From: Lance Yang <ioworker0@gmail.com>
To: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Vlastimil Babka <vbabka@suse.cz>,
Pavel Tatashin <pasha.tatashin@soleen.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm,memory_hotplug: {READ,WRITE}_ONCE unsynchronized zone data
Date: Wed, 22 May 2024 17:20:08 +0800 [thread overview]
Message-ID: <CAK1f24=fNFPyGCh+sxsq-Gg6BkD5qH=z+Ur2UD8+4CRZYoZc6g@mail.gmail.com> (raw)
In-Reply-To: <Zk2vDeQ3feZ3hsf0@google.com>
On Wed, May 22, 2024 at 4:38 PM Brendan Jackman <jackmanb@google.com> wrote:
>
> Hi Lance, thanks for taking a look.
>
> On Wed, May 22, 2024 at 12:25:30PM +0800, Lance Yang wrote:
> > Hi Brendan,
> >
> > On Tue, May 21, 2024 at 8:57 PM Brendan Jackman <jackmanb@google.com> wrote:
> > > @@ -1077,7 +1081,7 @@ void adjust_present_page_count(struct page *page, struct memory_group *group,
> > > */
> > > if (early_section(__pfn_to_section(page_to_pfn(page))))
> > > zone->present_early_pages += nr_pages;
> > > - zone->present_pages += nr_pages;
> > > + WRITE_ONCE(zone->present_pages, zone->present_pages + nr_pages);
> >
> > I'm not sure that using the WRITE_ONCE() wrapper would prevent load tearing
> > on 'zone->present_pages', but it's probably just me overthinking it :)
>
> Hmm.. this isn't for load-tearing, it's for store-tearing. I have a
> feeling I might be missing your pont here though, can you elaborate?
Sorry, my explanation wasn't clear :(
I'm a bit confused about whether 'WRITE_ONCE(zone->present_pages,
zone->present_pages + nr_pages);'
is equivalent to the following:
1 a = zone->present_pages + nr_pages;
2 WRITE_ONCE(zone->present_pages, a);
If so, is there any possibility of load tearing on
'zone->present_pages' in line 1?
>
> I have just noticed that the original "big bad optimizing compiler"
> article[1] only says store-tearing has been observed in the wild when
> the value being stored can be split into immediates (i.e. is
> constant). But it doesn't really seem wise to rely on that. From what
> I can tell from tools/memory-model/Documentation you are really out in
> the wild with unmarked accesses.
>
> [1] https://lwn.net/Articles/793253
Thanks for clarifying!
Lance
next prev parent reply other threads:[~2024-05-22 9:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 12:57 [PATCH 0/2] Clean up hotplug zone data synchronization Brendan Jackman
2024-05-21 12:57 ` [PATCH 1/2] mm,memory_hotplug: Remove un-taken lock Brendan Jackman
[not found] ` <78e646af-e8b5-4596-8fbf-17b139cfdddd@redhat.com>
2024-05-22 14:27 ` Brendan Jackman
2024-05-22 15:24 ` David Hildenbrand
2024-05-24 12:02 ` Brendan Jackman
2024-05-27 7:53 ` David Hildenbrand
2024-05-21 12:57 ` [PATCH 2/2] mm,memory_hotplug: {READ,WRITE}_ONCE unsynchronized zone data Brendan Jackman
2024-05-22 4:25 ` Lance Yang
2024-05-22 8:38 ` Brendan Jackman
2024-05-22 9:20 ` Lance Yang [this message]
2024-05-22 10:10 ` Brendan Jackman
2024-05-22 11:23 ` Lance Yang
2024-05-22 8:42 ` Brendan Jackman
2024-05-22 14:05 ` David Hildenbrand
2024-05-22 14:11 ` Brendan Jackman
2024-05-31 16:41 ` Brendan Jackman
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='CAK1f24=fNFPyGCh+sxsq-Gg6BkD5qH=z+Ur2UD8+4CRZYoZc6g@mail.gmail.com' \
--to=ioworker0@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=david@redhat.com \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=osalvador@suse.de \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
--cc=vbabka@suse.cz \
/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