diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/build.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 948c3951f4..22428a649c 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -413,6 +413,13 @@ def _exec_task(fn, task, d, quieterr): | |||
413 | nice = int(nice) - curnice | 413 | nice = int(nice) - curnice |
414 | newnice = os.nice(nice) | 414 | newnice = os.nice(nice) |
415 | logger.debug(1, "Renice to %s " % newnice) | 415 | logger.debug(1, "Renice to %s " % newnice) |
416 | ionice = localdata.getVar("BB_TASK_IONICE_LEVEL", True) | ||
417 | if ionice: | ||
418 | try: | ||
419 | cls, prio = ionice.split(".", 1) | ||
420 | bb.utils.ioprio_set(os.getpid(), int(cls), int(prio)) | ||
421 | except: | ||
422 | bb.warn("Invalid ionice level %s" % ionice) | ||
416 | 423 | ||
417 | bb.utils.mkdirhier(tempdir) | 424 | bb.utils.mkdirhier(tempdir) |
418 | 425 | ||
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 9b550ef3f1..7f82687ae4 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -1311,3 +1311,27 @@ def signal_on_parent_exit(signame): | |||
1311 | result = cdll['libc.so.6'].prctl(PR_SET_PDEATHSIG, signum) | 1311 | result = cdll['libc.so.6'].prctl(PR_SET_PDEATHSIG, signum) |
1312 | if result != 0: | 1312 | if result != 0: |
1313 | raise PrCtlError('prctl failed with error code %s' % result) | 1313 | raise PrCtlError('prctl failed with error code %s' % result) |
1314 | |||
1315 | # | ||
1316 | # Manually call the ioprio syscall. We could depend on other libs like psutil | ||
1317 | # however this gets us enough of what we need to bitbake for now without the | ||
1318 | # dependency | ||
1319 | # | ||
1320 | _unamearch = os.uname()[4] | ||
1321 | IOPRIO_WHO_PROCESS = 1 | ||
1322 | IOPRIO_CLASS_SHIFT = 13 | ||
1323 | |||
1324 | def ioprio_set(who, cls, value): | ||
1325 | NR_ioprio_set = None | ||
1326 | if _unamearch == "x86_64": | ||
1327 | NR_ioprio_set = 251 | ||
1328 | elif _unamearch[0] == "i" and _unamearch[2:3] == "86": | ||
1329 | NR_ioprio_set = 289 | ||
1330 | |||
1331 | if NR_ioprio_set: | ||
1332 | ioprio = value | (cls << IOPRIO_CLASS_SHIFT) | ||
1333 | rc = cdll['libc.so.6'].syscall(NR_ioprio_set, IOPRIO_WHO_PROCESS, who, ioprio) | ||
1334 | if rc != 0: | ||
1335 | raise ValueError("Unable to set ioprio, syscall returned %s" % rc) | ||
1336 | else: | ||
1337 | bb.warn("Unable to set IO Prio for arch %s" % _unamearch) | ||