diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-12-18 11:32:19 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2013-03-21 10:38:33 -0400 |
commit | a831881be220358a1d28c5d95d69449fb6d623ca (patch) | |
tree | 769ab069e2837a9bd3613046110468cd87c8c3fa /kernel/time | |
parent | a8d7ad52a7befbde896276d05c75c90fed48b5bf (diff) |
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')
-rw-r--r-- | kernel/time/Kconfig | 19 | ||||
-rw-r--r-- | kernel/time/tick-sched.c | 62 |
2 files changed, 81 insertions, 0 deletions
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 24510d84efd7..5a87c03e45ad 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig | |||
@@ -79,6 +79,25 @@ config NO_HZ | |||
79 | only trigger on an as-needed basis both when the system is | 79 | only trigger on an as-needed basis both when the system is |
80 | busy and when the system is idle. | 80 | busy and when the system is idle. |
81 | 81 | ||
82 | config NO_HZ_EXTENDED | ||
83 | bool "Full dynticks system" | ||
84 | depends on NO_HZ && RCU_USER_QS && VIRT_CPU_ACCOUNTING_GEN && RCU_NOCB_CPU && SMP | ||
85 | select CONTEXT_TRACKING_FORCE | ||
86 | help | ||
87 | Adaptively try to shutdown the tick whenever possible, even when | ||
88 | the CPU is running tasks. Typically this requires running a single | ||
89 | task on the CPU. Chances for running tickless are maximized when | ||
90 | the task mostly runs in userspace and has few kernel activity. | ||
91 | |||
92 | You need to fill up the nohz_extended boot parameter with the | ||
93 | desired range of dynticks CPUs. | ||
94 | |||
95 | This is implemented at the expense of some overhead in user <-> kernel | ||
96 | transitions: syscalls, exceptions and interrupts. Even when it's | ||
97 | dynamically off. | ||
98 | |||
99 | Say N. | ||
100 | |||
82 | config HIGH_RES_TIMERS | 101 | config HIGH_RES_TIMERS |
83 | bool "High Resolution Timer Support" | 102 | bool "High Resolution Timer Support" |
84 | depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS | 103 | depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS |
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) | |||
142 | profile_tick(CPU_PROFILING); | 142 | profile_tick(CPU_PROFILING); |
143 | } | 143 | } |
144 | 144 | ||
145 | #ifdef CONFIG_NO_HZ_EXTENDED | ||
146 | static cpumask_var_t nohz_extended_mask; | ||
147 | bool have_nohz_extended_mask; | ||
148 | |||
149 | int tick_nohz_extended_cpu(int cpu) | ||
150 | { | ||
151 | if (!have_nohz_extended_mask) | ||
152 | return 0; | ||
153 | |||
154 | return cpumask_test_cpu(cpu, nohz_extended_mask); | ||
155 | } | ||
156 | |||
157 | /* Parse the boot-time nohz CPU list from the kernel parameters. */ | ||
158 | static int __init tick_nohz_extended_setup(char *str) | ||
159 | { | ||
160 | alloc_bootmem_cpumask_var(&nohz_extended_mask); | ||
161 | if (cpulist_parse(str, nohz_extended_mask) < 0) | ||
162 | pr_warning("NOHZ: Incorrect nohz_extended cpumask\n"); | ||
163 | else | ||
164 | have_nohz_extended_mask = true; | ||
165 | return 1; | ||
166 | } | ||
167 | __setup("nohz_extended=", tick_nohz_extended_setup); | ||
168 | |||
169 | static int __init init_tick_nohz_extended(void) | ||
170 | { | ||
171 | cpumask_var_t online_nohz; | ||
172 | int cpu; | ||
173 | |||
174 | if (!have_nohz_extended_mask) | ||
175 | return 0; | ||
176 | |||
177 | if (!zalloc_cpumask_var(&online_nohz, GFP_KERNEL)) { | ||
178 | pr_warning("NO_HZ: Not enough memory to check extended nohz mask\n"); | ||
179 | return -ENOMEM; | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * CPUs can probably not be concurrently offlined on initcall time. | ||
184 | * But we are paranoid, aren't we? | ||
185 | */ | ||
186 | get_online_cpus(); | ||
187 | |||
188 | /* Ensure we keep a CPU outside the dynticks range for timekeeping */ | ||
189 | cpumask_and(online_nohz, cpu_online_mask, nohz_extended_mask); | ||
190 | if (cpumask_equal(online_nohz, cpu_online_mask)) { | ||
191 | cpu = cpumask_any(cpu_online_mask); | ||
192 | pr_warning("NO_HZ: Must keep at least one online CPU " | ||
193 | "out of nohz_extended range\n"); | ||
194 | pr_warning("NO_HZ: Clearing %d from nohz_extended range\n", cpu); | ||
195 | cpumask_clear_cpu(cpu, nohz_extended_mask); | ||
196 | } | ||
197 | put_online_cpus(); | ||
198 | free_cpumask_var(online_nohz); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | core_initcall(init_tick_nohz_extended); | ||
203 | #else | ||
204 | #define have_nohz_extended_mask (0) | ||
205 | #endif | ||
206 | |||
145 | /* | 207 | /* |
146 | * NOHZ - aka dynamic tick functionality | 208 | * NOHZ - aka dynamic tick functionality |
147 | */ | 209 | */ |