From: Con Kolivas <kernel@kolivas.org>
To: linux list <linux-kernel@vger.kernel.org>
Cc: ck list <ck@vds.kolivas.org>
Subject: [ckpatch][6/29] sched-range.patch
Date: Sun, 18 Jun 2006 17:30:57 +1000 [thread overview]
Message-ID: <200606181730.57652.kernel@kolivas.org> (raw)
Add SCHED_RANGE and SCHED_RT wrappers for easy policy management.
Signed-off-by: Con Kolivas <kernel@kolivas.org>
include/linux/sched.h | 7 +++++++
kernel/sched.c | 13 +++++--------
2 files changed, 12 insertions(+), 8 deletions(-)
Index: linux-ck-dev/include/linux/sched.h
===================================================================
--- linux-ck-dev.orig/include/linux/sched.h 2006-06-18 15:23:21.000000000 +1000
+++ linux-ck-dev/include/linux/sched.h 2006-06-18 15:23:35.000000000 +1000
@@ -165,6 +165,13 @@ extern unsigned long weighted_cpuload(co
#define SCHED_RR 2
#define SCHED_BATCH 3
+#define SCHED_MIN 0
+#define SCHED_MAX 3
+
+#define SCHED_RANGE(policy) ((policy) <= SCHED_MAX)
+#define SCHED_RT(policy) ((policy) == SCHED_FIFO || \
+ (policy) == SCHED_RR)
+
struct sched_param {
int sched_priority;
};
Index: linux-ck-dev/kernel/sched.c
===================================================================
--- linux-ck-dev.orig/kernel/sched.c 2006-06-18 15:23:21.000000000 +1000
+++ linux-ck-dev/kernel/sched.c 2006-06-18 15:23:35.000000000 +1000
@@ -3548,7 +3548,7 @@ static void __setscheduler(struct task_s
BUG_ON(task_queued(p));
p->policy = policy;
p->rt_priority = prio;
- if (policy != SCHED_NORMAL && policy != SCHED_BATCH) {
+ if (SCHED_RT(policy)) {
p->prio = MAX_RT_PRIO-1 - p->rt_priority;
} else
p->prio = p->static_prio;
@@ -3574,8 +3574,7 @@ recheck:
/* double check policy once rq lock held */
if (policy < 0)
policy = oldpolicy = p->policy;
- else if (policy != SCHED_FIFO && policy != SCHED_RR &&
- policy != SCHED_NORMAL && policy != SCHED_BATCH)
+ else if (!SCHED_RANGE(policy))
return -EINVAL;
/*
* Valid priorities for SCHED_FIFO and SCHED_RR are
@@ -3586,8 +3585,7 @@ recheck:
(p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
(!p->mm && param->sched_priority > MAX_RT_PRIO-1))
return -EINVAL;
- if ((policy == SCHED_NORMAL || policy == SCHED_BATCH)
- != (param->sched_priority == 0))
+ if ((!SCHED_RT(policy)) != (param->sched_priority == 0))
return -EINVAL;
/*
@@ -3598,12 +3596,11 @@ recheck:
* can't change policy, except between SCHED_NORMAL
* and SCHED_BATCH:
*/
- if (((policy != SCHED_NORMAL && p->policy != SCHED_BATCH) &&
- (policy != SCHED_BATCH && p->policy != SCHED_NORMAL)) &&
+ if (SCHED_RT(policy) && policy != p->policy &&
!p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
return -EPERM;
/* can't increase priority */
- if ((policy != SCHED_NORMAL && policy != SCHED_BATCH) &&
+ if (SCHED_RT(policy) &&
param->sched_priority > p->rt_priority &&
param->sched_priority >
p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
--
-ck
reply other threads:[~2006-06-18 7:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200606181730.57652.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=ck@vds.kolivas.org \
--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