Skip to contentSkip to conversation

build: Add BB_TASK_NICE_LEVEL to task code

PATCH In review Richard Purdie 2 participants 3 messages Sep 20, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: Add BB_TASK_NICE_LEVEL to task code

On Linux its not possible for processes to regain a previous nice level after it has changed. Its therefore not possible to have a core low priority and then raise the priorities of individual tasks.

This variable allows us to do something like:

BB_TASK_NICE_LEVEL = "5"
BB_TASK_NICE_LEVEL_task-testimage = "0"

to give priority to specific tasks which the BB_NICE_LEVEL functionality doesn't give us the option of.

---

bitbake/lib/bb/build.py +7 -0
index 8aec699..9addd71 100644
@@ -346,6 +346,13 @@ def _exec_task(fn, task, d, quieterr):
     if not tempdir:
         bb.fatal("T variable not set, unable to build")
 
+    # Change nice level if we're asked to
+    nice = localdata.getVar("BB_TASK_NICE_LEVEL", True)
+    if nice:
+        curnice = os.nice(0)
+        nice = int(nice) - curnice
+        logger.debug(1, "Renice to %s " % os.nice(nice))
+
     bb.utils.mkdirhier(tempdir)
 
     # Determine the logfile to generate
#1 lore raw
Quoted 19 lines · On Friday 20 September 2013 11:29:47 Richard Purdie wrote:

On Linux its not possible for processes to regain a previous nice level after it has changed. Its therefore not possible to have a core low priority and then raise the priorities of individual tasks.

This variable allows us to do something like:

BB_TASK_NICE_LEVEL = "5"
BB_TASK_NICE_LEVEL_task-testimage = "0"

to give priority to specific tasks which the BB_NICE_LEVEL functionality doesn't give us the option of.

---

bitbake/lib/bb/build.py +0 -0
index 8aec699..9addd71 100644

bitbake/lib/bb/build.py def _exec_task(fn, task, d, quieterr): · line 354

Quoted 9 lines
bitbake/lib/bb/build.py +6 -0
@@ -346,6 +346,13 @@ def _exec_task(fn, task, d, quieterr):
     if not tempdir:
         bb.fatal("T variable not set, unable to build")
 
+    # Change nice level if we're asked to
+    nice = localdata.getVar("BB_TASK_NICE_LEVEL", True)
+    if nice:
+        curnice = os.nice(0)
+        nice = int(nice) - curnice
+        logger.debug(1, "Renice to %s " % os.nice(nice))

It's a matter of style to be sure, but I think it's better not to have debug statements that do more than just printing debug output - could the latter be split onto two lines? Then it's easy to tell what's being done.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#2 lore raw
Quoted 23 lines · Paul Eggleton
Quoted 22 lines · On Friday 20 September 2013 11:29:47 Richard Purdie wrote:

On Linux its not possible for processes to regain a previous nice level after it has changed. Its therefore not possible to have a core low priority and then raise the priorities of individual tasks.

This variable allows us to do something like:

BB_TASK_NICE_LEVEL = "5"
BB_TASK_NICE_LEVEL_task-testimage = "0"

to give priority to specific tasks which the BB_NICE_LEVEL functionality doesn't give us the option of.

---

bitbake/lib/bb/build.py +0 -0
index 8aec699..9addd71 100644
@@ -346,6 +346,13 @@ def _exec_task(fn, task, d, quieterr):
     if not tempdir:
         bb.fatal("T variable not set, unable to build")
 
Quoted 10 lines

bitbake/lib/bb/build.py def _exec_task(fn, task, d, quieterr): · line 354

Quoted 6 lines
bitbake/lib/bb/build.py +6 -0
+    # Change nice level if we're asked to
+    nice = localdata.getVar("BB_TASK_NICE_LEVEL", True)
+    if nice:
+        curnice = os.nice(0)
+        nice = int(nice) - curnice
+        logger.debug(1, "Renice to %s " % os.nice(nice))

It's a matter of style to be sure, but I think it's better not to have debug statements that do more than just printing debug output - could the latter be split onto two lines? Then it's easy to tell what's being done.

Agreed, although this is a copy and paste of the BB_NICE_LEVEL code so we should probably fix both.

Cheers,

Richard