Re: [PATCH] tick/sched: fix data races at tick_do_timer_cpu

From: Qian Cai
Date: Wed Mar 04 2020 - 06:24:55 EST




> On Mar 4, 2020, at 4:56 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> Worse:
>
> + if (cpu != READ_ONCE(tick_do_timer_cpu) &&
> + (READ_ONCE(tick_do_timer_cpu) != TICK_DO_TIMER_NONE ||
>
> Doing that read twice is just utterly stupid. And the patch is full of
> that :/
>
> Please stop this non-thinking 'fix' generation!

That is an oversight that could easily be fixed. However, blaming about ânon-thinkingâ is rather harsh. Do you know I had spent weeks reading about memory-model.txt and alike just to get better at it?