Re: [linus:master] [mm] 24e44cc22a: BUG:KCSAN:data-race_in_pcpu_alloc_noprof/pcpu_block_update_hint_alloc

From: Tejun Heo
Date: Mon Jul 22 2024 - 13:52:32 EST


On Mon, Jul 22, 2024 at 10:47:30AM -0700, Boqun Feng wrote:
> This looks like a data race because we read pcpu_nr_empty_pop_pages out
> of the lock for a best effort checking, @Tejun, maybe you could confirm
> on this?

That does sound plausible.

> - if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW)
> + /*
> + * Checks pcpu_nr_empty_pop_pages out of the pcpu_lock, data races may
> + * occur but this is just a best-effort checking, everything is synced
> + * in pcpu_balance_work.
> + */
> + if (data_race(pcpu_nr_empty_pop_pages) < PCPU_EMPTY_POP_PAGES_LOW)
> pcpu_schedule_balance_work();

Would it be better to use READ/WRITE_ONCE() for the variable?

Thanks.

--
tejun