mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xunlei Pang <xlpang@126.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Juri Lelli <juri.lelli@gmail.com>, Ingo Molnar <mingo@redhat.com>,
	Xunlei Pang <pang.xunlei@linaro.org>
Subject: [PATCH v3 3/4] sched/rt: Remove redundant conditions from task_woken_rt()
Date: Tue, 12 May 2015 22:46:43 +0800	[thread overview]
Message-ID: <1431442004-18716-3-git-send-email-xlpang@126.com> (raw)
In-Reply-To: <1431442004-18716-1-git-send-email-xlpang@126.com>

From: Xunlei Pang <pang.xunlei@linaro.org>

- Remove "has_pushable_tasks(rq)".
  Because for queued p, "!task_running(rq, p)" and "p->nr_cpus_allowed > 1"
  already imply that "has_pushable_tasks(rq)" is true.

- Remove "!test_tsk_need_resched(rq->curr)".
  The condtion mainly intends to ensure higher priority rt tasks won't be pushed
  away. I can think of two reasons below for getting rid of it.
  1) With following "rq->curr->prio <= p->prio", we still can guarantee that
     purpose. "rq->curr->prio <= p->prio" implies the "need resched flag" wasn't
     set by check_preempt_curr() except the one set by check_preempt_equal_prio()
     for equal prio cases(In this case, if the condition is removed, it may result
     in an extra push_rt_tasks(), but this doesn't cause the wrong logic, in fact
     this extra push_rt_tasks() will probably return quickly for the case).

     Addtionally, there're also cases the "need resched flag" got set before the
     waking, with current implementation it needn't to push lower priority tasks
     as the cpu will schedule, while it will do an extra pushing if the condition
     is removed. But on the other hand, we can get a timely pushing for the woken
     tasks after the condition is removed(better for the non-preemptible kernel).

  2) With following condtion "rq->curr->nr_cpus_allowed < 2" which was added by
     commit b3bc211cfe7d ("sched: Give CPU bound RT tasks preference"), in the
     scenario descibed in it, "need resched flag" was already set before by
     check_preempt_curr(), thus "!test_tsk_need_resched(rq->curr)" is always false
     which means with current implementation the commit is futile for task_woken_rt().
  So, by removing this condition, we get the right logic.

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 kernel/sched/rt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 4a49c6a..4bd8551 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2232,8 +2232,6 @@ out:
 static void task_woken_rt(struct rq *rq, struct task_struct *p)
 {
 	if (!task_running(rq, p) &&
-	    !test_tsk_need_resched(rq->curr) &&
-	    has_pushable_tasks(rq) &&
 	    p->nr_cpus_allowed > 1 &&
 	    (dl_task(rq->curr) || rt_task(rq->curr)) &&
 	    (rq->curr->nr_cpus_allowed < 2 ||
-- 
1.9.1



  parent reply	other threads:[~2015-05-12 14:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:46 [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed Xunlei Pang
2015-05-12 14:46 ` [PATCH v3 2/4] sched/deadline: " Xunlei Pang
2015-05-12 14:46 ` Xunlei Pang [this message]
2015-05-12 14:46 ` [PATCH v3 4/4] sched/deadline: Remove redundant conditions from task_woken_dl() Xunlei Pang
2015-05-29 13:16 ` [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed Peter Zijlstra
     [not found]   ` <OF8BB81194.1A32A464-ON48257E54.004C068A-48257E54.004D51E2@zte.com.cn>
2015-05-30  8:20     ` Peter Zijlstra
2015-05-30 10:54       ` Peter Zijlstra
2015-05-30 16:30         ` 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=1431442004-18716-3-git-send-email-xlpang@126.com \
    --to=xlpang@126.com \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pang.xunlei@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /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