(3) schedule() makes fallback and cpuset_cpus_allowed_fallback
change task->cpus_allowed
I'm failing to see how this is happening, surely that kthread isn't
actually running that early?
If my understand correctly, current call graph is below.
kernel_init()
smp_init();
cpu_up()
... cpu hotplug notification
kthread_create()
sched_init_smp();
So, cpu hotplug event is happen before sched_init_smp(). The old rule is,
all kthreads of using cpu-up notification have to use kthread_bind(). It
protected from sched load balance.
but, now cpuset_cpus_allowed_fallback() forcedly change kthread's cpumask.
Why is this works? the point are two.
- rcu_cpu_kthread_should_stop() call set_cpus_allowed_ptr() again
periodically.
then, it can reset cpumask if cpuset_cpus_allowed_fallback() change it.
my debug print obseve following cpumask change occur at boot time.
1) kthread_bind: bind cpu1
2) cpuset_cpus_allowed_fallback: bind possible cpu
3) rcu_cpu_kthread_should_stop: rebind cpu1
- while tsk->rt.nr_cpus_allowed == 1, sched load balancer never be crash.
Seems rcu_spawn_one_cpu_kthread() call wake_up_process() directly,
which is under hotplug event CPU_UP_PREPARE. Maybe it should be
under CPU_ONLINE.