Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap
From: Yosry Ahmed
Date: Fri Jan 19 2024 - 17:08:52 EST
On Fri, Jan 19, 2024 at 2:05 PM Chris Li <chriscli@xxxxxxxxxx> wrote:
>
> Hi Yosry,
>
> On Fri, Jan 19, 2024 at 1:41 PM Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote:
> > > if your code is naturally structured so that you delete the entries
> > > after freeing them, you have no reason to call xa_destroy().
> >
> > Thanks for elaborating. Based on this, I believe doing xas_for_each()
> > { zswap_free_entry(); }; xa_destroy(); is both closer to the current
> > code structure and more efficient.
> >
> Can't do that in this case though. Because you get the RCU read lock
> on the tree.
> Other threads can still lookup the xarray (also RCU read lock) and get
> a pointer to the already freed memory.
During swapoff no one should be trying to swapin or swapout, where
would the lookups come from?