Re: [PATCH 1/4] sched/numa: Track per-process automatic NUMA balancing mode

From: Chen Yu

Date: Tue Oct 13 2026 - 06:17:21 EST


On Tue, Sep 08, 2026 at 08:24:43PM +0800, Li Zhe wrote:

[ snip ]

> +int task_numa_balancing_set_current(bool enabled)
> +{
> + static DEFINE_MUTEX(task_numa_balancing_mutex);
> + struct task_struct *t;
> + unsigned long flags;
> + bool old_enabled;
> +
> + guard(mutex)(&task_numa_balancing_mutex);
> +
> + if (WARN_ON_ONCE(!lock_task_sighand(current, &flags)))
> + return -ESRCH;
> +
> + old_enabled = current->signal->numa_balancing_enabled;
> + if (old_enabled != enabled)
> + WRITE_ONCE(current->signal->numa_balancing_enabled, enabled);
> +
> + unlock_task_sighand(current, &flags);
> +
> + if (old_enabled != enabled) {
> + sched_numa_balancing_change_task(current, enabled);
> + read_lock(&tasklist_lock);

I wonder if we can use the RCU read lock instead to avoid being blocked by
/blocking the fork && exec, which grabs the write lock of tasklock_lock.
Agents do frequent fork/exec, so we may want to avoid interfering with them?

thanks,
Chenyu