mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juri Lelli <juri.lelli@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH linux-next] sched: Fix broken setscheduler()
Date: Thu, 6 Mar 2014 13:20:40 +0100	[thread overview]
Message-ID: <20140306132040.781dbf18c9385a6112fbab2b@gmail.com> (raw)
In-Reply-To: <20140306115825.GS27965@twins.programming.kicks-ass.net>

On Thu, 6 Mar 2014 12:58:25 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> On Wed, Mar 05, 2014 at 11:29:31PM -0500, Steven Rostedt wrote:
> > I decided to run my tests on linux-next, and my wakeup_rt tracer was
> > broken. After running a bisect, I found that the problem commit was:
> > 
> >    linux-next commit c365c292d059
> >    "sched: Consider pi boosting in setscheduler()"
> > 
> > And the reason the wake_rt tracer test was failing, was because it had
> > no RT task to trace. I first noticed this when running with
> > sched_switch event and saw that my RT task still had normal SCHED_OTHER
> > priority. Looking at the problem commit, I found:
> > 
> >  -       p->normal_prio = normal_prio(p);
> >  -       p->prio = rt_mutex_getprio(p);
> > 
> > With no
> > 
> >  +       p->normal_prio = normal_prio(p);
> >  +       p->prio = rt_mutex_getprio(p);
> > 
> > Reading what the commit is suppose to do, I realize that the p->prio
> > can't be set if the task is boosted with a higher prio, but the
> > p->normal_prio still needs to be set regardless, otherwise, when the
> > task is deboosted, it wont get the new priority.
> > 
> > The p->prio has to be set before "check_class_changed()" is called,
> > otherwise the class wont be changed.
> 
> So Juri had a different patch for this problem:
> 
>   http://lkml.kernel.org/r/20140301191838.d15d03112b2598a671dac22c@gmail.com
> 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > ---
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 4600bca..b1cc871 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -3198,6 +3198,7 @@ static void __setscheduler_params(struct task_struct *p,
> >  	 * getparam()/getattr() don't report silly values for !rt tasks.
> >  	 */
> >  	p->rt_priority = attr->sched_priority;
> > +	p->normal_prio = normal_prio(p);
> >  	set_load_weight(p);
> >  }
> 
> Now; if I'm reading things right, normal_prio is the unboosted priority
> of a task. And we should indeed keep setting that, otherwise the unboost
> doesn't know where it should go.
> 
> Juri put that in __setscheduler(), but I think that's wrong because the
> rt_mutex_check_prio() case in __sched_setscheduler() still needs to
> update this.
> 

Oh, right. Missed that.

> > @@ -3207,6 +3208,8 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
> >  {
> >  	__setscheduler_params(p, attr);
> >  
> > +	p->prio = rt_mutex_getprio(p);
> > +
> >  	if (dl_prio(p->prio))
> >  		p->sched_class = &dl_sched_class;
> >  	else if (rt_prio(p->prio))
> > 
> 
> And when we call this we're sure to not be boosted; so this is
> effectively the same as Juri has:
> 
>   p->prio = p->normal_prio = normal_prio(p)
> 
> Seeing how rt_mutex_getprio() and normal_prio() are the same under these
> conditions.
> 
> 

Yes. I think you can go with

 p->prio = p->normal_prio

and save a few checks in rt_mutex_getprio().

Thanks,

- Juri

  reply	other threads:[~2014-03-06 12:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06  4:29 Steven Rostedt
2014-03-06 11:58 ` Peter Zijlstra
2014-03-06 12:20   ` Juri Lelli [this message]
2014-03-06 17:04     ` [PATCH v2] " Steven Rostedt
2014-03-06 20:43       ` Thomas Gleixner
2014-03-10 17:29         ` Steven Rostedt
2014-03-10 21:18           ` Thomas Gleixner
2014-03-10 21:37             ` Steven Rostedt
2014-03-11  9:35               ` Juri Lelli
2014-03-11 10:48                 ` Thomas Gleixner
2014-03-11 23:24                   ` [PATCH v3] " Steven Rostedt
2014-03-12 10:41                     ` Thomas Gleixner
2014-03-12 10:10       ` [tip:sched/core] " tip-bot for Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140306132040.781dbf18c9385a6112fbab2b@gmail.com \
    --to=juri.lelli@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome