From: Stephen Baker <stbaker@cisco.com>
To: linux-kernel@vger.kernel.org
Subject: Linux Kernel Patch; setpriority
Date: Wed, 27 Mar 2002 14:59:13 -0600 [thread overview]
Message-ID: <3CA232A1.7040702@cisco.com> (raw)
All,
This patch will allow a process or thread to changes it's priority
dynamically based on it's capabilities. In our case we wanted to use
threads with Linux. To have true priorities we need root to use
SCHED_FIFO or SCHED_RR; in many case root access is not allowed but we
still wanted priorities. So we started using setpriority to change a
threads priority. Now we used nice values from 19 to 0 which did not
require root access. In some cases a thread need to raise it's nice
level and this would fail. I also saw a note man renice(8) that said
this bug exists.
So the following patch address this problem. It allows any process or
thread to raise or lower it's nice value for it's current capability.
For example a CAP_SYS_NICE process can use 19 to -20 for it's value and
a normal user can use 19 to 0. By capping normal user to zero then we
don't have any problems with conflicts with higher priority programs in
the system since zero is the default value.
SB
--- linux-2.4.9-31/kernel/sys.c Wed Mar 27 13:11:10 2002
+++ linux/kernel/sys.c Wed Mar 27 13:09:36 2002
@@ -194,6 +194,12 @@
return 0;
}
+/*
+ * Allow the process to adjust it's priority higher or lower.
+ * If the process has CAP_SYS_NICE set then we can use
+ * -20 to 19. Otherwise we use 0 to 19 as our valid priority
+ * range.
+ */
asmlinkage long sys_setpriority(int which, int who, int niceval)
{
struct task_struct *p;
@@ -220,7 +226,8 @@
}
if (error == -ESRCH)
error = 0;
- if (niceval < p->nice && !capable(CAP_SYS_NICE))
+ if ((niceval < 0) &&
+ (niceval < p->nice && !capable(CAP_SYS_NICE)))
error = -EACCES;
else
p->nice = niceval;
next reply other threads:[~2002-03-27 21:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-27 20:59 Stephen Baker [this message]
2002-03-27 21:19 ` Linux Kernel Patch; setpriority David Wagner
2002-03-29 0:24 ` Mike Fedyk
2002-03-27 22:32 ` Chris Wright
2002-03-28 21:19 ` Bill Davidsen
2002-03-28 22:20 ` Stephen Baker
2002-03-29 0:39 ` Bill Davidsen
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=3CA232A1.7040702@cisco.com \
--to=stbaker@cisco.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