[PATCH] introduce is_rt_policy() helper
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 29 Sep 2006 09:00:49 +0000 (02:00 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 29 Sep 2006 16:18:17 +0000 (09:18 -0700)
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>
include/linux/sched.h
kernel/sched.c

index 503dea61ff99d7e761c34ec9d3a62668388eadce..fbc69cc3923d876997e4c391a8274ad4ce4212ae 100644 (file)
@@ -504,8 +504,8 @@ struct signal_struct {
 #define rt_prio(prio)          unlikely((prio) < MAX_RT_PRIO)
 #define rt_task(p)             rt_prio((p)->prio)
 #define batch_task(p)          (unlikely((p)->policy == SCHED_BATCH))
-#define has_rt_policy(p) \
-       unlikely((p)->policy != SCHED_NORMAL && (p)->policy != SCHED_BATCH)
+#define is_rt_policy(p)                ((p) != SCHED_NORMAL && (p) != SCHED_BATCH)
+#define has_rt_policy(p)       unlikely(is_rt_policy((p)->policy))
 
 /*
  * Some day this will be a full-fledged user tracking system..
index f9b3c6a414f189bf443044b9947715cb94825fa5..c3c718aea618c505247631ccde8ccd1c0c31d3b0 100644 (file)
@@ -4109,8 +4109,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 (is_rt_policy(policy) != (param->sched_priority != 0))
                return -EINVAL;
 
        /*
@@ -4134,7 +4133,7 @@ recheck:
                                !rlim_rtprio)
                        return -EPERM;
                /* 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 > rlim_rtprio)
                        return -EPERM;