Re: [PATCH 1/2] sched: isolation: cpu isolation handles for cpuset

From: Frederic Weisbecker
Date: Wed Oct 27 2021 - 19:20:43 EST


On Wed, Oct 27, 2021 at 04:43:18PM -0400, Paul Gortmaker wrote:
> Assuming we want to drive isolation from cpuset and not something
> like /sys/devices/system/cpu/cpu*/hotplug/isolation then we'll
> need some kind of handle for cpuset to drive it from.
>
> These would also serve as a collection point for all the isolation
> related operations - current and future. While only RCU nocb toggle
> is currently deployed, I've left some guesses at what is probably to
> come in the future.
>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
> Cc: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
> Cc: Valentin Schneider <valentin.schneider@xxxxxxx>
> [PG: RFC code - not for merge]
> Signed-off-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx>
> ---
> include/linux/sched/isolation.h | 4 ++++
> kernel/sched/isolation.c | 22 ++++++++++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
> index cc9f393e2a70..3ab9c667c441 100644
> --- a/include/linux/sched/isolation.h
> +++ b/include/linux/sched/isolation.h
> @@ -25,6 +25,8 @@ extern bool housekeeping_enabled(enum hk_flags flags);
> extern void housekeeping_affine(struct task_struct *t, enum hk_flags flags);
> extern bool housekeeping_test_cpu(int cpu, enum hk_flags flags);
> extern void __init housekeeping_init(void);
> +extern void isolate_cpu(int cpu);
> +extern void deisolate_cpu(int cpu);

I first read "desolate_cpu()". That gives me ideas to rename nohz_full.

>
> #else
>
> @@ -46,6 +48,8 @@ static inline bool housekeeping_enabled(enum hk_flags flags)
> static inline void housekeeping_affine(struct task_struct *t,
> enum hk_flags flags) { }
> static inline void housekeeping_init(void) { }
> +static void isolate_cpu(int cpu) { }
> +static void deisolate_cpu(int cpu) { }
> #endif /* CONFIG_CPU_ISOLATION */
>
> static inline bool housekeeping_cpu(int cpu, enum hk_flags flags)
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 7f06eaf12818..57b105d42632 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -63,6 +63,28 @@ bool housekeeping_test_cpu(int cpu, enum hk_flags flags)
> }
> EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
>
> +void isolate_cpu(int cpu)
> +{
> + pr_info("Isolating core %d\n", cpu);
> + if (rcu_nocb_cpu_offload(cpu))
> + pr_warn("RCU; unable to nocb offload CPU %d\n", cpu);
> +#if 0 /* TODO */
> + housekeeping_clear_cpu(cpu);
> + tick_nohz_full_add_cpus_to(cpumask_of(cpu));
> +#endif
> +}
> +
> +void deisolate_cpu(int cpu)
> +{
> + pr_info("Deisolating core %d\n", cpu);
> +#if 0 /* TODO */
> + tick_nohz_full_clear_cpus_from(cpumask_of(cpu));
> + housekeeping_add_cpu(cpu);
> +#endif
> + if (rcu_nocb_cpu_deoffload(cpu))
> + pr_warn("RCU: unable to nocb reload CPU %d\n", cpu);
> +}

In my series I'm eventually splitting housekeeping cpumasks so that we
can modify HK_FLAG_RCU without modifying the others.

Thanks.

> +
> void __init housekeeping_init(void)
> {
> if (!housekeeping_flags)
> --
> 2.15.0
>