From: Kristis Makris <devcore@freeuk.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] niceness magic numbers, 2.4.20-pre11
Date: 22 Oct 2002 21:59:17 -0700 [thread overview]
Message-ID: <1035349158.491.29.camel@mcmicro> (raw)
[-- Attachment #1: Type: text/plain, Size: 219 bytes --]
This untested patch removes use of process priority magic numbers in
sys_nice, sys_setpriority, sys_getpriority, and properly uses their
#define'd values.
It would be nice if someone tested if it applies against 2.5.
[-- Attachment #2: niceness_magic_numbers.patch --]
[-- Type: text/x-patch, Size: 2060 bytes --]
diff -ur linux-2.4.20-pre11.orig/include/linux/resource.h linux/include/linux/resource.h
--- linux-2.4.20-pre11.orig/include/linux/resource.h Tue Jun 18 20:10:36 2002
+++ linux/include/linux/resource.h Sat Oct 19 13:55:10 2002
@@ -43,7 +43,7 @@
};
#define PRIO_MIN (-20)
-#define PRIO_MAX 20
+#define PRIO_MAX 19
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
diff -ur linux-2.4.20-pre11.orig/kernel/sched.c linux/kernel/sched.c
--- linux-2.4.20-pre11.orig/kernel/sched.c Sat Oct 19 13:26:59 2002
+++ linux/kernel/sched.c Sat Oct 19 13:41:19 2002
@@ -870,17 +870,19 @@
if (increment < 0) {
if (!capable(CAP_SYS_NICE))
return -EPERM;
- if (increment < -40)
- increment = -40;
+
+ /* +1 to account for 0 in min<-->max range */
+ if (increment < PRIO_MIN - (PRIO_MAX + 1))
+ increment = PRIO_MIN - (PRIO_MAX + 1);
}
- if (increment > 40)
- increment = 40;
+ if (increment > -(PRIO_MIN - (PRIO_MAX + 1)))
+ increment = -(PRIO_MIN - (PRIO_MAX + 1));
newprio = current->nice + increment;
- if (newprio < -20)
- newprio = -20;
- if (newprio > 19)
- newprio = 19;
+ if (newprio < PRIO_MIN)
+ newprio = PRIO_MIN;
+ if (newprio > PRIO_MAX)
+ newprio = PRIO_MAX;
current->nice = newprio;
return 0;
}
diff -ur linux-2.4.20-pre11.orig/kernel/sys.c linux/kernel/sys.c
--- linux-2.4.20-pre11.orig/kernel/sys.c Sat Oct 19 11:58:48 2002
+++ linux/kernel/sys.c Sat Oct 19 13:37:48 2002
@@ -204,10 +204,10 @@
/* normalize: avoid signed division (rounding problems) */
error = -ESRCH;
- if (niceval < -20)
- niceval = -20;
- if (niceval > 19)
- niceval = 19;
+ if (niceval < PRIO_MIN)
+ niceval = PRIO_MIN;
+ if (niceval > PRIO_MAX)
+ niceval = PRIO_MAX;
read_lock(&tasklist_lock);
for_each_task(p) {
@@ -249,7 +249,8 @@
long niceval;
if (!proc_sel(p, which, who))
continue;
- niceval = 20 - p->nice;
+ niceval = PRIO_MAX + 1 - p->nice; /* +1 to account for 0
+ * in 0<-->max range */
if (niceval > retval)
retval = niceval;
}
next reply other threads:[~2002-10-23 4:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-23 4:59 Kristis Makris [this message]
2002-10-23 6:37 ` [PATCH] niceness magic numbers, 2.4.20-pre11 Randy.Dunlap
2002-10-23 8:16 ` Alan Cox
2002-10-23 19:52 ` Robert Love
2002-10-23 23:50 ` [PATCH] niceness magic numbers, 2.5.44 now Randy.Dunlap
2002-10-24 0:11 ` Robert Love
2002-10-24 3:22 ` [PATCH] niceness magic numbers, 2.4.20-pre11 Kristis Makris
2002-10-24 3:32 ` Robert Love
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1035349158.491.29.camel@mcmicro \
--to=devcore@freeuk.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox