Package: runit
Version: 1.7.2-1
Severity: normal

Hello!

chpst -n seems to always sets the nice value to 19 on x86_64, no 
matter what argument has been given:

$ chpst -n 5 ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S  1000 11267 10824  0  75   0 -  2634 -      pts/7    00:00:00 bash
0 R  1000 11742 11267  0  97  19 -  1892 -      pts/7    00:00:00 ps

On the other hand, chpst works just fine on x86:

[on the x86 box]
$ chpst -n 5 ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S  1000 14282 23386  4  75   0 -  2928 -      pts/3    00:00:00 bash
0 R  1000  5586 14282  0  82   5 -  1827 -      pts/3    00:00:00 ps


[on the x86_64 box]
$ strace -f chpst -n 5 /bin/true 2>&1 | head -n 5
execve("/usr/bin/chpst", ["chpst", "-n", "5", "/bin/true"], [/* 68 vars */]) = 0
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 25)        = 0
getpriority(PRIO_PROCESS, 0)            = 1
execve("/bin/true", ["/bin/true"], [/* 68 vars */]) = 0

On Linux, "getpriority()" will not return the normal nice-value, but
a negated value that has been offset by 20 (ie it returns 40..1 instead
of -20..19) to avoid negative return values.

On the other hand, "setpriority" accepts _regular_ nice value in the
range -20..19. chpst seems to ignore this difference and sets wrong
nice value as a result.
 
x86 is not affected since chpst uses "nice" system call here:

[on the x86 box]
$ strace chpst -n 5 /bin/true 2>&1 | head -n 3
execve("/usr/bin/chpst", ["chpst", "-n", "5", "/bin/true"], [/* 67 vars */]) = 0
nice(5)                                 = 0
execve("/bin/true", ["/bin/true"], [/* 67 vars */]) = 0


So I think chpst should either use "nice" system call on x86_64 too 
(BTW this should be much faster than getpriority/setpriority variant)
or perform the conversion.

Sorry for not providing the patch (runit source is not exactly
hacker-friendly).


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.17.11-grsec-em64t-p4
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)

runit depends on no packages.

Versions of packages runit recommends:
pn  fgetty                        <none>     (no description available)

-- no debconf information

-- 
All science is either physics or stamp collecting.

Attachment: signature.asc
Description: Digital signature

Reply via email to