public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Xunlei Pang <xlpang@126.com>,
	linux-kernel@vger.kernel.org, Juri Lelli <juri.lelli@gmail.com>,
	Xunlei Pang <pang.xunlei@linaro.org>
Subject: Re: [PATCH v6 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases
Date: Mon, 20 Apr 2015 19:20:48 +0200	[thread overview]
Message-ID: <20150420172048.GZ27490@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20150420105228.461e103c@gandalf.local.home>

On Mon, Apr 20, 2015 at 10:52:28AM -0400, Steven Rostedt wrote:
> On Mon, 20 Apr 2015 16:22:47 +0800
> Xunlei Pang <xlpang@126.com> wrote:
> 
> >  static inline void enqueue_pushable_task(struct rq *rq, struct task_struct *p)
> >  {
> >  }
> > @@ -1506,8 +1526,21 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p)
> >  	 * The previous task needs to be made eligible for pushing
> >  	 * if it is still active
> >  	 */
> > -	if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1)
> > -		enqueue_pushable_task(rq, p);
> > +	if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1) {
> > +		/*
> > +		 * put_prev_task_rt() is called by many functions,
> > +		 * pick_next_task_rt() is the only one may have
> > +		 * PREEMPT_ACTIVE set. So if detecting p(current
> > +		 * task) is preempted in such case, we should
> > +		 * enqueue it to the front of the pushable plist,
> > +		 * as there may be multiple tasks with the same
> > +		 * priority as p.
> 
> The above comment is very difficult to understand. Maybe something like:
> 
> 		/*
> 		 * When put_prev_task_rt() is called by
> 		 * pick_next_task_rt(), if PREEMPT_ACTIVE is set, it
> 		 * means that the current rt task is being preempted by
> 		 * a higher priority task. To maintain FIFO, it must
> 		 * stay ahead of any other task that is queued at the
> 		 * same priority.
> 		 */
> 
> -- Steve
> 
> > +		 */
> > +		if (preempt_count() & PREEMPT_ACTIVE)
> > +			enqueue_pushable_task_preempted(rq, p);
> > +		else
> > +			enqueue_pushable_task(rq, p);
> > +	}
> >  }

This looks wrong, what do you want to find? _any_ preemption? In that
case PREEMPT_ACTIVE is wrong. What you need to check is if the task is
still on the RQ or not.

If the task was put to sleep it got dequeued, if it was not dequeued, it
got preempted.

PREEMPT_ACTIVE is only ever set for forced kernel preemption, which is a
special sub case only ever triggered with CONFIG_PREEMPT=y.

  reply	other threads:[~2015-04-20 17:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20  8:22 [PATCH v6 1/3] lib/plist: Provide plist_add_head() for nodes with the same prio Xunlei Pang
2015-04-20  8:22 ` [PATCH v6 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases Xunlei Pang
2015-04-20 14:52   ` Steven Rostedt
2015-04-20 17:20     ` Peter Zijlstra [this message]
2015-04-20 17:48       ` Steven Rostedt
2015-04-20 23:45         ` Peter Zijlstra
2015-04-21 13:10           ` Steven Rostedt
     [not found]         ` <OFB1503F16.1E65406F-ON48257E2E.002B562D-48257E30.0008BFEB@zte.com.cn>
2015-04-23  3:01           ` Steven Rostedt
     [not found]             ` <OFE3B71874.C9D81693-ON48257E30.0024F69F-48257E30.0025E2D3@zte.com.cn>
2015-04-23 13:10               ` Steven Rostedt
2015-04-24 18:32               ` Peter Zijlstra
     [not found]                 ` <OF0B05B4FE.F40C0BE3-ON48257E32.004EF485-48257E32.00513DB3@zte.com.cn>
2015-04-25 18:23                   ` Peter Zijlstra
     [not found]                     ` <OFD410EB1E.5A02675A-ON48257E33.00309252-48257E33.003641FF@zte.com.cn>
2015-04-26 15:58                       ` Steven Rostedt
2015-04-28 10:19                         ` Peter Zijlstra
2015-04-28 12:48                           ` Mike Galbraith
2015-04-20  8:22 ` [PATCH v6 3/3] sched/rt: Check to push the task when changing its affinity Xunlei Pang
2015-04-20 16:06   ` Steven Rostedt
2015-04-20 14:42 ` [PATCH v6 1/3] lib/plist: Provide plist_add_head() for nodes with the same prio Steven Rostedt
2015-04-20 14:48 ` 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=20150420172048.GZ27490@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pang.xunlei@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=xlpang@126.com \
    /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