Re: [PATCH 05/33] sched/isolation: Save boot defined domain flags

Valentin Schneider
2025-10-23T15:45:47Z

On 13/10/25 22:31, Frederic Weisbecker wrote:
> HK_TYPE_DOMAIN will soon integrate not only boot defined isolcpus= CPUs
> but also cpuset isolated partitions.
>
> Housekeeping still needs a way to record what was initially passed
> to isolcpus= in order to keep these CPUs isolated after a cpuset
> isolated partition is modified or destroyed while containing some of
> them.
>
> Create a new HK_TYPE_DOMAIN_BOOT to keep track of those.
>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> Reviewed-by: Phil Auld <pauld@redhat.com>
> ---
> include/linux/sched/isolation.h | 1 +
> kernel/sched/isolation.c | 5 +++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
> index d8501f4709b5..da22b038942a 100644
> --- a/include/linux/sched/isolation.h
> +++ b/include/linux/sched/isolation.h
> @@ -7,6 +7,7 @@
> #include <linux/tick.h>
>
> enum hk_type {
> + HK_TYPE_DOMAIN_BOOT,
> HK_TYPE_DOMAIN,
> HK_TYPE_MANAGED_IRQ,
> HK_TYPE_KERNEL_NOISE,
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index a4cf17b1fab0..8690fb705089 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -11,6 +11,7 @@
> #include "sched.h"
>
> enum hk_flags {
> + HK_FLAG_DOMAIN_BOOT = BIT(HK_TYPE_DOMAIN_BOOT),
> HK_FLAG_DOMAIN = BIT(HK_TYPE_DOMAIN),
> HK_FLAG_MANAGED_IRQ = BIT(HK_TYPE_MANAGED_IRQ),
> HK_FLAG_KERNEL_NOISE = BIT(HK_TYPE_KERNEL_NOISE),
> @@ -216,7 +217,7 @@ static int __init housekeeping_isolcpus_setup(char *str)
>
> if (!strncmp(str, "domain,", 7)) {
> str += 7;
> - flags |= HK_FLAG_DOMAIN;
> + flags |= HK_FLAG_DOMAIN | HK_FLAG_DOMAIN_BOOT;
> continue;
> }
>
> @@ -246,7 +247,7 @@ static int __init housekeeping_isolcpus_setup(char *str)
>
> /* Default behaviour for isolcpus without flags */
> if (!flags)
> - flags |= HK_FLAG_DOMAIN;
> + flags |= HK_FLAG_DOMAIN | HK_FLAG_DOMAIN_BOOT;

I got stupidly confused by the cpumask_andnot() used later on since these
are housekeeping cpumasks and not isolated ones; AFAICT HK_FLAG_DOMAIN_BOOT
is meant to be a superset of HK_FLAG_DOMAIN - or, put in a way my brain
comprehends, NOT(HK_FLAG_DOMAIN) (i.e. runtime isolated cpumask) is a
superset of NOT(HK_FLAG_DOMAIN_BOOT) (i.e. boottime isolated cpumask),
thus the final shape of cpu_is_isolated() makes sense:

static inline bool cpu_is_isolated(int cpu)
{
return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN);
}

Could we document that to make it a bit more explicit? Maybe something like

enum hk_type {
/* Set at boot-time via the isolcpus= cmdline argument */
HK_TYPE_DOMAIN_BOOT,
/*
* Updated at runtime via isolated cpusets; strict subset of
* HK_TYPE_DOMAIN_BOOT as it accounts for boot-time isolated CPUs.
*/
HK_TYPE_DOMAIN,
...
}