[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <90ab0b09-0f70-fe6d-259e-f529f4ef9174@nvidia.com>
Date: Thu, 6 Feb 2020 16:27:34 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Qian Cai <cai@....pw>
CC: Jan Kara <jack@...e.cz>, David Hildenbrand <david@...hat.com>,
<akpm@...ux-foundation.org>, <ira.weiny@...el.com>,
<dan.j.williams@...el.com>, <elver@...gle.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: fix a data race in put_page()
On 2/6/20 4:18 PM, Qian Cai wrote:
>> On Feb 6, 2020, at 6:34 PM, John Hubbard <jhubbard@...dia.com> wrote:
>> On 2/6/20 7:23 AM, Qian Cai wrote:
>>>> On Feb 6, 2020, at 9:55 AM, Jan Kara <jack@...e.cz> 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 Marco (I've fixed the typo in his name. --jh) has an idea to enhance KCSAN so as to support this model of
>> access, and/or
>
> A similar thing was brought up before, i.e., anything compared to zero is immune to load-tearing
> issues, but it is rather difficult to implement it in the compiler, so it was settled to use data_race(),
>
> https://lore.kernel.org/lkml/CANpmjNN8J1oWtLPHTgCwbbtTuU_Js-8HD=cozW5cYkm8h-GTBg@mail.gmail.com/#r
>
Thanks for that link to the previous discussion, good context.
>>
>> b) Add a new, better-named macro to indicate what's going on. Initial bikeshed-able
>> candidates:
>>
>> READ_RO_BITS()
>> READ_IMMUTABLE_BITS()
>> ...etc...
>>
>
> Actually, Linus might hate those kinds of complication rather than a simple data_race() macro,
>
> https://lore.kernel.org/linux-fsdevel/CAHk-=wg5CkOEF8DTez1Qu0XTEFw_oHhxN98bDnFqbY7HL5AB2g@mail.gmail.com/
>
Another good link. However, my macros above haven't been proposed yet, and I'm perfectly
comfortable proposing something that Linus *might* (or might not!) hate. No point in
guessing about it, IMHO.
If you want, I'll be happy to put on my flame suit and post a patchset proposing
READ_IMMUTABLE_BITS() (or a better-named thing, if someone has another name idea). :)
thanks,
--
John Hubbard
NVIDIA
Powered by blists - more mailing lists