Commit 57a6f51c authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] introduce is_rt_policy() helper

Imho, makes the code a bit easier to read.
Signed-off-by: default avatarOleg 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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5fe1d75f
...@@ -504,8 +504,8 @@ struct signal_struct { ...@@ -504,8 +504,8 @@ struct signal_struct {
#define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO) #define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO)
#define rt_task(p) rt_prio((p)->prio) #define rt_task(p) rt_prio((p)->prio)
#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH)) #define batch_task(p) (unlikely((p)->policy == SCHED_BATCH))
#define has_rt_policy(p) \ #define is_rt_policy(p) ((p) != SCHED_NORMAL && (p) != SCHED_BATCH)
unlikely((p)->policy != SCHED_NORMAL && (p)->policy != SCHED_BATCH) #define has_rt_policy(p) unlikely(is_rt_policy((p)->policy))
/* /*
* Some day this will be a full-fledged user tracking system.. * Some day this will be a full-fledged user tracking system..
......
...@@ -4109,8 +4109,7 @@ int sched_setscheduler(struct task_struct *p, int policy, ...@@ -4109,8 +4109,7 @@ int sched_setscheduler(struct task_struct *p, int policy,
(p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) || (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
(!p->mm && param->sched_priority > MAX_RT_PRIO-1)) (!p->mm && param->sched_priority > MAX_RT_PRIO-1))
return -EINVAL; return -EINVAL;
if ((policy == SCHED_NORMAL || policy == SCHED_BATCH) if (is_rt_policy(policy) != (param->sched_priority != 0))
!= (param->sched_priority == 0))
return -EINVAL; return -EINVAL;
/* /*
...@@ -4134,7 +4133,7 @@ int sched_setscheduler(struct task_struct *p, int policy, ...@@ -4134,7 +4133,7 @@ int sched_setscheduler(struct task_struct *p, int policy,
!rlim_rtprio) !rlim_rtprio)
return -EPERM; return -EPERM;
/* can't increase priority */ /* can't increase priority */
if ((policy != SCHED_NORMAL && policy != SCHED_BATCH) && if (is_rt_policy(policy) &&
param->sched_priority > p->rt_priority && param->sched_priority > p->rt_priority &&
param->sched_priority > rlim_rtprio) param->sched_priority > rlim_rtprio)
return -EPERM; return -EPERM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment