Re: [PATCH v3 1/5] iommufd: Add iommufd_object_tombstone_user() helper
From: Xu Yilun
Date: Mon Jun 30 2025 - 03:32:53 EST
> > - while (!xa_empty(&ictx->objects)) {
> > + for (;;) {
> > unsigned int destroyed = 0;
> > unsigned long index;
> > + empty = true;
> > xa_for_each(&ictx->objects, index, obj) {
> > + empty = false;
>
> People like me, who don't know the details of how xa_for_each() and
> xa_empty() work, will ask why "empty = xa_empty()" isn't used here. So
> it's better to add some comments to make it more readable.
>
> /* XA_ZERO_ENTRY is treated as a null entry by xa_for_each(). */
Yes. I try to make it more elaborate:
+ /*
+ * xa_for_each() will not return tomestones (zeroed entries),
+ * which prevent the xarray being empty. So use an empty flag
+ * instead of xa_empty() to indicate all entries are either
+ * NULLed or tomestoned.
+ */
empty = true;
Thanks,
Yilun
>
> Others look good to me.
>
> Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>