Re: rcu_dereference() without protection in select_task_rq_fair()

From: Peter Zijlstra
Date: Mon Feb 15 2010 - 04:12:20 EST


On Sun, 2010-02-14 at 09:04 -0800, Paul E. McKenney wrote:

> OK, but doesn't the "preempt_count() != 0" that is in the current version
> of rcu_read_lock_sched_held() already cover this check?

Hmm, yes it should.

> In other words, I believe that I have located a usage of for_each_domain()
> that violates the rule that it may only be called within preempt-disabled
> sections.

>From the trace:

> [<ffffffff81033ec4>] select_task_rq_fair+0xc1/0x686
> [<ffffffff810353f4>] wake_up_new_task+0x1e/0x13e

Which reads like:

void wake_up_new_task(...)
{
...

int cpu __maybe_unused = get_cpu();

#ifdef CONFIG_SMP
/*
* Fork balancing, do it here and not earlier because:
* - cpus_allowed can change in the fork path
* - any previously selected cpu might disappear through hotplug
*
* We still have TASK_WAKING but PF_STARTING is gone now, meaning
* ->cpus_allowed is stable, we have preemption disabled, meaning
* cpu_online_mask is stable.
*/
cpu = select_task_rq(p, SD_BALANCE_FORK, 0);
set_task_cpu(p, cpu);
#endif

...

put_cpu()
}

I cannot see how we can get there without preemption disabled.

--
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/