[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aDXU6LUlrmBLL3ak@yury>
Date: Tue, 27 May 2025 11:06:16 -0400
From: Yury Norov <yury.norov@...il.com>
To: Shrikanth Hegde <sshegde@...ux.ibm.com>
Cc: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, tglx@...utronix.de, maddy@...ux.ibm.com,
vschneid@...hat.com, dietmar.eggemann@....com, rostedt@...dmis.org,
jstultz@...gle.com, kprateek.nayak@....com, huschle@...ux.ibm.com,
srikar@...ux.ibm.com, linux-kernel@...r.kernel.org,
linux@...musvillemoes.dk
Subject: Re: [RFC PATCH 1/5] cpumask: Introduce cpu parked mask
On Fri, May 23, 2025 at 11:44:44PM +0530, Shrikanth Hegde wrote:
> CPU is said to be parked, when underlying physical CPU is not
> available. This happens when there is contention for CPU resource in
> para-virtualized case. One should avoid using these CPUs.
>
> Build and maintain this state of parked CPUs. Scheduler will use this
> information and push the tasks out as soon as it can.
This 'parked' term sounds pretty obscured. Maybe name it in
a positive sense, and more explicit, like cpu_paravirt_mask.
Also, shouldn't this be conditional on CONFIG_PARAVIRT?
Thanks,
Yury
> Signed-off-by: Shrikanth Hegde <sshegde@...ux.ibm.com>
> ---
> - Not sure if __read_mostly attribute suits for cpu_parked
> since it can change often. Since often means a few mins, it is long time
> from scheduler perspective, hence kept it.
>
> include/linux/cpumask.h | 14 ++++++++++++++
> kernel/cpu.c | 3 +++
> 2 files changed, 17 insertions(+)
>
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 6a569c7534db..501848303800 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -84,6 +84,7 @@ static __always_inline void set_nr_cpu_ids(unsigned int nr)
> * cpu_enabled_mask - has bit 'cpu' set iff cpu can be brought online
> * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
> * cpu_active_mask - has bit 'cpu' set iff cpu available to migration
> + * cpu_parked_mask - has bit 'cpu' set iff cpu is parked
> *
> * If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
> *
> @@ -93,6 +94,11 @@ static __always_inline void set_nr_cpu_ids(unsigned int nr)
> * representing which CPUs are currently plugged in. And
> * cpu_online_mask is the dynamic subset of cpu_present_mask,
> * indicating those CPUs available for scheduling.
> + *
> + * A CPU is said to be parked when underlying physical CPU(pCPU) is not
> + * available at the moment. It is recommended not to run any workload on
> + * that CPU.
> +
> *
> * If HOTPLUG is enabled, then cpu_present_mask varies dynamically,
> * depending on what ACPI reports as currently plugged in, otherwise
> @@ -118,12 +124,14 @@ extern struct cpumask __cpu_enabled_mask;
> extern struct cpumask __cpu_present_mask;
> extern struct cpumask __cpu_active_mask;
> extern struct cpumask __cpu_dying_mask;
> +extern struct cpumask __cpu_parked_mask;
> #define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
> #define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
> #define cpu_enabled_mask ((const struct cpumask *)&__cpu_enabled_mask)
> #define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask)
> #define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask)
> #define cpu_dying_mask ((const struct cpumask *)&__cpu_dying_mask)
> +#define cpu_parked_mask ((const struct cpumask *)&__cpu_parked_mask)
>
> extern atomic_t __num_online_cpus;
>
> @@ -1146,6 +1154,7 @@ void init_cpu_possible(const struct cpumask *src);
> #define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mask, (present))
> #define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, (active))
> #define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dying))
> +#define set_cpu_parked(cpu, parked) assign_cpu((cpu), &__cpu_parked_mask, (parked))
>
> void set_cpu_online(unsigned int cpu, bool online);
>
> @@ -1235,6 +1244,11 @@ static __always_inline bool cpu_dying(unsigned int cpu)
> return cpumask_test_cpu(cpu, cpu_dying_mask);
> }
>
> +static __always_inline bool cpu_parked(unsigned int cpu)
> +{
> + return cpumask_test_cpu(cpu, cpu_parked_mask);
> +}
> +
> #else
>
> #define num_online_cpus() 1U
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index a59e009e0be4..532fbfbe3226 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -3110,6 +3110,9 @@ EXPORT_SYMBOL(__cpu_dying_mask);
> atomic_t __num_online_cpus __read_mostly;
> EXPORT_SYMBOL(__num_online_cpus);
>
> +struct cpumask __cpu_parked_mask __read_mostly;
> +EXPORT_SYMBOL(__cpu_parked_mask);
> +
> void init_cpu_present(const struct cpumask *src)
> {
> cpumask_copy(&__cpu_present_mask, src);
> --
> 2.39.3
Powered by blists - more mailing lists