Subject: kern/33671: getpriority(2) under COMPAT_LINUX return wrong values
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 06/08/2006 18:25:00
>Number:         33671
>Category:       kern
>Synopsis:       getpriority(2) under COMPAT_LINUX return wrong values
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 08 18:25:00 +0000 2006
>Originator:     Nicolas Joly
>Release:        NetBSD 3.99.17
>Organization:
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 3.99.17 NetBSD 3.99.17 (LANFEUST) #4: Fri Mar 31 11:46:51 CEST 2006 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
While running some linux binaries on my -current NetBSD/amd64, i noticed that
getpriority(2) return wrong values. According to the linux man page (notes
section), this syscall returns values in 40..1 interval instead of the expected
-20 to 20 range.

I wad able to reproduce this behaviour with the following code, compiled
on a Linux/x86_64 RHEL4.3 and Linux/i386 RHEL3.7 machines :

njoly@lanfeust [~]> cat priority.c 

#include <stdio.h>

#include <sys/time.h>
#include <sys/resource.h>

int main() {
  int p;

  p = getpriority(PRIO_PROCESS, 0);
  printf("Running at priority = %d\n", p);

  p = setpriority(PRIO_PROCESS, 0, 4);
  printf("Setting priority to 4\n");

  p = getpriority(PRIO_PROCESS, 0);
  printf("Running at priority = %d\n", p);

  return 0; }

njoly@lanfeust [~]> file ./priority
./priority: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
njoly@lanfeust [~]> ./priority 
Running at priority = 20
Setting priority to 4
Running at priority = 16

>How-To-Repeat:
Run a linux program in compat mode that call getpriority(2).
>Fix:
don't know.