public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Chris Metcalf <cmetcalf@mellanox.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Christoph Lameter <cl@linux.com>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>, Mike Galbraith <efault@gmx.de>,
	Rik van Riel <riel@redhat.com>, Wanpeng Li <kernellwp@gmail.com>
Subject: [RFC PATCH 11/12] housekeeping: Handle nohz_full= parameter
Date: Wed, 23 Aug 2017 03:51:10 +0200	[thread overview]
Message-ID: <1503453071-952-12-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1503453071-952-1-git-send-email-fweisbec@gmail.com>

We want to centralize the isolation management from the housekeeping
subsystem. Therefore we need to handle the nohz_full= parameter from
there.

Since nohz_full= so far has involved unbound timers, watchdog, RCU
and tilegx NAPI isolation, we keep that default behaviour.

nohz_full= is deemed to be deprecated in the future. We want to control
the isolation features from the isolcpus= parameter.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Wanpeng Li <kernellwp@gmail.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
---
 include/linux/housekeeping.h |  1 +
 include/linux/tick.h         |  1 +
 kernel/housekeeping.c        | 42 +++++++++++++++++++++++++++++-------------
 kernel/time/tick-sched.c     | 13 +++----------
 4 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/include/linux/housekeeping.h b/include/linux/housekeeping.h
index 2a9b808..b53a2b2 100644
--- a/include/linux/housekeeping.h
+++ b/include/linux/housekeeping.h
@@ -12,6 +12,7 @@ enum hk_flags {
 	HK_FLAG_SCHED		= (1 << 3),
 	HK_FLAG_WORKQUEUE	= (1 << 4),
 	HK_FLAG_KTHREAD		= (1 << 5),
+	HK_FLAG_TICK		= (1 << 6),
 };
 
 #ifdef CONFIG_CPU_ISOLATION
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 68afc09..3c82cf5 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -228,6 +228,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal,
 
 extern void tick_nohz_full_kick_cpu(int cpu);
 extern void __tick_nohz_task_switch(void);
+extern void __init tick_nohz_full_setup(cpumask_var_t cpumask);
 #else
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
diff --git a/kernel/housekeeping.c b/kernel/housekeeping.c
index e2196d1..633a0d9 100644
--- a/kernel/housekeeping.c
+++ b/kernel/housekeeping.c
@@ -49,23 +49,39 @@ bool housekeeping_test_cpu(int cpu, enum hk_flags flags)
 
 void __init housekeeping_init(void)
 {
-	if (!tick_nohz_full_enabled())
+	if (!housekeeping_flags)
 		return;
 
-	if (!alloc_cpumask_var(&housekeeping_mask, GFP_KERNEL)) {
-		WARN(1, "NO_HZ: Can't allocate not-full dynticks cpumask\n");
-		cpumask_clear(tick_nohz_full_mask);
-		tick_nohz_full_running = false;
-		return;
-	}
-
-	cpumask_andnot(housekeeping_mask,
-		       cpu_possible_mask, tick_nohz_full_mask);
-
-	housekeeping_flags = HK_FLAG_TIMER | HK_FLAG_RCU | HK_FLAG_MISC;
-
 	static_branch_enable(&housekeeping_overriden);
 
 	/* We need at least one CPU to handle housekeeping work */
 	WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
 }
+
+static int __init housekeeping_nohz_full_setup(char *str)
+{
+	cpumask_var_t non_housekeeping_mask;
+
+	alloc_bootmem_cpumask_var(&non_housekeeping_mask);
+	if (cpulist_parse(str, non_housekeeping_mask) < 0) {
+		pr_warn("Housekeeping: Incorrect nohz_full cpumask\n");
+		free_bootmem_cpumask_var(non_housekeeping_mask);
+		return 0;
+	}
+
+	alloc_bootmem_cpumask_var(&housekeeping_mask);
+	cpumask_andnot(housekeeping_mask, cpu_possible_mask, non_housekeeping_mask);
+
+	if (cpumask_empty(housekeeping_mask))
+		cpumask_set_cpu(smp_processor_id(), housekeeping_mask);
+
+	housekeeping_flags = HK_FLAG_TICK | HK_FLAG_TIMER |
+				HK_FLAG_RCU | HK_FLAG_MISC;
+
+	tick_nohz_full_setup(non_housekeeping_mask);
+
+	free_bootmem_cpumask_var(non_housekeeping_mask);
+
+	return 1;
+}
+__setup("nohz_full=", housekeeping_nohz_full_setup);
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 9d29dee..f09dd43 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -384,20 +384,13 @@ void __tick_nohz_task_switch(void)
 	local_irq_restore(flags);
 }
 
-/* Parse the boot-time nohz CPU list from the kernel parameters. */
-static int __init tick_nohz_full_setup(char *str)
+/* Get the boot-time nohz CPU list from the kernel parameters. */
+void __init tick_nohz_full_setup(cpumask_var_t cpumask)
 {
 	alloc_bootmem_cpumask_var(&tick_nohz_full_mask);
-	if (cpulist_parse(str, tick_nohz_full_mask) < 0) {
-		pr_warn("NO_HZ: Incorrect nohz_full cpumask\n");
-		free_bootmem_cpumask_var(tick_nohz_full_mask);
-		return 1;
-	}
+	cpumask_copy(tick_nohz_full_mask, cpumask);
 	tick_nohz_full_running = true;
-
-	return 1;
 }
-__setup("nohz_full=", tick_nohz_full_setup);
 
 static int tick_nohz_cpu_down(unsigned int cpu)
 {
-- 
2.7.4

  parent reply	other threads:[~2017-08-23  1:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23  1:50 [RFC 00/12] Introduce housekeeping subsystem v2 Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 01/12] housekeeping: Move housekeeping related code to its own file Frederic Weisbecker
2017-08-31 20:16   ` Rik van Riel
2017-08-31 22:58     ` Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 02/12] watchdog: Use housekeeping_cpumask() instead of ad-hoc version Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 03/12] housekeeping: Provide a dynamic off-case to housekeeping_any_cpu() Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 04/12] housekeeping: Make housekeeping cpumask private Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 05/12] housekeeping: Use its own static key Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 06/12] housekeeping: Rename is_housekeeping_cpu to housekeeping_cpu Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 07/12] housekeeping: Move it under own config, independant from NO_HZ Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 08/12] housekeeping: Introduce housekeeping flags Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 09/12] workqueue: Affine unbound workqueues to housekeeping cpumask Frederic Weisbecker
2017-08-23  1:51 ` [RFC PATCH 10/12] housekeeping: Affine unbound kthreads Frederic Weisbecker
2017-08-23  1:51 ` Frederic Weisbecker [this message]
2017-08-23  1:51 ` [RFC PATCH 12/12] housekeeping: Reimplement isolcpus on housekeeping Frederic Weisbecker
2017-08-23 14:55   ` Christopher Lameter
2017-08-24 13:19     ` Frederic Weisbecker
2017-08-28 10:10     ` Peter Zijlstra
2017-08-28 15:38       ` Christopher Lameter
2017-08-28 10:09   ` Peter Zijlstra
2017-08-28 13:23     ` Frederic Weisbecker
2017-08-28 13:31       ` Peter Zijlstra
2017-08-28 15:27         ` Frederic Weisbecker
2017-08-28 16:24           ` Peter Zijlstra
2017-08-28 16:53             ` Christopher Lameter
2017-08-28 17:33             ` Frederic Weisbecker
2017-08-31 18:53               ` Thomas Gleixner
2017-08-31 23:00                 ` 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=1503453071-952-12-git-send-email-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=cl@linux.com \
    --cc=cmetcalf@mellanox.com \
    --cc=efault@gmx.de \
    --cc=kernellwp@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    /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