Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap

From: Chris Li
Date: Fri Jan 19 2024 - 17:05:52 EST


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.

Chris