]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
[PATCH] sched_setscheduler: fix? policy checks
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 29 Sep 2006 09:00:50 +0000 (02:00 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 29 Sep 2006 16:18:17 +0000 (09:18 -0700)
commit8dc3e9099e01dfdd53f27f329c268eced03dfef6
treec4a88aeabd5726185bf65c75cc52145d9dc33e43
parent57a6f51c4281aa3119975473c70dce0480d322bd
[PATCH] sched_setscheduler: fix? policy checks

I am not sure this patch is correct: I can't understand what the current
code does, and I don't know what it was supposed to do.

The comment says:

 * can't change policy, except between SCHED_NORMAL
 * and SCHED_BATCH:

The code:

if (((policy != SCHED_NORMAL && p->policy != SCHED_BATCH) &&
(policy != SCHED_BATCH && p->policy != SCHED_NORMAL)) &&

But this is equivalent to:

if ( (is_rt_policy(policy) && has_rt_policy(p)) &&

which means something different.  We can't _decrease_ the current
->rt_priority with such a check (if rlim[RLIMIT_RTPRIO] == 0).

Probably, it was supposed to be:

if ( !(policy == SCHED_NORMAL && p->policy == SCHED_BATCH)  &&
!(policy == SCHED_BATCH  && p->policy == SCHED_NORMAL)

this matches the comment, but strange: it doesn't allow to _drop_ the
realtime priority when rlim[RLIMIT_RTPRIO] == 0.

I think the right check would be:

/* can't set/change rt policy */
if (is_rt_policy(policy) &&
policy != p->policy &&
!rlim_rtprio)
return -EPERM;

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>
kernel/sched.c