lkml.org 
[lkml]   [2009]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] scheduler: introduce SCHED_RESET_ON_FORK scheduling policy flag, Second try
On Fri, 29.05.09 11:28, Peter Zijlstra (peterz@infradead.org) wrote:

> > This patch introduces a new flag SCHED_RESET_ON_FORK which can be passed
> > to the kernel via sched_setscheduler(), ORed in the policy parameter. If
> > set this will make sure that when the process forks a) the scheduling
> > priority is reset to DEFAULT_PRIO if it was higher and b) the scheduling
> > policy is reset to SCHED_NORMAL if it was either SCHED_FIFO or SCHED_RR.
>
> Maybe SCHED_OTHER_ON_FORK, or SCHED_DEFAULT_ON_FORK?

Hmm, I think this would be misleading, since it does more than just
reset to SCHED_OTHER. It also resets the nice level.

> > + if (current->sched_reset_on_fork &&
> > + (p->policy == SCHED_FIFO || p->policy == SCHED_RR))
> > + p->policy = SCHED_NORMAL;
> > +
> > + if (current->sched_reset_on_fork &&
> > + (current->normal_prio < DEFAULT_PRIO))
> > + p->prio = DEFAULT_PRIO;
> > + else
> > + p->prio = current->normal_prio;
>
> This bit hurt my brain, what's wrong with:
>
> p->prio = current->normal_prio; /* don't leak boosted prio */
> if (current->sched_reset_on_fork) {
> p->policy = SCHED_NORMAL;
> p->prio = p->normal_prio = p->static_prio = DEFAULT_PRIO;
> }

This would do something very different. i.e. with this suggested code
of yours SCHED_IDLE/SCHED_BATCH would be upgraded to SCHED_OTHER on
fork and a process with a positive nice level would be upgraded to to
nice level 0. My original patch would only downgrade, never upgrade.

It is of course a question what makes more sense here: a logic that
makes sure that only "elevated" scheduling gets reset to normal
scheduling, or one that would reset both 'higher' and 'lower'
scheduling settings to normal.

Given that this is supposed to be a security feature it makes more
sense to me to only 'decrease' scheduling settings, not 'increase'
them. Dunno, what do you think?

Lennart

--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4


\
 
 \ /
  Last update: 2009-05-29 12:43    [W:0.213 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site