Re: [PATCH -next] mm: mark a intentional data race in page_zonenum()
From: Qian Cai
Date: Thu Feb 06 2020 - 06:15:00 EST
> On Feb 6, 2020, at 4:04 AM, Jan Kara <jack@xxxxxxx> wrote:
>
> So in this particular case, store tearing is non-issue because we use
> atomic operation to store the value in page_cpupid_xchg_last(). I think it
> would make some sense to use READ_ONCE(page->flags) here to prevent
> compiler from loading page->flags several times - I have hard time finding
> a reason why a compiler would want to do that but conceptually that
> protection makes sense, it is for free performance wise, and will still
> allow KCSAN to find a race in case we ever grow a place that modifies
> page's zone non-atomically (which might be a real problem). And it should
> also silence the KCSAN warning AFAIU.
Ah, read up to 3 bits might be an issue then. Iâll post an alternative version which uses READ_ONCE() just for the old page ( because the new page has not been published yet) in wp_page_copy() then.