linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	John Kacur <jkacur@redhat.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Mike Galbraith <umgwanakikbuti@gmail.com>,
	Muli Baron <muli.baron@gmail.com>
Subject: [PATCH RT] rt, nohz_full: fix nohz_full for PREEMPT_RT_FULL
Date: Tue, 19 May 2015 22:56:45 -0400	[thread overview]
Message-ID: <20150519225645.4aec4961@grimm.local.home> (raw)
In-Reply-To: <20150514135936.609231479@goodmis.org>

I'm adding this patch to the next 3.14-rt release.

-- Steve


>From b59089f83e5bea79c86bf0726c98529c2afb09cc Mon Sep 17 00:00:00 2001
From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Sat, 11 Apr 2015 15:15:59 +0200
Subject: [PATCH] rt, nohz_full: fix nohz_full for PREEMPT_RT_FULL

A task being ticked and trying to shut the tick down will fail due
to having just awakened ksoftirqd, subtract it from nr_running.

Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/sched/core.c      | 29 +++++++++++++++++++++++------
 kernel/time/tick-sched.c |  5 +++++
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 883669d3e293..71c0bb1cdeb0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -696,17 +696,34 @@ static inline bool got_nohz_idle_kick(void)
 #endif /* CONFIG_NO_HZ_COMMON */
 
 #ifdef CONFIG_NO_HZ_FULL
+
+static int ksoftirqd_running(void)
+{
+	struct task_struct *softirqd;
+
+	if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
+		return 0;
+	softirqd = this_cpu_ksoftirqd();
+	if (softirqd && softirqd->on_rq)
+		return 1;
+	return 0;
+}
+
 bool sched_can_stop_tick(void)
 {
-       struct rq *rq;
+	struct rq *rq;
 
-       rq = this_rq();
+	rq = this_rq();
 
-       /* Make sure rq->nr_running update is visible after the IPI */
-       smp_rmb();
+	/* Make sure rq->nr_running update is visible after the IPI */
+	smp_rmb();
 
-       /* More than one running task need preemption */
-       if (rq->nr_running > 1)
+	/*
+	 * More than one running task need preemption
+	 *
+	 * NOTE, RT: if ksoftirqd is awake, subtract it.
+	 */
+	if (rq->nr_running - ksoftirqd_running() > 1)
                return false;
 
        return true;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6c97081f67f9..57d5bb1b3919 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -226,7 +226,12 @@ void __tick_nohz_full_check(void)
 
 static void nohz_full_kick_work_func(struct irq_work *work)
 {
+	unsigned long flags;
+
+	/* ksoftirqd processes sirqs with interrupts enabled */
+	local_irq_save(flags);
 	__tick_nohz_full_check();
+	local_irq_restore(flags);
 }
 
 static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) = {
-- 
2.1.4

  parent reply	other threads:[~2015-05-20  2:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 13:59 [PATCH RT 0/5] Linux 3.14.39-rt38-rc1 Steven Rostedt
2015-05-14 13:59 ` [PATCH RT 1/5] kernel/irq_work: fix no_hz deadlock Steven Rostedt
2015-05-14 13:59 ` [PATCH RT 2/5] KVM: lapic: mark LAPIC timer handler as irqsafe Steven Rostedt
2015-05-14 13:59 ` [PATCH RT 3/5] KVM: use simple waitqueue for vcpu->wq Steven Rostedt
2015-05-14 13:59 ` [PATCH RT 4/5] hotplug: Use set_cpus_allowed_ptr() in sync_unplug_thread() Steven Rostedt
2015-05-14 13:59 ` [PATCH RT 5/5] Linux 3.14.39-rt38-rc1 Steven Rostedt
2015-05-19 15:46 ` [PATCH RT 0/5] " Muli Baron
2015-05-20  2:51   ` Steven Rostedt
2015-05-20  2:56 ` Steven Rostedt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-05-14 14:01 [PATCH RT 0/5] Linux 3.12.40-rt56-rc1 Steven Rostedt
2015-05-20  2:59 ` [PATCH RT] rt, nohz_full: fix nohz_full for PREEMPT_RT_FULL Steven Rostedt
2015-05-14 14:02 [PATCH RT 0/5] Linux 3.10.75-rt81-rc1 Steven Rostedt
2015-05-20  3:01 ` [PATCH RT] rt, nohz_full: fix nohz_full for PREEMPT_RT_FULL 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=20150519225645.4aec4961@grimm.local.home \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=muli.baron@gmail.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=tglx@linutronix.de \
    --cc=umgwanakikbuti@gmail.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;
as well as URLs for NNTP newsgroup(s).