Re: [PATCH -next v2] mm: mark an intentional data race in page_zonenum

From: Matthew Wilcox
Date: Thu Feb 06 2020 - 15:20:12 EST


On Thu, Feb 06, 2020 at 01:30:00PM -0500, Qian Cai wrote:
> Both the read and write are done only with the non-exclusive mmap_sem
> held. Since the read only check for a specific bit range (up to 3 bits)
> in the flag but the write here never change those 3 bits, so load
> tearing would be harmless here. Thus, just mark it as an intentional
> data races using the data_race() macro which is designed for those
> situations [1].

This changelog makes me think you don't really understand the situation.

A page never changes its zone number. The zone number happens to be
stored in the same word as other bits which are modified, but the zone
number bits will never be modified by any other write. So we can accept
a reload of the zone bits after an intervening write and we don't need
to use READ_ONCE().