linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Qian Cai <cai@lca.pw>
Cc: Matthew Wilcox <willy@infradead.org>,
	Marco Elver <elver@google.com>,
	jhubbard@nvidia.com, ira.weiny@intel.com,
	dan.j.williams@intel.com, jack@suse.cz, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next v2] mm: mark an intentional data race in page_zonenum
Date: Sun, 9 Feb 2020 18:20:08 -0800	[thread overview]
Message-ID: <20200209182008.008c06f1cf4347a95f9de0a5@linux-foundation.org> (raw)
In-Reply-To: <95A69596-D5F9-41EB-84A0-AE32D17FE320@lca.pw>

On Thu, 6 Feb 2020 15:25:41 -0500 Qian Cai <cai@lca.pw> wrote:

> 
> 
> > On Feb 6, 2020, at 3:20 PM, Matthew Wilcox <willy@infradead.org> wrote:
> > 
> > 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().
> 
> Maybe your explanation is better, but I did try to explain the same thing.
> I’ll let Andrew to decide if he would like to update the commit log a bit
> with your wording.

Using data_race() here seems misleading - there is no race, but we're
using data_race() to suppress a false positive warning from KCSAN, yes?

That's a bit hacky.  If this happens rarely then perhaps adding a
suitable comment in page_zonenum() which explains this will suffice. 
But if we keep on abusing data_race() in this fashion then it would be
better to add a new macro for this purpose.



  reply	other threads:[~2020-02-10  2:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 18:30 [PATCH -next v2] mm: mark an intentional data race in page_zonenum Qian Cai
2020-02-06 20:20 ` Matthew Wilcox
2020-02-06 20:25   ` Qian Cai
2020-02-10  2:20     ` Andrew Morton [this message]
2020-02-10  2:41       ` Qian Cai
2020-02-10  4:06         ` Andrew Morton
2020-02-10  7:58           ` Marco Elver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200209182008.008c06f1cf4347a95f9de0a5@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cai@lca.pw \
    --cc=dan.j.williams@intel.com \
    --cc=elver@google.com \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).