[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ee51c074-c061-4bcb-9bd6-c25e6d286655@lucifer.local>
Date: Wed, 6 Aug 2025 11:37:30 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Pedro Falcato <pfalcato@...e.de>
Cc: Zi Yan <ziy@...dia.com>, wang lian <lianux.mm@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
David Hildenbrand <david@...hat.com>,
Wei Yang <richard.weiyang@...il.com>,
Christian Brauner <brauner@...nel.org>, Jann Horn <jannh@...gle.com>,
Kairui Song <ryncsn@...il.com>, Liam Howlett <liam.howlett@...cle.com>,
Mark Brown <broonie@...nel.org>, SeongJae Park <sj@...nel.org>,
Shuah Khan <shuah@...nel.org>, Vlastimil Babka <vbabka@...e.cz>,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests/mm: fix FORCE_READ to read input value
correctly.
On Wed, Aug 06, 2025 at 11:34:57AM +0100, Pedro Falcato wrote:
> On Tue, Aug 05, 2025 at 08:21:23PM +0100, Lorenzo Stoakes wrote:
> > +cc Pedro
> >
> > On Tue, Aug 05, 2025 at 03:09:54PM -0400, Zi Yan wrote:
> > > On 5 Aug 2025, at 15:00, Lorenzo Stoakes wrote:
> > >
> > > > On Tue, Aug 05, 2025 at 01:51:40PM -0400, Zi Yan wrote:
> > > >> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
> > > >> index c20298ae98ea..b55d1809debc 100644
> > > >> --- a/tools/testing/selftests/mm/vm_util.h
> > > >> +++ b/tools/testing/selftests/mm/vm_util.h
> > > >> @@ -23,7 +23,7 @@
> > > >> * anything with it in order to trigger a read page fault. We therefore must use
> > > >> * volatile to stop the compiler from optimising this away.
> > > >> */
> > > >> -#define FORCE_READ(x) (*(volatile typeof(x) *)x)
> > > >> +#define FORCE_READ(x) (*(const volatile typeof(x) *)&(x))
> > > >
> > > > NIT: but wonder if const is necessary, and also (as discussed off-list
> > >
> > > I just used READ_ONCE() code, but it is not necessary.
> >
> > It's not end of the world though.
> >
> > >
> > > > again :) will this work with a (void) prefixed, just to a. make it clear
> > > > we're reading but discarding and b. to avoid any possible compiler warning
> > > > on this?
> > >
> > > Adding (void) makes no difference, at least from godbolt.
> >
>
> I disagree with adding (void), because volatile being properly propagated into
> the type should hide any Wunused-value warnings (because volatile reads can have
> side effects, so discarding a read is most definitely valid).
Yeah, I just wondered _why_.
I mean this is fine as-is. I believe Andrew's already taken the patch as a
hotfix anyway.
>
> And as I was seeing in https://godbolt.org/z/jnWsET1vx yesterday, GCC (and clang)
> can silently drop the volatile qualifier For Some Reason.
Ack, would love to know why, but don't have the time to explore so was hoping
you/someone else could figure it out and tell me :P
>
> --
> Pedro
Cheers, Lorenzo
Powered by blists - more mailing lists