Hello, Tianyi.

On Sun, Sep 06, 2026 at 10:40:29PM +0800, Tianyi Chen wrote:
> +     if (cpu >= 0 &&
> +         (!bpf_cpumask_test_cpu(cpu, cast_mask(mask)) ||
> +          !bpf_cpumask_test_cpu(cpu, p->cpus_ptr)))
> +             cpu = -ERANGE;

The syscall runs with migration disabled. With CONFIG_PREEMPT_RCU,
preemption between selection and this check can make
migrate_disable_switch() narrow p->cpus_ptr to the running CPU, rejecting a
valid selection on another CPU. Please check the requested affinity instead.

> +     SCX_FAIL_IF(sched_getaffinity(0, sizeof(original), &original),
> +                 "Failed to get affinity (%d)", errno);

Please use dynamically allocated masks. The fixed cpu_set_t makes
sched_getaffinity() fail with EINVAL when nr_cpu_ids exceeds 1024, even if
the task only uses low-numbered CPUs.

Thanks.
-- 
tejun

Reply via email to