mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: peterz@infradead.org
Cc: lcapitulino@redhat.com, linux-kernel@vger.kernel.org,
	mtosatti@redhat.com, mingo@kernel.org, fweisbec@redhat.com
Subject: [PATCH] sched,rt,nohz: stop scheduler tick if running realtime task
Date: Mon, 16 Feb 2015 15:23:49 -0500	[thread overview]
Message-ID: <20150216152349.6a8ed824@annuminas.surriel.com> (raw)

If the CPU is running a realtime task that does not round-robin with
another realtime task of equal priority, there is no point in keeping
the scheduler tick going. After all, whenever the scheduler tick runs,
the kernel will just decide not to reschedule.

Extend sched_can_stop_tick to recognize these situations, and inform
the rest of the kernel that the scheduler tick can be stopped.

Signed-off-by: Rik van Riel <riel@redhat.com>
Tested-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 kernel/sched/core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ade2958a9197..ad985a632c4d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -745,6 +745,22 @@ static inline bool got_nohz_idle_kick(void)
 bool sched_can_stop_tick(void)
 {
 	/*
+	 * FIFO realtime policy runs the highest priority task. Other runnable
+	 * tasks are of a lower priority. The scheduler tick does nothing.
+	 */
+	if (current->policy == SCHED_FIFO)
+		return true;
+
+	/*
+	 * Round-robin realtime tasks time slice with other tasks at the same
+	 * realtime priority. Is this task the only one at this priority?
+	 */
+	if (current->policy == SCHED_RR) {
+		struct sched_rt_entity *rt_se = &current->rt;
+		return rt_se->run_list.prev == rt_se->run_list.next;
+	}
+
+	/*
 	 * More than one running task need preemption.
 	 * nr_running update is assumed to be visible
 	 * after IPI is sent from wakers.

             reply	other threads:[~2015-02-16 20:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 20:23 Rik van Riel [this message]
2015-02-18 18:43 ` [tip:sched/core] sched/rt/nohz: Stop " tip-bot for Rik van Riel
2015-03-03 17:12 ` [PATCH] sched,rt,nohz: stop " Frederic Weisbecker

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=20150216152349.6a8ed824@annuminas.surriel.com \
    --to=riel@redhat.com \
    --cc=fweisbec@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®