[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241113140914.GI35230@nvidia.com>
Date: Wed, 13 Nov 2024 10:09:14 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Uros Bizjak <ubizjak@...il.com>
Cc: Arnd Bergmann <arnd@...db.de>,
Suravee Suthikulpanit <suravee.suthikulpanit@....com>,
linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
Joerg Roedel <joro@...tes.org>, Robin Murphy <robin.murphy@....com>,
vasant.hegde@....com, Linux-Arch <linux-arch@...r.kernel.org>,
Kevin Tian <kevin.tian@...el.com>, jon.grimm@....com,
santosh.shukla@....com, pandoh@...gle.com, kumaranand@...gle.com
Subject: Re: [PATCH v10 05/10] iommu/amd: Introduce helper function to update
256-bit DTE
On Wed, Nov 13, 2024 at 03:06:05PM +0100, Uros Bizjak wrote:
> On Wed, Nov 13, 2024 at 2:20 PM Jason Gunthorpe <jgg@...dia.com> wrote:
> >
> > On Wed, Nov 13, 2024 at 01:50:14PM +0100, Arnd Bergmann wrote:
> > > On Wed, Nov 13, 2024, at 13:03, Suravee Suthikulpanit wrote:
> > > >
> > > > +static void write_dte_upper128(struct dev_table_entry *ptr, struct
> > > > dev_table_entry *new)
> > > > +{
> > > > + struct dev_table_entry old = {};
> > > > +
> > > > + old.data128[1] = __READ_ONCE(ptr->data128[1]);
> > >
> > > The __READ_ONCE() in place of READ_ONCE() does make this a
> > > lot simpler. After seeing how it is used though, I wonder if
> > > this should just be an open-coded volatile pointer access
> > > to avoid complicating __unqual_scalar_typeof() further.
> >
> > I've been skeptical we even need the READ_ONCE. This is all under a
> > lock, what is READ_ONCE even protecting against? It is safe to double
> > read.
>
> Even without atomicity guarantee, __READ_ONCE() still prevents the
> compiler from performing unwanted optimizations (please see the first
> comment in include/asm-generic/rwonce.h) and unwanted reordering of
> reads and writes when this function is inlined. This macro does cast
> the read to volatile, but IMO it is much more readable to use
> __READ_ONCE() than volatile qualifier.
Yes it does, but please explain to me what "unwanted reordering" is
allowed here?
Again, this is all under a lock so ptr->data128 is fully stable and
not changing.
Jason
Powered by blists - more mailing lists