From: Steven Rostedt <rostedt@goodmis.org>
To: Xunlei Pang <xlpang@126.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@gmail.com>,
Dan Streetman <ddstreet@ieee.org>,
Xunlei Pang <pang.xunlei@linaro.org>
Subject: Re: [PATCH v5 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases
Date: Thu, 9 Apr 2015 09:56:38 -0400 [thread overview]
Message-ID: <20150409095638.4fe20620@gandalf.local.home> (raw)
In-Reply-To: <1428550038-13619-2-git-send-email-xlpang@126.com>
On Thu, 9 Apr 2015 11:27:17 +0800
Xunlei Pang <xlpang@126.com> wrote:
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> ---
> kernel/sched/rt.c | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 575da76..402162a 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -359,11 +359,15 @@ static inline void set_post_schedule(struct rq *rq)
> rq->post_schedule = has_pushable_tasks(rq);
> }
>
> -static void enqueue_pushable_task(struct rq *rq, struct task_struct *p)
> +static void
> +enqueue_pushable_task(struct rq *rq, struct task_struct *p, bool head)
> {
> plist_del(&p->pushable_tasks, &rq->rt.pushable_tasks);
> plist_node_init(&p->pushable_tasks, p->prio);
> - plist_add(&p->pushable_tasks, &rq->rt.pushable_tasks);
> + if (head)
> + plist_add_head(&p->pushable_tasks, &rq->rt.pushable_tasks);
> + else
> + plist_add_tail(&p->pushable_tasks, &rq->rt.pushable_tasks);
>
> /* Update the highest prio pushable task */
> if (p->prio < rq->rt.highest_prio.next)
> @@ -385,7 +389,8 @@ static void dequeue_pushable_task(struct rq *rq, struct task_struct *p)
>
> #else
>
> -static inline void enqueue_pushable_task(struct rq *rq, struct task_struct *p)
> +static inline
> +void enqueue_pushable_task(struct rq *rq, struct task_struct *p, bool head)
> {
> }
>
> @@ -1260,7 +1265,7 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags)
> enqueue_rt_entity(rt_se, flags & ENQUEUE_HEAD);
>
> if (!task_current(rq, p) && p->nr_cpus_allowed > 1)
> - enqueue_pushable_task(rq, p);
> + enqueue_pushable_task(rq, p, false);
Hmm, I really don't like the "false" parameter all over the place, since
it's only needed in one place. Thinking about this more, what about
keeping enqueue_pushable_task() as is, and adding an
enqueue_pushable_task_preempted(). Having something like this:
static inline void
enqueue_pushable_task(struct rq *rq, struct task_struct *p)
{
enqueue_pushable_task_preempted(rq, p, false);
}
> }
>
> static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags)
> @@ -1507,7 +1512,16 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p)
> * if it is still active
> */
> if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1)
> - enqueue_pushable_task(rq, p);
> + /*
> + * 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.
> + */
> + enqueue_pushable_task(rq, p, !!(preempt_count() & PREEMPT_ACTIVE));
Then we don't need to touch any of the code but this place, and this
would be:
enqueue_pushable_task_preempted(rq, p,
!!(preempt_count() & PREEMPT_ACTIVE));
I'm thinking this would be much more descriptive.
What do you think?
-- Steve
> }
>
> #ifdef CONFIG_SMP
> @@ -2091,7 +2105,7 @@ static void set_cpus_allowed_rt(struct task_struct *p,
> rq->rt.rt_nr_migratory--;
> } else {
> if (!task_current(rq, p))
> - enqueue_pushable_task(rq, p);
> + enqueue_pushable_task(rq, p, false);
> rq->rt.rt_nr_migratory++;
> }
>
next prev parent reply other threads:[~2015-04-09 13:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-09 3:27 [PATCH v5 1/3] lib/plist: Provide plist_add_head() for nodes with the same prio Xunlei Pang
2015-04-09 3:27 ` [PATCH v5 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases Xunlei Pang
2015-04-09 13:56 ` Steven Rostedt [this message]
2015-04-09 3:27 ` [PATCH v5 3/3] sched/rt: Check to push the task when changing its affinity Xunlei Pang
2015-04-09 13:43 ` [PATCH v5 1/3] lib/plist: Provide plist_add_head() for nodes with the same prio 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=20150409095638.4fe20620@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=ddstreet@ieee.org \
--cc=juri.lelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pang.xunlei@linaro.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®