Re: [tip:core/futexes] futex: use current->time_slack_ns for rt tasks too

Peter Zijlstra
2009-03-12T14:49:30Z

> > ---
> >
> > Subject: sched: adjust timer_slack_ns on scheduler policy change
> > From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Date: Thu Mar 12 15:01:02 CET 2009
> >
> > Ensure RT tasks have 0 timer slack.
> >
> > Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > ---
> > kernel/sched.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > Index: linux-2.6/kernel/sched.c
> > ===================================================================
> > --- linux-2.6.orig/kernel/sched.c
> > +++ linux-2.6/kernel/sched.c
> > @@ -5511,10 +5511,12 @@ __setscheduler(struct rq *rq, struct tas
> > case SCHED_NORMAL:
> > case SCHED_BATCH:
> > case SCHED_IDLE:
> > + p->timer_slack_ns = p->default_timer_slack_ns;
> > p->sched_class = &fair_sched_class;
> > break;
> > case SCHED_FIFO:
> > case SCHED_RR:
> > + p->timer_slack_ns = 0;
> > p->sched_class = &rt_sched_class;
> > break;
> > }
> >

Looking at the default_timer_slack_ns stuff, do we want something like
the below?

---
diff --git a/kernel/sys.c b/kernel/sys.c
index 7306f94..6d8a84d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1811,11 +1811,13 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned
long, arg2, unsigned long, arg3,
error = current->timer_slack_ns;
break;
case PR_SET_TIMERSLACK:
- if (arg2 <= 0)
+ if (arg2 <= 0) {
current->timer_slack_ns =
current->default_timer_slack_ns;
- else
- current->timer_slack_ns = arg2;
+ } else {
+ current->default_timer_slack_ns =
+ current->timer_slack_ns = arg2;
+ }
error = 0;
break;