public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: qianjun.kernel@gmail.com
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com
Cc: linux-kernel@vger.kernel.org, jun qian <qianjun.kernel@gmail.com>
Subject: [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick
Date: Wed, 14 Apr 2021 10:22:29 +0800	[thread overview]
Message-ID: <20210414022229.5469-1-qianjun.kernel@gmail.com> (raw)

From: jun qian <qianjun.kernel@gmail.com>

As you are already set the TIF_NEED_RESCHED, there is no need
to check resched again.

Signed-off-by: jun qian <qianjun.kernel@gmail.com>
---
 kernel/sched/fair.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 794c2cb945f8..1a69b5fffe4a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4360,19 +4360,26 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 {
 	unsigned long ideal_runtime, delta_exec;
 	struct sched_entity *se;
+	struct rq *rq = rq_of(cfs_rq);
 	s64 delta;
 
 	ideal_runtime = sched_slice(cfs_rq, curr);
 	delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
 	if (delta_exec > ideal_runtime) {
-		resched_curr(rq_of(cfs_rq));
+		if (!test_tsk_need_resched(rq->curr))
+			resched_curr(rq_of(cfs_rq));
 		/*
 		 * The current task ran long enough, ensure it doesn't get
 		 * re-elected due to buddy favours.
 		 */
 		clear_buddies(cfs_rq, curr);
 		return;
-	}
+	/*
+	 * If here with TIF_NEED_RESCHED already set from the early entity_tick,
+	 * there is no need to check again.
+	 */
+	} else if (test_tsk_need_resched(rq->curr))
+		return;
 
 	/*
 	 * Ensure that a task that missed wakeup preemption by a
-- 
2.18.2


             reply	other threads:[~2021-04-14  2:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14  2:22 qianjun.kernel [this message]
2021-04-14  7:12 ` [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick Peter Zijlstra

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=20210414022229.5469-1-qianjun.kernel@gmail.com \
    --to=qianjun.kernel@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.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