lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZarV0Iyq7Wor_Dvc@casper.infradead.org>
Date: Fri, 19 Jan 2024 20:04:32 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Yosry Ahmed <yosryahmed@...gle.com>
Cc: Chris Li <chrisl@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Wei Xu <weixugc@...gle.com>,
	Yu Zhao <yuzhao@...gle.com>, Greg Thelen <gthelen@...gle.com>,
	Chun-Tse Shao <ctshao@...gle.com>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Brain Geffon <bgeffon@...gle.com>, Minchan Kim <minchan@...nel.org>,
	Michal Hocko <mhocko@...e.com>,
	Mel Gorman <mgorman@...hsingularity.net>,
	Huang Ying <ying.huang@...el.com>, Nhat Pham <nphamcs@...il.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Kairui Song <kasong@...cent.com>,
	Zhongkun He <hezhongkun.hzk@...edance.com>,
	Kemeng Shi <shikemeng@...weicloud.com>,
	Barry Song <v-songbaohua@...o.com>,
	"Liam R. Howlett" <Liam.Howlett@...cle.com>,
	Joel Fernandes <joel@...lfernandes.org>,
	Chengming Zhou <zhouchengming@...edance.com>
Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap

On Fri, Jan 19, 2024 at 11:29:42AM -0800, Yosry Ahmed wrote:
> I see, but it's not clear to me if the xarray is being properly
> cleaned up in this case.
> 
> Do we have to call xa_destroy() anyway to make sure everything is
> cleaned up in the xarray? In that case, we can just do that after the
> loop.

You do not need to call xa_destroy().  xa_destroy() exists for two
patterns: first, that you're storing values, not pointers in the tree,
and you can just delete the tree without leaking memory.  second, that
you do xas_for_each() { kfree(p); }; xa_destroy();  that's more
efficient than xas_for_each() { kfree(p); xas_store(NULL); } as it
batches the freeing of the nodes to the end.

if your code is naturally structured so that you delete the entries
after freeing them, you have no reason to call xa_destroy().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ