aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Weisbecker <frederic@kernel.org>2017-10-26 22:42:28 -0400
committerIngo Molnar <mingo@kernel.org>2017-10-27 03:55:24 -0400
commit7863406143d8bbbbda07a61285c5f4c217908dfd (patch)
tree91693d224c4970503ed0ea7636fe774331a265ec
parent54b933c6c954a8b7b0c2b40a1c4d3f7279d11e22 (diff)
sched/isolation: Move housekeeping related code to its own file
The housekeeping code is currently tied to the NOHZ code. As we are planning to make housekeeping independent from it, start with moving the relevant code to its own file. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Christoph Lameter <cl@linux.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Wanpeng Li <kernellwp@gmail.com> Link: http://lkml.kernel.org/r/1509072159-31808-2-git-send-email-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--drivers/net/ethernet/tile/tilegx.c2
-rw-r--r--include/linux/sched/isolation.h56
-rw-r--r--include/linux/tick.h37
-rw-r--r--init/main.c2
-rw-r--r--kernel/rcu/tree_plugin.h1
-rw-r--r--kernel/rcu/update.c1
-rw-r--r--kernel/sched/Makefile1
-rw-r--r--kernel/sched/core.c1
-rw-r--r--kernel/sched/fair.c1
-rw-r--r--kernel/sched/isolation.c33
-rw-r--r--kernel/time/tick-sched.c18
-rw-r--r--kernel/watchdog.c1
12 files changed, 98 insertions, 56 deletions
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index c00102b8145a..27a3272dcd48 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -40,7 +40,7 @@
40#include <linux/tcp.h> 40#include <linux/tcp.h>
41#include <linux/net_tstamp.h> 41#include <linux/net_tstamp.h>
42#include <linux/ptp_clock_kernel.h> 42#include <linux/ptp_clock_kernel.h>
43#include <linux/tick.h> 43#include <linux/sched/isolation.h>
44 44
45#include <asm/checksum.h> 45#include <asm/checksum.h>
46#include <asm/homecache.h> 46#include <asm/homecache.h>
diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
new file mode 100644
index 000000000000..b7cfbc46286c
--- /dev/null
+++ b/include/linux/sched/isolation.h
@@ -0,0 +1,56 @@
1#ifndef _LINUX_SCHED_ISOLATION_H
2#define _LINUX_SCHED_ISOLATION_H
3
4#include <linux/cpumask.h>
5#include <linux/init.h>
6#include <linux/tick.h>
7
8#ifdef CONFIG_NO_HZ_FULL
9extern cpumask_var_t housekeeping_mask;
10
11static inline int housekeeping_any_cpu(void)
12{
13 return cpumask_any_and(housekeeping_mask, cpu_online_mask);
14}
15
16extern void __init housekeeping_init(void);
17
18#else
19
20static inline int housekeeping_any_cpu(void)
21{
22 return smp_processor_id();
23}
24
25static inline void housekeeping_init(void) { }
26#endif /* CONFIG_NO_HZ_FULL */
27
28
29static inline const struct cpumask *housekeeping_cpumask(void)
30{
31#ifdef CONFIG_NO_HZ_FULL
32 if (tick_nohz_full_enabled())
33 return housekeeping_mask;
34#endif
35 return cpu_possible_mask;
36}
37
38static inline bool is_housekeeping_cpu(int cpu)
39{
40#ifdef CONFIG_NO_HZ_FULL
41 if (tick_nohz_full_enabled())
42 return cpumask_test_cpu(cpu, housekeeping_mask);
43#endif
44 return true;
45}
46
47static inline void housekeeping_affine(struct task_struct *t)
48{
49#ifdef CONFIG_NO_HZ_FULL
50 if (tick_nohz_full_enabled())
51 set_cpus_allowed_ptr(t, housekeeping_mask);
52
53#endif
54}
55
56#endif /* _LINUX_SCHED_ISOLATION_H */
diff --git a/include/linux/tick.h b/include/linux/tick.h
index fe01e68bf520..68afc09aa8ac 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -137,7 +137,6 @@ static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; }
137#ifdef CONFIG_NO_HZ_FULL 137#ifdef CONFIG_NO_HZ_FULL
138extern bool tick_nohz_full_running; 138extern bool tick_nohz_full_running;
139extern cpumask_var_t tick_nohz_full_mask; 139extern cpumask_var_t tick_nohz_full_mask;
140extern cpumask_var_t housekeeping_mask;
141 140
142static inline bool tick_nohz_full_enabled(void) 141static inline bool tick_nohz_full_enabled(void)
143{ 142{
@@ -161,11 +160,6 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask)
161 cpumask_or(mask, mask, tick_nohz_full_mask); 160 cpumask_or(mask, mask, tick_nohz_full_mask);
162} 161}
163 162
164static inline int housekeeping_any_cpu(void)
165{
166 return cpumask_any_and(housekeeping_mask, cpu_online_mask);
167}
168
169extern void tick_nohz_dep_set(enum tick_dep_bits bit); 163extern void tick_nohz_dep_set(enum tick_dep_bits bit);
170extern void tick_nohz_dep_clear(enum tick_dep_bits bit); 164extern void tick_nohz_dep_clear(enum tick_dep_bits bit);
171extern void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit); 165extern void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit);
@@ -235,10 +229,6 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal,
235extern void tick_nohz_full_kick_cpu(int cpu); 229extern void tick_nohz_full_kick_cpu(int cpu);
236extern void __tick_nohz_task_switch(void); 230extern void __tick_nohz_task_switch(void);
237#else 231#else
238static inline int housekeeping_any_cpu(void)
239{
240 return smp_processor_id();
241}
242static inline bool tick_nohz_full_enabled(void) { return false; } 232static inline bool tick_nohz_full_enabled(void) { return false; }
243static inline bool tick_nohz_full_cpu(int cpu) { return false; } 233static inline bool tick_nohz_full_cpu(int cpu) { return false; }
244static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { } 234static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { }
@@ -260,33 +250,6 @@ static inline void tick_nohz_full_kick_cpu(int cpu) { }
260static inline void __tick_nohz_task_switch(void) { } 250static inline void __tick_nohz_task_switch(void) { }
261#endif 251#endif
262 252
263static inline const struct cpumask *housekeeping_cpumask(void)
264{
265#ifdef CONFIG_NO_HZ_FULL
266 if (tick_nohz_full_enabled())
267 return housekeeping_mask;
268#endif
269 return cpu_possible_mask;
270}
271
272static inline bool is_housekeeping_cpu(int cpu)
273{
274#ifdef CONFIG_NO_HZ_FULL
275 if (tick_nohz_full_enabled())
276 return cpumask_test_cpu(cpu, housekeeping_mask);
277#endif
278 return true;
279}
280
281static inline void housekeeping_affine(struct task_struct *t)
282{
283#ifdef CONFIG_NO_HZ_FULL
284 if (tick_nohz_full_enabled())
285 set_cpus_allowed_ptr(t, housekeeping_mask);
286
287#endif
288}
289
290static inline void tick_nohz_task_switch(void) 253static inline void tick_nohz_task_switch(void)
291{ 254{
292 if (tick_nohz_full_enabled()) 255 if (tick_nohz_full_enabled())
diff --git a/init/main.c b/init/main.c
index 0ee9c6866ada..4610c99ae306 100644
--- a/init/main.c
+++ b/init/main.c
@@ -46,6 +46,7 @@
46#include <linux/cgroup.h> 46#include <linux/cgroup.h>
47#include <linux/efi.h> 47#include <linux/efi.h>
48#include <linux/tick.h> 48#include <linux/tick.h>
49#include <linux/sched/isolation.h>
49#include <linux/interrupt.h> 50#include <linux/interrupt.h>
50#include <linux/taskstats_kern.h> 51#include <linux/taskstats_kern.h>
51#include <linux/delayacct.h> 52#include <linux/delayacct.h>
@@ -606,6 +607,7 @@ asmlinkage __visible void __init start_kernel(void)
606 early_irq_init(); 607 early_irq_init();
607 init_IRQ(); 608 init_IRQ();
608 tick_init(); 609 tick_init();
610 housekeeping_init();
609 rcu_init_nohz(); 611 rcu_init_nohz();
610 init_timers(); 612 init_timers();
611 hrtimers_init(); 613 hrtimers_init();
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index e012b9be777e..c7632f51c5a0 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -29,6 +29,7 @@
29#include <linux/oom.h> 29#include <linux/oom.h>
30#include <linux/sched/debug.h> 30#include <linux/sched/debug.h>
31#include <linux/smpboot.h> 31#include <linux/smpboot.h>
32#include <linux/sched/isolation.h>
32#include <uapi/linux/sched/types.h> 33#include <uapi/linux/sched/types.h>
33#include "../time/tick-internal.h" 34#include "../time/tick-internal.h"
34 35
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index 5033b66d2753..79abeb0ca329 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -51,6 +51,7 @@
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/tick.h> 52#include <linux/tick.h>
53#include <linux/rcupdate_wait.h> 53#include <linux/rcupdate_wait.h>
54#include <linux/sched/isolation.h>
54 55
55#define CREATE_TRACE_POINTS 56#define CREATE_TRACE_POINTS
56 57
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
index 78f54932ea1d..871d43d73375 100644
--- a/kernel/sched/Makefile
+++ b/kernel/sched/Makefile
@@ -26,3 +26,4 @@ obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o
26obj-$(CONFIG_CPU_FREQ) += cpufreq.o 26obj-$(CONFIG_CPU_FREQ) += cpufreq.o
27obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o 27obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o
28obj-$(CONFIG_MEMBARRIER) += membarrier.o 28obj-$(CONFIG_MEMBARRIER) += membarrier.o
29obj-$(CONFIG_NO_HZ_FULL) += isolation.o
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2288a145bf01..ad188acb7636 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -26,6 +26,7 @@
26#include <linux/profile.h> 26#include <linux/profile.h>
27#include <linux/security.h> 27#include <linux/security.h>
28#include <linux/syscalls.h> 28#include <linux/syscalls.h>
29#include <linux/sched/isolation.h>
29 30
30#include <asm/switch_to.h> 31#include <asm/switch_to.h>
31#include <asm/tlb.h> 32#include <asm/tlb.h>
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 56f343b8e749..591481db8c6a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -32,6 +32,7 @@
32#include <linux/mempolicy.h> 32#include <linux/mempolicy.h>
33#include <linux/migrate.h> 33#include <linux/migrate.h>
34#include <linux/task_work.h> 34#include <linux/task_work.h>
35#include <linux/sched/isolation.h>
35 36
36#include <trace/events/sched.h> 37#include <trace/events/sched.h>
37 38
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
new file mode 100644
index 000000000000..3589252ed476
--- /dev/null
+++ b/kernel/sched/isolation.c
@@ -0,0 +1,33 @@
1/*
2 * Housekeeping management. Manage the targets for routine code that can run on
3 * any CPU: unbound workqueues, timers, kthreads and any offloadable work.
4 *
5 * Copyright (C) 2017 Red Hat, Inc., Frederic Weisbecker
6 *
7 */
8
9#include <linux/sched/isolation.h>
10#include <linux/tick.h>
11#include <linux/init.h>
12#include <linux/kernel.h>
13
14cpumask_var_t housekeeping_mask;
15
16void __init housekeeping_init(void)
17{
18 if (!tick_nohz_full_enabled())
19 return;
20
21 if (!alloc_cpumask_var(&housekeeping_mask, GFP_KERNEL)) {
22 WARN(1, "NO_HZ: Can't allocate not-full dynticks cpumask\n");
23 cpumask_clear(tick_nohz_full_mask);
24 tick_nohz_full_running = false;
25 return;
26 }
27
28 cpumask_andnot(housekeeping_mask,
29 cpu_possible_mask, tick_nohz_full_mask);
30
31 /* We need at least one CPU to handle housekeeping work */
32 WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
33}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7b258c59d78a..27d7d522ac4e 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -166,7 +166,6 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
166 166
167#ifdef CONFIG_NO_HZ_FULL 167#ifdef CONFIG_NO_HZ_FULL
168cpumask_var_t tick_nohz_full_mask; 168cpumask_var_t tick_nohz_full_mask;
169cpumask_var_t housekeeping_mask;
170bool tick_nohz_full_running; 169bool tick_nohz_full_running;
171static atomic_t tick_dep_mask; 170static atomic_t tick_dep_mask;
172 171
@@ -438,13 +437,6 @@ void __init tick_nohz_init(void)
438 return; 437 return;
439 } 438 }
440 439
441 if (!alloc_cpumask_var(&housekeeping_mask, GFP_KERNEL)) {
442 WARN(1, "NO_HZ: Can't allocate not-full dynticks cpumask\n");
443 cpumask_clear(tick_nohz_full_mask);
444 tick_nohz_full_running = false;
445 return;
446 }
447
448 /* 440 /*
449 * Full dynticks uses irq work to drive the tick rescheduling on safe 441 * Full dynticks uses irq work to drive the tick rescheduling on safe
450 * locking contexts. But then we need irq work to raise its own 442 * locking contexts. But then we need irq work to raise its own
@@ -453,7 +445,6 @@ void __init tick_nohz_init(void)
453 if (!arch_irq_work_has_interrupt()) { 445 if (!arch_irq_work_has_interrupt()) {
454 pr_warn("NO_HZ: Can't run full dynticks because arch doesn't support irq work self-IPIs\n"); 446 pr_warn("NO_HZ: Can't run full dynticks because arch doesn't support irq work self-IPIs\n");
455 cpumask_clear(tick_nohz_full_mask); 447 cpumask_clear(tick_nohz_full_mask);
456 cpumask_copy(housekeeping_mask, cpu_possible_mask);
457 tick_nohz_full_running = false; 448 tick_nohz_full_running = false;
458 return; 449 return;
459 } 450 }
@@ -466,9 +457,6 @@ void __init tick_nohz_init(void)
466 cpumask_clear_cpu(cpu, tick_nohz_full_mask); 457 cpumask_clear_cpu(cpu, tick_nohz_full_mask);
467 } 458 }
468 459
469 cpumask_andnot(housekeeping_mask,
470 cpu_possible_mask, tick_nohz_full_mask);
471
472 for_each_cpu(cpu, tick_nohz_full_mask) 460 for_each_cpu(cpu, tick_nohz_full_mask)
473 context_tracking_cpu_set(cpu); 461 context_tracking_cpu_set(cpu);
474 462
@@ -478,12 +466,6 @@ void __init tick_nohz_init(void)
478 WARN_ON(ret < 0); 466 WARN_ON(ret < 0);
479 pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n", 467 pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n",
480 cpumask_pr_args(tick_nohz_full_mask)); 468 cpumask_pr_args(tick_nohz_full_mask));
481
482 /*
483 * We need at least one CPU to handle housekeeping work such
484 * as timekeeping, unbound timers, workqueues, ...
485 */
486 WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
487} 469}
488#endif 470#endif
489 471
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 6bcb854909c0..3c44dbaa4b9f 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -24,6 +24,7 @@
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/sched/clock.h> 25#include <linux/sched/clock.h>
26#include <linux/sched/debug.h> 26#include <linux/sched/debug.h>
27#include <linux/sched/isolation.h>
27 28
28#include <asm/irq_regs.h> 29#include <asm/irq_regs.h>
29#include <linux/kvm_para.h> 30#include <linux/kvm_para.h>