On Tue, Mar 14, 2023 at 03:02:53PM -0400, Waiman Long <longman@xxxxxxxxxx> wrote:OK, I got it now. I will swap it as suggested.
No effect except better readability (possible_mask comes first in theI don't quite understand what you meant by "swapping args". It is effective+ cpumask_andnot(new_cpus, possible_mask, cs->subparts_cpus);I'm wrapping my head around this slightly.
+ } else {
+ cpumask_and(new_cpus, cs->effective_cpus, possible_mask);
+ }
1) I'd suggest swapping args in of cpumask_and() to have possible_mask
consistently first.
new_cpus = cs->effective_cpus ∩ possible_mask. What is the point of swapping
cs->effective_cpus and possible_mask.
other branch above too, left hand arg as the "base" that's modified).
I see now that it returns offlined cpus to top cpuset's tasks.2) Then I'm wondering whether two branches are truly different wheneffective_cpus may not be equal "cpus_allowed - subparts_cpus" if some of
effective_cpus := cpus_allowed - subparts_cpus
top_cpuset.cpus_allowed == possible_mask (1)
the CPUs are offline as effective_cpus contains only online CPUs.
subparts_cpu can include offline cpus too. That is why I choose that
expression. I will add a comment to clarify that.
Oh, I mistook this for hotplug changing behavior but it's actually forIOW, can you see a difference in what affinities are set to eligibleThis is due to the fact that cpu hotplug code currently doesn't update the
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?)
cpu affinity of tasks in the top cpuset. Tasks not in the top cpuset can
rely on the hotplug code to update the cpu affinity appropriately.
updating top_cpuset when its children becomes a partition root.
IIUC, top cpuset + hotplug has been treated specially because
hotplug must have taken care of affinity regardless of cpuset.
v1 allowed modification of top cpuset's mask (not sure if that
worked), v2 won't allow direct top cpuset's mask modificiation
but indirectly via partition root children.
So this is a continuation for 3fb906e7fabb ("cgroup/cpuset: Don't filter
offline CPUs in cpuset_cpus_allowed() for top cpuset tasks") to ensure
hotplug offline/online cycle won't overwrite top_cpuset tasks'
affinities (when partition change during offlined period).
This looks correct in this regard then.
(I wish it were simpler but that's for a different/broader top
cpuset+hotplug approach.)