From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751552AbdJXNf7 (ORCPT ); Tue, 24 Oct 2017 09:35:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48938 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751444AbdJXNfz (ORCPT ); Tue, 24 Oct 2017 09:35:55 -0400 Date: Tue, 24 Oct 2017 06:35:47 -0700 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: Ingo Molnar , LKML , Peter Zijlstra , Chris Metcalf , Thomas Gleixner , Luiz Capitulino , Christoph Lameter , Mike Galbraith , Rik van Riel , Wanpeng Li Subject: Re: [PATCH 01/12] housekeeping: Move housekeeping related code to its own file Reply-To: paulmck@linux.vnet.ibm.com References: <1508850421-10058-1-git-send-email-frederic@kernel.org> <1508850421-10058-2-git-send-email-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1508850421-10058-2-git-send-email-frederic@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17102413-0024-0000-0000-000002E72B7F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007945; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00935783; UDB=6.00471497; IPR=6.00716049; BA=6.00005658; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017688; XFM=3.00000015; UTC=2017-10-24 13:35:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102413-0025-0000-0000-000045D38B2D Message-Id: <20171024133547.GX3659@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-24_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710240189 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 24, 2017 at 03:06:50PM +0200, Frederic Weisbecker wrote: > The housekeeping code is currently tied to the nohz code. As we are > planning to make housekeeping independant from it, start with moving > the relevant code to its own file. > > Signed-off-by: Frederic Weisbecker > Cc: Chris Metcalf > Cc: Rik van Riel > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Mike Galbraith > Cc: Ingo Molnar > Cc: Christoph Lameter > Cc: Paul E. McKenney >>From an RCU perspective: Acked-by: Paul E. McKenney > Cc: Wanpeng Li > Cc: Luiz Capitulino > --- > drivers/net/ethernet/tile/tilegx.c | 2 +- > include/linux/housekeeping.h | 56 ++++++++++++++++++++++++++++++++++++++ > include/linux/tick.h | 37 ------------------------- > init/main.c | 2 ++ > kernel/Makefile | 1 + > kernel/housekeeping.c | 33 ++++++++++++++++++++++ > kernel/rcu/tree_plugin.h | 1 + > kernel/rcu/update.c | 1 + > kernel/sched/core.c | 1 + > kernel/sched/fair.c | 1 + > kernel/time/tick-sched.c | 18 ------------ > kernel/watchdog.c | 1 + > 12 files changed, 98 insertions(+), 56 deletions(-) > create mode 100644 include/linux/housekeeping.h > create mode 100644 kernel/housekeeping.c > > diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c > index c00102b..8c7ef12 100644 > --- a/drivers/net/ethernet/tile/tilegx.c > +++ b/drivers/net/ethernet/tile/tilegx.c > @@ -40,7 +40,7 @@ > #include > #include > #include > -#include > +#include > > #include > #include > diff --git a/include/linux/housekeeping.h b/include/linux/housekeeping.h > new file mode 100644 > index 0000000..3d6a8e6 > --- /dev/null > +++ b/include/linux/housekeeping.h > @@ -0,0 +1,56 @@ > +#ifndef _LINUX_HOUSEKEEPING_H > +#define _LINUX_HOUSEKEEPING_H > + > +#include > +#include > +#include > + > +#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_HOUSEKEEPING_H */ > diff --git a/include/linux/tick.h b/include/linux/tick.h > index fe01e68..68afc09 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; } > #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) > { > @@ -161,11 +160,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); > @@ -235,10 +229,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) { } > @@ -260,33 +250,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()) > diff --git a/init/main.c b/init/main.c > index 0ee9c686..bf138b9 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -46,6 +46,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -606,6 +607,7 @@ asmlinkage __visible void __init start_kernel(void) > early_irq_init(); > init_IRQ(); > tick_init(); > + housekeeping_init(); > rcu_init_nohz(); > init_timers(); > hrtimers_init(); > diff --git a/kernel/Makefile b/kernel/Makefile > index ed470aa..c63f893 100644 > --- a/kernel/Makefile > +++ b/kernel/Makefile > @@ -109,6 +109,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o > obj-$(CONFIG_JUMP_LABEL) += jump_label.o > obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o > obj-$(CONFIG_TORTURE_TEST) += torture.o > +obj-$(CONFIG_NO_HZ_FULL) += housekeeping.o > > obj-$(CONFIG_HAS_IOMEM) += memremap.o > > diff --git a/kernel/housekeeping.c b/kernel/housekeeping.c > new file mode 100644 > index 0000000..b41c52e > --- /dev/null > +++ b/kernel/housekeeping.c > @@ -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 > +#include > +#include > +#include > + > +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)); > +} > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > index e012b9b..387e0a2 100644 > --- a/kernel/rcu/tree_plugin.h > +++ b/kernel/rcu/tree_plugin.h > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > #include > #include "../time/tick-internal.h" > > diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c > index 5033b66..1c003e2 100644 > --- a/kernel/rcu/update.c > +++ b/kernel/rcu/update.c > @@ -51,6 +51,7 @@ > #include > #include > #include > +#include > > #define CREATE_TRACE_POINTS > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index d17c5da..4cc01a7 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > #include > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index d3f3094..c76fab6 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > > #include > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index c7a899c..9d29dee 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -165,7 +165,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; > > @@ -437,13 +436,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 > @@ -452,7 +444,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; > } > @@ -465,9 +456,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); > > @@ -477,12 +465,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 > > diff --git a/kernel/watchdog.c b/kernel/watchdog.c > index 6bcb854..d71eee0 100644 > --- a/kernel/watchdog.c > +++ b/kernel/watchdog.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > #include > #include > -- > 2.7.4 >