procps/ps
Mike Fleetwood 2bac5334b0 ps: display the nice value for processes with the SCHED_BATCH scheduler policy
Ps command does not display the nice value for processes with the SCHED_BATCH
scheduler policy, only for SCHED_OTHER.

Boinc (http://boinc.berkeley.edu/) client runs project processing jobs on
Linux using SCHED_BATCH scheduler policy and nice value 19.  The nice value
is not displayable by ps.

Steps to Reproduce:
1. Run process using SCHED_BATCH scheduler policy with nice value.
    ./test-schedbatch 18 &
2. Display process details:
    ps -o pid,ppid,user,comm,cls,nice

Results before:
[mike@rockover c]$ ps -o pid,ppid,user,comm,cls,nice
  PID  PPID USER     COMMAND         CLS  NI
18205  2540 mike     bash             TS   0
20552 18205 mike     test-schedbatch   B   -
20553 18205 mike     ps               TS   0
[mike@rockover c]$ awk '{printf "%5d %-17s %1d %2d\n", $1, $2, $41, $19}'
/proc/20552/stat
20552 (test-schedbatch) 3 18

Results after this patch:
[mike@rockover c]$ ps -o pid,ppid,user,comm,cls,nice
  PID  PPID USER     COMMAND         CLS  NI
18205  2540 mike     bash             TS   0
20552 18205 mike     test-schedbatch   B  18
20553 18205 mike     ps               TS   0

Additional info: Here is the fragment from the sched_setscheduler(2) manual
page on the subject:

   SCHED_BATCH: Scheduling batch processes
       (Since  Linux 2.6.16.)  SCHED_BATCH can only be used at static
       priority 0.  This policy is similar to SCHED_OTHER in that it
       schedules the process according to its dynamic priority (based on the
       nice value).  The difference is that this policy will cause the
       scheduler to always assume that the process is CPU-intensive.
       Consequently, the scheduler will apply a small scheduling penalty with
       respect to wakeup behaviour, so that this process is mildly disfavored
       in scheduling decisions.

       This policy is useful for workloads that are noninteractive, but do
       not want to lower their nice value, and for workloads that want a
       determin- istic scheduling policy without interactivity causing extra
       preemptions (between the workload's tasks).

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=741090
Acked-by: Jaromir Capik <jcapik@redhat.com>
Acked-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
2012-01-09 21:37:41 +01:00
..
common.h ps: generalize help text logic, add related translator hints 2012-01-04 08:58:53 +11:00
COPYING ps: minor reformatting and trailing whitespace elimination 2012-01-04 08:58:53 +11:00
display.c ps: generalize help text logic, add related translator hints 2012-01-04 08:58:53 +11:00
global.c ps: generalize help text logic, add related translator hints 2012-01-04 08:58:53 +11:00
HACKING procps 010114 2002-02-01 22:47:29 +00:00
help.c ps: generalize help text logic, add related translator hints 2012-01-04 08:58:53 +11:00
Makefile.am build-sys: correct all Makefile.am files for LOCALEDIR, etc 2012-01-04 08:58:54 +11:00
output.c ps: display the nice value for processes with the SCHED_BATCH scheduler policy 2012-01-09 21:37:41 +01:00
parser.c ps: corrections to messages 2012-01-06 00:17:50 +11:00
ps.1 ps: update man document for redesigned help provisions 2012-01-04 08:58:53 +11:00
regression procps 010114 2002-02-01 22:47:29 +00:00
select.c ps: minor reformatting and trailing whitespace elimination 2012-01-04 08:58:53 +11:00
sortformat.c ps: change PACKAGE_BUGREPORT to procps@freelists.org 2012-01-05 09:56:05 +11:00
stacktrace.c ps: exclude debugging only code from participation in nls support 2012-01-04 08:58:53 +11:00