Re: [PATCH 04/40] sched: implement __set_cpus_allowed()

From: Tejun Heo
Date: Wed Jan 20 2010 - 03:30:33 EST


On 01/19/2010 05:37 PM, Peter Zijlstra wrote:
> On Tue, 2010-01-19 at 10:07 +0900, Tejun Heo wrote:
>> It's also necessary to guarantee forward progress during CPU_DOWN.
>> The problem with kthread_bind() is that it's not synchronized against
>> CPU hotplug operations. It needs outer synchronization like calling
>> it directly from CPU_DOWN_PREP. I guess it's doable but I think it
>> would be better to simply share the backend implementation between
>> set_cpus_allowed_ptr() and kthread_bind().
> OK, so you're saying you need to migrate the rescue thread during
> cpu-down. That thread is guaranteed sleeping right,

No, it's not. It might have been tasked to process works from other

> if it were not it'd not be elegible to run on our dying cpu. Hence
> kthread_bind() ought to just work, no?

Why wouldn't it be elegible?

Commit e2912009fb7b715728311b0d8fe327a1432b3f79 killed the ability to
bind a kthread to a dead CPU which means that the only differences
between kthread_bind() and set_cpus_allowed_ptr() are...

* Whether to use cpu_online_mask or cpu_active_mask.

* Whether to set or check PF_THREAD_BOUND.

Wouldn't it make more sense to share the backend implementation
between kthread_bind() and set_cpus_allowed_ptr() instead of making
kthread_bind() a special case? The goals of the two functions are
basically identical. Why have two separate implementations?
kthread_bind() implementation as it currently stands is pretty fragile
too. Making kthread_bind() backed by set_cpus_allowed_ptr() will make
it more robust and less error-prone and all that's necessary to
achieve that is modifying sanity checks.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at