sched/isolation: Move housekeeping related code to its own file
authorFrederic Weisbecker <frederic@kernel.org>
Fri, 27 Oct 2017 02:42:28 +0000 (04:42 +0200)
committerLukasz Luba <l.luba@partner.samsung.com>
Mon, 10 Sep 2018 08:18:11 +0000 (10:18 +0200)
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>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
12 files changed:
drivers/net/ethernet/tile/tilegx.c
include/linux/sched/isolation.h [new file with mode: 0644]
include/linux/tick.h
init/main.c
kernel/rcu/tree_plugin.h
kernel/rcu/update.c
kernel/sched/Makefile
kernel/sched/core.c
kernel/sched/fair.c
kernel/sched/isolation.c [new file with mode: 0644]
kernel/time/tick-sched.c
kernel/watchdog.c

index c00102b8145aea309e3a405b8b62803d70b1e4d4..27a3272dcd48f321276bfa19f8abd5e7a4b1c842 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/tcp.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_clock_kernel.h>
-#include <linux/tick.h>
+#include <linux/sched/isolation.h>
 
 #include <asm/checksum.h>
 #include <asm/homecache.h>
diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
new file mode 100644 (file)
index 0000000..b7cfbc4
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef _LINUX_SCHED_ISOLATION_H
+#define _LINUX_SCHED_ISOLATION_H
+
+#include <linux/cpumask.h>
+#include <linux/init.h>
+#include <linux/tick.h>
+
+#ifdef CONFIG_NO_HZ_FULL
+extern cpumask_var_t housekeeping_mask;
+
+static inline int housekeeping_any_cpu(void)
+{
+       return cpumask_any_and(housekeeping_mask, cpu_online_mask);
+}
+
+extern void __init housekeeping_init(void);
+
+#else
+
+static inline int housekeeping_any_cpu(void)
+{
+       return smp_processor_id();
+}
+
+static inline void housekeeping_init(void) { }
+#endif /* CONFIG_NO_HZ_FULL */
+
+
+static inline const struct cpumask *housekeeping_cpumask(void)
+{
+#ifdef CONFIG_NO_HZ_FULL
+       if (tick_nohz_full_enabled())
+               return housekeeping_mask;
+#endif
+       return cpu_possible_mask;
+}
+
+static inline bool is_housekeeping_cpu(int cpu)
+{
+#ifdef CONFIG_NO_HZ_FULL
+       if (tick_nohz_full_enabled())
+               return cpumask_test_cpu(cpu, housekeeping_mask);
+#endif
+       return true;
+}
+
+static inline void housekeeping_affine(struct task_struct *t)
+{
+#ifdef CONFIG_NO_HZ_FULL
+       if (tick_nohz_full_enabled())
+               set_cpus_allowed_ptr(t, housekeeping_mask);
+
+#endif
+}
+
+#endif /* _LINUX_SCHED_ISOLATION_H */
index 5cdac11dd317094c53a95bb1f71e8e1855171369..4deac3d7e75782e70f285a965771501ad195ff84 100644 (file)
@@ -139,7 +139,6 @@ static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; }
 #ifdef CONFIG_NO_HZ_FULL
 extern bool tick_nohz_full_running;
 extern cpumask_var_t tick_nohz_full_mask;
-extern cpumask_var_t housekeeping_mask;
 
 static inline bool tick_nohz_full_enabled(void)
 {
@@ -163,11 +162,6 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask)
                cpumask_or(mask, mask, tick_nohz_full_mask);
 }
 
-static inline int housekeeping_any_cpu(void)
-{
-       return cpumask_any_and(housekeeping_mask, cpu_online_mask);
-}
-
 extern void tick_nohz_dep_set(enum tick_dep_bits bit);
 extern void tick_nohz_dep_clear(enum tick_dep_bits bit);
 extern void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit);
@@ -237,10 +231,6 @@ 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);
 #else
-static inline int housekeeping_any_cpu(void)
-{
-       return smp_processor_id();
-}
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
 static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { }
@@ -262,33 +252,6 @@ static inline void tick_nohz_full_kick_cpu(int cpu) { }
 static inline void __tick_nohz_task_switch(void) { }
 #endif
 
-static inline const struct cpumask *housekeeping_cpumask(void)
-{
-#ifdef CONFIG_NO_HZ_FULL
-       if (tick_nohz_full_enabled())
-               return housekeeping_mask;
-#endif
-       return cpu_possible_mask;
-}
-
-static inline bool is_housekeeping_cpu(int cpu)
-{
-#ifdef CONFIG_NO_HZ_FULL
-       if (tick_nohz_full_enabled())
-               return cpumask_test_cpu(cpu, housekeeping_mask);
-#endif
-       return true;
-}
-
-static inline void housekeeping_affine(struct task_struct *t)
-{
-#ifdef CONFIG_NO_HZ_FULL
-       if (tick_nohz_full_enabled())
-               set_cpus_allowed_ptr(t, housekeeping_mask);
-
-#endif
-}
-
 static inline void tick_nohz_task_switch(void)
 {
        if (tick_nohz_full_enabled())
index 2d355a61dfc51a5582f834f4fcca382469c83fb0..0dd5364d665948f53448917fde811561af538135 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/cgroup.h>
 #include <linux/efi.h>
 #include <linux/tick.h>
+#include <linux/sched/isolation.h>
 #include <linux/interrupt.h>
 #include <linux/taskstats_kern.h>
 #include <linux/delayacct.h>
@@ -610,6 +611,7 @@ asmlinkage __visible void __init start_kernel(void)
        early_irq_init();
        init_IRQ();
        tick_init();
+       housekeeping_init();
        rcu_init_nohz();
        init_timers();
        hrtimers_init();
index fed95fa941e61737e55b84ce080135059c2dfbd3..34d4a563bb390a4885f43ce3c19e220fff606942 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/oom.h>
 #include <linux/sched/debug.h>
 #include <linux/smpboot.h>
+#include <linux/sched/isolation.h>
 #include <uapi/linux/sched/types.h>
 #include "../time/tick-internal.h"
 
index 7a577bd989a4a3b6388e093a5820c002a6dcd42b..be59c8131593cd547e15be31eccbc51a5c5e8499 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/kthread.h>
 #include <linux/tick.h>
 #include <linux/rcupdate_wait.h>
+#include <linux/sched/isolation.h>
 
 #define CREATE_TRACE_POINTS
 
index a9ee16bbc6931a6e6cb8631f48bc6c19b39215b4..bebd97a6ddfe78455e8f7f5aba3c7e697214a255 100644 (file)
@@ -27,3 +27,4 @@ obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o
 obj-$(CONFIG_CPU_FREQ) += cpufreq.o
 obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o
 obj-$(CONFIG_MEMBARRIER) += membarrier.o
+obj-$(CONFIG_NO_HZ_FULL) += isolation.o
index ca08598c467fe73b4f97481529bbfc5d749f5dbf..ec2aea4048fcfdb8c996fbd166fc42da5554e627 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/profile.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/sched/isolation.h>
 
 #include <asm/switch_to.h>
 #include <asm/tlb.h>
index 6ce37ba92f9d9c02dcc93cbe59bd6e2707ab2f4c..ac55c8182fca0f996f42bd0ab745c4c2ccecb673 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/mempolicy.h>
 #include <linux/migrate.h>
 #include <linux/task_work.h>
+#include <linux/sched/isolation.h>
 
 #include <trace/events/sched.h>
 
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
new file mode 100644 (file)
index 0000000..3589252
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  Housekeeping management. Manage the targets for routine code that can run on
+ *  any CPU: unbound workqueues, timers, kthreads and any offloadable work.
+ *
+ * Copyright (C) 2017 Red Hat, Inc., Frederic Weisbecker
+ *
+ */
+
+#include <linux/sched/isolation.h>
+#include <linux/tick.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+cpumask_var_t housekeeping_mask;
+
+void __init housekeeping_init(void)
+{
+       if (!tick_nohz_full_enabled())
+               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);
+
+       /* We need at least one CPU to handle housekeeping work */
+       WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
+}
index 92bc1995949e332d216400903f1af849f78f9d3f..92d14aeb15cc1cc211a76f5f3e600022015c31db 100644 (file)
@@ -166,7 +166,6 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
 
 #ifdef CONFIG_NO_HZ_FULL
 cpumask_var_t tick_nohz_full_mask;
-cpumask_var_t housekeeping_mask;
 bool tick_nohz_full_running;
 static atomic_t tick_dep_mask;
 
@@ -438,13 +437,6 @@ void __init tick_nohz_init(void)
                        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;
-       }
-
        /*
         * Full dynticks uses irq work to drive the tick rescheduling on safe
         * locking contexts. But then we need irq work to raise its own
@@ -453,7 +445,6 @@ void __init tick_nohz_init(void)
        if (!arch_irq_work_has_interrupt()) {
                pr_warn("NO_HZ: Can't run full dynticks because arch doesn't support irq work self-IPIs\n");
                cpumask_clear(tick_nohz_full_mask);
-               cpumask_copy(housekeeping_mask, cpu_possible_mask);
                tick_nohz_full_running = false;
                return;
        }
@@ -466,9 +457,6 @@ void __init tick_nohz_init(void)
                cpumask_clear_cpu(cpu, tick_nohz_full_mask);
        }
 
-       cpumask_andnot(housekeeping_mask,
-                      cpu_possible_mask, tick_nohz_full_mask);
-
        for_each_cpu(cpu, tick_nohz_full_mask)
                context_tracking_cpu_set(cpu);
 
@@ -478,12 +466,6 @@ void __init tick_nohz_init(void)
        WARN_ON(ret < 0);
        pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n",
                cpumask_pr_args(tick_nohz_full_mask));
-
-       /*
-        * We need at least one CPU to handle housekeeping work such
-        * as timekeeping, unbound timers, workqueues, ...
-        */
-       WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
 }
 #endif
 
index c8e06703e44c2ce1604aab569d1a9cd4b7faf823..813006ab12088308a8cb1435a3415b073bae4554 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/workqueue.h>
 #include <linux/sched/clock.h>
 #include <linux/sched/debug.h>
+#include <linux/sched/isolation.h>
 
 #include <asm/irq_regs.h>
 #include <linux/kvm_para.h>