summaryrefslogtreecommitdiffstats
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2012-12-18 17:32:19 +0100
committerFrederic Weisbecker <fweisbec@gmail.com>2013-03-21 15:38:33 +0100
commita831881be220358a1d28c5d95d69449fb6d623ca (patch)
tree769ab069e2837a9bd3613046110468cd87c8c3fa /kernel/time/tick-sched.c
parenta8d7ad52a7befbde896276d05c75c90fed48b5bf (diff)
downloadblackbird-op-linux-a831881be220358a1d28c5d95d69449fb6d623ca.tar.gz
blackbird-op-linux-a831881be220358a1d28c5d95d69449fb6d623ca.zip
nohz: Basic full dynticks interface
For extreme usecases such as Real Time or HPC, having the ability to shutdown the tick when a single task runs on a CPU is a desired feature: * Reducing the amount of interrupts improves throughput for CPU-bound tasks. The CPU is less distracted from its real job, from an execution time and from the cache point of views. * This also improve latency response as we have less critical sections. Start with introducing a very simple interface to define full dynticks CPU: use a boot time option defined cpumask through the "nohz_extended=" kernel parameter. CPUs that are part of this range will have their tick shutdown whenever possible: provided they run a single task and they don't do kernel activity that require the periodic tick. These details will be later documented in Documentation/* An online CPU must be kept outside this range to handle the timekeeping. Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: Christoph Lameter <cl@linux.com> Cc: Geoff Levand <geoff@infradead.org> Cc: Gilad Ben Yossef <gilad@benyossef.com> Cc: Hakan Akkan <hakanakkan@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Kevin Hilman <khilman@linaro.org> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index a19a39952c1b..79c275f08b7d 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -142,6 +142,68 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
profile_tick(CPU_PROFILING);
}
+#ifdef CONFIG_NO_HZ_EXTENDED
+static cpumask_var_t nohz_extended_mask;
+bool have_nohz_extended_mask;
+
+int tick_nohz_extended_cpu(int cpu)
+{
+ if (!have_nohz_extended_mask)
+ return 0;
+
+ return cpumask_test_cpu(cpu, nohz_extended_mask);
+}
+
+/* Parse the boot-time nohz CPU list from the kernel parameters. */
+static int __init tick_nohz_extended_setup(char *str)
+{
+ alloc_bootmem_cpumask_var(&nohz_extended_mask);
+ if (cpulist_parse(str, nohz_extended_mask) < 0)
+ pr_warning("NOHZ: Incorrect nohz_extended cpumask\n");
+ else
+ have_nohz_extended_mask = true;
+ return 1;
+}
+__setup("nohz_extended=", tick_nohz_extended_setup);
+
+static int __init init_tick_nohz_extended(void)
+{
+ cpumask_var_t online_nohz;
+ int cpu;
+
+ if (!have_nohz_extended_mask)
+ return 0;
+
+ if (!zalloc_cpumask_var(&online_nohz, GFP_KERNEL)) {
+ pr_warning("NO_HZ: Not enough memory to check extended nohz mask\n");
+ return -ENOMEM;
+ }
+
+ /*
+ * CPUs can probably not be concurrently offlined on initcall time.
+ * But we are paranoid, aren't we?
+ */
+ get_online_cpus();
+
+ /* Ensure we keep a CPU outside the dynticks range for timekeeping */
+ cpumask_and(online_nohz, cpu_online_mask, nohz_extended_mask);
+ if (cpumask_equal(online_nohz, cpu_online_mask)) {
+ cpu = cpumask_any(cpu_online_mask);
+ pr_warning("NO_HZ: Must keep at least one online CPU "
+ "out of nohz_extended range\n");
+ pr_warning("NO_HZ: Clearing %d from nohz_extended range\n", cpu);
+ cpumask_clear_cpu(cpu, nohz_extended_mask);
+ }
+ put_online_cpus();
+ free_cpumask_var(online_nohz);
+
+ return 0;
+}
+core_initcall(init_tick_nohz_extended);
+#else
+#define have_nohz_extended_mask (0)
+#endif
+
/*
* NOHZ - aka dynamic tick functionality
*/
OpenPOWER on IntegriCloud