Re: [PATCH 8/8] sched_ext: idle: Introduce node-aware idle cpu kfunc helpers

From: Tejun Heo
Date: Sun Feb 16 2025 - 11:57:13 EST


Hello,

On Fri, Feb 14, 2025 at 08:40:07PM +0100, Andrea Righi wrote:
...
> const struct cpumask *scx_bpf_get_idle_cpumask_node(int node)
> const struct cpumask *scx_bpf_get_idle_smtmask_node(int node)
> s32 scx_bpf_pick_idle_cpu_in_node(const cpumask_t *cpus_allowed,
> int node, u64 flags)

All other functions have just _node as the suffix. Might as well do the same
here?

> s32 scx_bpf_pick_any_cpu_node(const cpumask_t *cpus_allowed,
> int node, u64 flags)

...
> +__bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask_node(int node)
> +{
> + node = validate_node(node);
> + if (node < 0)
> + return cpu_none_mask;
> +
> +#ifdef CONFIG_SMP
> + return idle_cpumask(node)->cpu;
> +#else
> + return cpu_none_mask;

Shouldn't the UP case forwarded to scx_bpf_get_idle_cpumask()? Wouldn't a
NUMA aware scheduler running on a UP kernel end up specifying 0 to these
calls?

> +__bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask_node(int node)
> +{
> + node = validate_node(node);
> + if (node < 0)
> + return cpu_none_mask;
> +
> +#ifdef CONFIG_SMP
> + if (sched_smt_active())
> + return idle_cpumask(node)->smt;
> + else
> + return idle_cpumask(node)->cpu;
> +#else
> + return cpu_none_mask;

Ditto here.

Thanks.

--
tejun