[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250711213323.GH1951027@nvidia.com>
Date: Fri, 11 Jul 2025 18:33:23 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Xu Yilun <yilun.xu@...ux.intel.com>
Cc: Nicolin Chen <nicolinc@...dia.com>, kevin.tian@...el.com,
will@...nel.org, aneesh.kumar@...nel.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, joro@...tes.org, robin.murphy@....com,
shuah@...nel.org, aik@....com, dan.j.williams@...el.com,
baolu.lu@...ux.intel.com, yilun.xu@...el.com
Subject: Re: [PATCH v4 2/7] iommufd: Add iommufd_object_tombstone_user()
helper
On Fri, Jul 11, 2025 at 11:02:53PM +0800, Xu Yilun wrote:
> > With one nit:
> >
> > > - while (!xa_empty(&ictx->objects)) {
> > > + for (;;) {
Actually just leave this, if xa_empty does work out then the loop
exits quickly, otherwise the break will deal with the tombstones
it.
> > > unsigned int destroyed = 0;
> > > unsigned long index;
> > > + bool empty = true;
> > >
> > > + /*
> > > + * xa_for_each() will not return tomestones (zeroed entries),
> > > + * which prevent the xarray being empty. So use an empty flags
> >
> > Since the first "empty" and the second "empty" are different things,
> >
> > > + * instead of xa_empty() to indicate all entries are either
> > > + * NULLed or tomestoned.
> > > + */
> >
> > let's write something like this (correcting typos too):
> >
> > /*
> > * We can't use xa_empty(), as a tombstone (NULLed entry) would
> ^
> > * prevent it returning true, unlike xa_for_each() ignoring the
> > * NULLed entries. So use an empty flag instead of xa_empty() to
> ^
> s/NULLed/zeroed, are they?
Maybe:
We can't use xa_empty() to end the loop as the tombstones are stored
as XA_ZERO_ENTRY in the xarray. However xa_for_each() automatically
converts them to NULL and skips them causing xa_empty() to be kept
false. Thus once xa_for_each() finds no further !NULL entries the
loop is done.
?
Jason
Powered by blists - more mailing lists