aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-09-29 05:00:49 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:17 -0400
commit57a6f51c4281aa3119975473c70dce0480d322bd (patch)
tree05d22c0c64fc9de38554b6aca24b021a81479975
parent5fe1d75f34974046fffcca5e22fb8a7b42fded33 (diff)
[PATCH] introduce is_rt_policy() helper
Imho, makes the code a bit easier to read. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/sched.h4
-rw-r--r--kernel/sched.c5
2 files changed, 4 insertions, 5 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 503dea61ff99..fbc69cc3923d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -504,8 +504,8 @@ struct signal_struct {
504#define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO) 504#define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO)
505#define rt_task(p) rt_prio((p)->prio) 505#define rt_task(p) rt_prio((p)->prio)
506#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH)) 506#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH))
507#define has_rt_policy(p) \ 507#define is_rt_policy(p) ((p) != SCHED_NORMAL && (p) != SCHED_BATCH)
508 unlikely((p)->policy != SCHED_NORMAL && (p)->policy != SCHED_BATCH) 508#define has_rt_policy(p) unlikely(is_rt_policy((p)->policy))
509 509
510/* 510/*
511 * Some day this will be a full-fledged user tracking system.. 511 * Some day this will be a full-fledged user tracking system..
diff --git a/kernel/sched.c b/kernel/sched.c
index f9b3c6a414f1..c3c718aea618 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4109,8 +4109,7 @@ recheck:
4109 (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) || 4109 (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
4110 (!p->mm && param->sched_priority > MAX_RT_PRIO-1)) 4110 (!p->mm && param->sched_priority > MAX_RT_PRIO-1))
4111 return -EINVAL; 4111 return -EINVAL;
4112 if ((policy == SCHED_NORMAL || policy == SCHED_BATCH) 4112 if (is_rt_policy(policy) != (param->sched_priority != 0))
4113 != (param->sched_priority == 0))
4114 return -EINVAL; 4113 return -EINVAL;
4115 4114
4116 /* 4115 /*
@@ -4134,7 +4133,7 @@ recheck:
4134 !rlim_rtprio) 4133 !rlim_rtprio)
4135 return -EPERM; 4134 return -EPERM;
4136 /* can't increase priority */ 4135 /* can't increase priority */
4137 if ((policy != SCHED_NORMAL && policy != SCHED_BATCH) && 4136 if (is_rt_policy(policy) &&
4138 param->sched_priority > p->rt_priority && 4137 param->sched_priority > p->rt_priority &&
4139 param->sched_priority > rlim_rtprio) 4138 param->sched_priority > rlim_rtprio)
4140 return -EPERM; 4139 return -EPERM;