lkml.org 
[lkml]   [2011]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] sched: allow users with rtprio rlimit to change from SCHED_IDLE policy
From
Date
On Wed, 2011-02-23 at 13:28 -0800, Darren Hart wrote:
> From: Darren Hart <dvhart@linux.intel.com>
> Date: Thu, 17 Feb 2011 15:37:07 -0800
> Subject: [PATCH] sched: allow users with sufficient RLIMIT_NICE to change from SCHED_IDLE policy
>
> The current scheduler implementation returns -EPERM when trying to change from
> SCHED_IDLE to SCHED_OTHER or SCHED_BATCH.


> Since SCHED_IDLE is considered to be
> equivalent to a nice 20,

Well, its not quite equivalent, its actually 5 times lighter still and
the preemption behaviour is slightly different as you've found ;-)

> changing to another policy should be allowed provided
> the RLIMIT_NICE is accounted for.
>
> This patch allows the following test-case to pass with RLIMIT_NICE=40, but still
> fail with RLIMIT_NICE=10 when the calling process is run from a typical shell
> (nice 0, or 20 in rlimit terms).

>
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
> kernel/sched.c | 11 +++++++----
> 1 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 18d38e4..9bf6284 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -4822,12 +4822,15 @@ recheck:
> param->sched_priority > rlim_rtprio)
> return -EPERM;
> }
> +
> /*
> + * Treat SCHED_IDLE as nice 20. Only allow a switch to
> + * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
> */
> + if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) {
> + if (!can_nice(p, TASK_NICE(p)))
> + return -EPERM;
> + }
>
> /* can't change other user's priorities */
> if (!check_same_owner(p))

Looks fine, thanks!


\
 
 \ /
  Last update: 2011-02-24 12:51    [W:0.066 / U:3.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site