Re: [PATCH] mm: fix a data race in put_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/6/20 7:23 AM, Qian Cai wrote:
> 
> 
>> On Feb 6, 2020, at 9:55 AM, Jan Kara <jack@xxxxxxx> wrote:
>>
>> I don't think the problem is real. The question is how to make KCSAN happy
>> in a way that doesn't silence other possibly useful things it can find and
>> also which makes it most obvious to the reader what's going on... IMHO
>> using READ_ONCE() fulfills these targets nicely - it is free
>> performance-wise in this case, it silences the checker without impacting
>> other races on page->flags, its kind of obvious we don't want the load torn
>> in this case so it makes sense to the reader (although a comment may be
>> nice).
> 
> Actually, use the data_race() macro there fulfilling the same purpose too, i.e, silence the splat here but still keep searching for other races.
> 

Yes, but both READ_ONCE() and data_race() would be saying untrue things about this code,
and that somewhat offends my sense of perfection... :)

* READ_ONCE(): this field need not be restricted to being read only once, so the
  name is immediately wrong. We're using side effects of READ_ONCE().

* data_race(): there is no race on the N bits worth of page zone number data. There
  is only a perceived race, due to tools that look at word-level granularity.

I'd propose one or both of the following:

a) Hope that Marcus has an idea to enhance KCSAN so as to support this model of
   access, and/or

b) Add a new, better-named macro to indicate what's going on. Initial bikeshed-able
   candidates:

	READ_RO_BITS()
	READ_IMMUTABLE_BITS()
	...etc...

thanks,
-- 
John Hubbard
NVIDIA




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux