public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix nice
@ 2002-02-28 14:15 Jakub Jelinek
  2002-03-01 16:32 ` Ulrich Drepper
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jakub Jelinek @ 2002-02-28 14:15 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

2001-06-04 patch for nice apparently changed nothing at all on linux, since
sysdeps/unix/nice.c which was patched is overridden in
sysdeps/unix/sysv/syscalls.list (nice), thus nice still returns 0 on
success, not the actual new priority.
Fix below. I have briefly tested that it works as expected on ia32 linux.

2002-02-28  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/sysv/linux/nice.c: New file.

--- libc/sysdeps/unix/sysv/linux/nice.c.jj	Thu Feb 28 23:12:51 2002
+++ libc/sysdeps/unix/sysv/linux/nice.c	Thu Feb 28 23:15:06 2002
@@ -0,0 +1 @@
+#include <sysdeps/unix/nice.c>

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix nice
  2002-02-28 14:15 [PATCH] Fix nice Jakub Jelinek
@ 2002-03-01 16:32 ` Ulrich Drepper
  2002-03-01 16:50   ` Andreas Schwab
  2002-03-01 16:48 ` Ulrich Drepper
  2002-03-02  1:42 ` Thorsten Kukuk
  2 siblings, 1 reply; 6+ messages in thread
From: Ulrich Drepper @ 2002-03-01 16:32 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Jakub Jelinek <jakub@redhat.com> writes:

> 2002-02-28  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* sysdeps/unix/sysv/linux/nice.c: New file.
> 
> --- libc/sysdeps/unix/sysv/linux/nice.c.jj	Thu Feb 28 23:12:51 2002
> +++ libc/sysdeps/unix/sysv/linux/nice.c	Thu Feb 28 23:15:06 2002
> @@ -0,0 +1 @@
> +#include <sysdeps/unix/nice.c>

Why do you want to avoid using the nice() syscall?  If the syscall is
returning the wrong value this can be fixed.  But using
getpriority/setpriority seems not the smartest thing to do.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix nice
  2002-02-28 14:15 [PATCH] Fix nice Jakub Jelinek
  2002-03-01 16:32 ` Ulrich Drepper
@ 2002-03-01 16:48 ` Ulrich Drepper
  2002-03-02  1:42 ` Thorsten Kukuk
  2 siblings, 0 replies; 6+ messages in thread
From: Ulrich Drepper @ 2002-03-01 16:48 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Well, I should have checked first.  The kernel is apparently not
providing any other way to get the information needed.  Calling nice
and then getpriority is even more wrong.  I've applied the patch.
Thanks,

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix nice
  2002-03-01 16:32 ` Ulrich Drepper
@ 2002-03-01 16:50   ` Andreas Schwab
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2002-03-01 16:50 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Jakub Jelinek, Glibc hackers

Ulrich Drepper <drepper@redhat.com> writes:

|> Jakub Jelinek <jakub@redhat.com> writes:
|> 
|> > 2002-02-28  Jakub Jelinek  <jakub@redhat.com>
|> > 
|> > 	* sysdeps/unix/sysv/linux/nice.c: New file.
|> > 
|> > --- libc/sysdeps/unix/sysv/linux/nice.c.jj	Thu Feb 28 23:12:51 2002
|> > +++ libc/sysdeps/unix/sysv/linux/nice.c	Thu Feb 28 23:15:06 2002
|> > @@ -0,0 +1 @@
|> > +#include <sysdeps/unix/nice.c>
|> 
|> Why do you want to avoid using the nice() syscall?  If the syscall is
|> returning the wrong value this can be fixed.  But using
|> getpriority/setpriority seems not the smartest thing to do.

You have to resort to getpriority anyway to fix nice.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix nice
  2002-02-28 14:15 [PATCH] Fix nice Jakub Jelinek
  2002-03-01 16:32 ` Ulrich Drepper
  2002-03-01 16:48 ` Ulrich Drepper
@ 2002-03-02  1:42 ` Thorsten Kukuk
  2002-03-09  6:40   ` Andreas Jaeger
  2 siblings, 1 reply; 6+ messages in thread
From: Thorsten Kukuk @ 2002-03-02  1:42 UTC (permalink / raw)
  To: libc-hacker; +Cc: drepper

On Thu, Feb 28, Jakub Jelinek wrote:

> Hi!
> 
> 2001-06-04 patch for nice apparently changed nothing at all on linux, since
> sysdeps/unix/nice.c which was patched is overridden in
> sysdeps/unix/sysv/syscalls.list (nice), thus nice still returns 0 on
> success, not the actual new priority.
> Fix below. I have briefly tested that it works as expected on ia32 linux.

I found another problem: according to 1003.1-2001:

Requests for values above or below 2*{NZERO}-1 shall result in the 
nice value being set to the corresponding limit.

In the moment we return "prio + incr" and fail the test. Should we
change this to a "return getpriority (PRIO_PROCESS, 0);" or should
we recalculate the return value with help of the NZERO definition?

A simple patch which works for me:

2002-03-02  Thorsten Kukuk  <kukuk@suse.de>

        * sysdeps/unix/nice.c: Use getpriority() for the return value
 
--- sysdeps/unix/nice.c
+++ sysdeps/unix/nice.c 2002/03/02 09:40:14
@@ -43,7 +43,7 @@

   result = setpriority (PRIO_PROCESS, 0, prio + incr);
   if (result != -1)
-    return prio + incr;
+    return getpriority (PRIO_PROCESS, 0);
   else
     return -1;


-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/        kukuk@suse.de
SuSE Linux AG        Deutschherrenstr. 15-19       D-90429 Nuernberg
--------------------------------------------------------------------    
Key fingerprint = A368 676B 5E1B 3E46 CFCE  2D97 F8FD 4E23 56C6 FB4B

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix nice
  2002-03-02  1:42 ` Thorsten Kukuk
@ 2002-03-09  6:40   ` Andreas Jaeger
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Jaeger @ 2002-03-09  6:40 UTC (permalink / raw)
  To: Thorsten Kukuk; +Cc: libc-hacker, drepper

Thorsten Kukuk <kukuk@suse.de> writes:

> On Thu, Feb 28, Jakub Jelinek wrote:
>
>> Hi!
>> 
>> 2001-06-04 patch for nice apparently changed nothing at all on linux, since
>> sysdeps/unix/nice.c which was patched is overridden in
>> sysdeps/unix/sysv/syscalls.list (nice), thus nice still returns 0 on
>> success, not the actual new priority.
>> Fix below. I have briefly tested that it works as expected on ia32 linux.
>
> I found another problem: according to 1003.1-2001:
>
> Requests for values above or below 2*{NZERO}-1 shall result in the 
> nice value being set to the corresponding limit.
>
> In the moment we return "prio + incr" and fail the test. Should we
> change this to a "return getpriority (PRIO_PROCESS, 0);" or should
> we recalculate the return value with help of the NZERO definition?
>
> A simple patch which works for me:
>
> 2002-03-02  Thorsten Kukuk  <kukuk@suse.de>
>
>         * sysdeps/unix/nice.c: Use getpriority() for the return value
>  
> --- sysdeps/unix/nice.c
> +++ sysdeps/unix/nice.c 2002/03/02 09:40:14
> @@ -43,7 +43,7 @@
>
>    result = setpriority (PRIO_PROCESS, 0, prio + incr);
>    if (result != -1)
> -    return prio + incr;
> +    return getpriority (PRIO_PROCESS, 0);
>    else
>      return -1;

Just for reference, the current implementation behaves this way:
nice(0)=0       getpriority()=0
nice(-100)=-100 getpriority()=-20
nice(-80)=-100  getpriority()=-20
nice(-60)=-80   getpriority()=-20
nice(-40)=-60   getpriority()=-20
nice(-20)=-40   getpriority()=-20
nice(0)=-20     getpriority()=-20
nice(20)=0      getpriority()=0
nice(40)=40     getpriority()=19
nice(60)=79     getpriority()=19
nice(80)=99     getpriority()=19
nice(100)=119   getpriority()=19

A return value of 119 is defintely wrong,
Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-03-09 14:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-28 14:15 [PATCH] Fix nice Jakub Jelinek
2002-03-01 16:32 ` Ulrich Drepper
2002-03-01 16:50   ` Andreas Schwab
2002-03-01 16:48 ` Ulrich Drepper
2002-03-02  1:42 ` Thorsten Kukuk
2002-03-09  6:40   ` Andreas Jaeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).