Re: [PATCH 2/5] cgroup/cpuset: Include offline CPUs when tasks' cpumasks in top_cpuset are updated

From: Michal Koutný
Date: Tue Mar 14 2023 - 13:34:21 EST


Hello Waiman.

On Mon, Mar 06, 2023 at 03:08:46PM -0500, Waiman Long <longman@xxxxxxxxxx> wrote:
> - /*
> - * Percpu kthreads in top_cpuset are ignored
> - */
> - if (top_cs && (task->flags & PF_KTHREAD) &&
> - kthread_is_per_cpu(task))
> - continue;
> + const struct cpumask *possible_mask = task_cpu_possible_mask(task);
>
> - cpumask_and(new_cpus, cs->effective_cpus,
> - task_cpu_possible_mask(task));
> + if (top_cs) {
> + /*
> + * Percpu kthreads in top_cpuset are ignored
> + */
> + if ((task->flags & PF_KTHREAD) && kthread_is_per_cpu(task))
> + continue;
> + cpumask_andnot(new_cpus, possible_mask, cs->subparts_cpus);
> + } else {
> + cpumask_and(new_cpus, cs->effective_cpus, possible_mask);
> + }

I'm wrapping my head around this slightly.
1) I'd suggest swapping args in of cpumask_and() to have possible_mask
consistently first.
2) Then I'm wondering whether two branches are truly different when
effective_cpus := cpus_allowed - subparts_cpus
top_cpuset.cpus_allowed == possible_mask (1)

IOW, can you see a difference in what affinities are set to eligible
top_cpuset tasks before and after this patch upon CPU hotplug?
(Hm, (1) holds only in v2. So is this a fix for v1 only?)

Thanks,
Michal

Attachment: signature.asc
Description: PGP signature