Re: [PATCH v5 4/5] cpusets: Update tasks' cpus_allowed mask uponupdates to root cpuset

From: Srivatsa S. Bhat
Date: Thu May 24 2012 - 06:34:38 EST


On 05/24/2012 02:43 PM, Peter Zijlstra wrote:

> On Thu, 2012-05-17 at 22:33 +0530, Srivatsa S. Bhat wrote:
>> + /*
>> + * Restore only the top_cpuset because it has to track
>> + * cpu_active_mask always.
>> + * (We don't need to do anything if we come here during resume
>> + * from suspend, since top_cpuset.cpus_allowed will already be
>> + * equal to cpu_active_mask.)
>> + */
>> + if (root == &top_cpuset && !cpumask_equal(root->cpus_allowed,
>> + cpu_active_mask)) {
>> + mutex_lock(&callback_mutex);
>> + cpumask_copy(root->cpus_allowed, cpu_active_mask);
>> + mutex_unlock(&callback_mutex);
>> + update_tasks_cpumask(root, NULL);
>> + }
>
> This looks absolutely broken.
>
> Suppose I set an explicit cpu affinity mask on my task, which per not
> using cpusets is in the root group.
>
> If I then do a hotplug cycle, I'll find my affinity mask is lost.
>


Sorry, my bad, I hadn't considered that. Thanks for pointing it out!

So, I am wondering how we ought to deal with CPU hotplug for tasks attached
to the root cpuset..

Considering tasks attached to the root cpuset, if a cpu present in a task's
cpus_allowed mask goes offline, it should be removed from that mask right?
And if that cpu comes back online, it should not be put back to the task's
cpus_allowed mask (just like we don't put back cpus in non-root cpusets).

Is the above understanding correct?

In the current kernel, during cpu hotplug, we don't touch cpus_allowed mask
of the tasks attached to the root cpuset at all.. Whereas we update the
cpus_allowed mask of tasks belonging to non-root cpusets, during cpu offline.

So, is this differentiation intended?

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/