Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1229479rdb; Fri, 19 Jan 2024 12:04:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqr5/7Nxqdsw9N/oId1UK3Sd0kZn/JuFU7oy6ihbuhYujgY8MmVK1mLcK5m8HKfaBb6gyR X-Received: by 2002:a67:ff87:0:b0:467:fe71:1208 with SMTP id v7-20020a67ff87000000b00467fe711208mr310478vsq.63.1705694699321; Fri, 19 Jan 2024 12:04:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705694699; cv=pass; d=google.com; s=arc-20160816; b=ZMhvXHHXBHo2NYy0V5kpFfNmbs9iR+Tke3E2ihGdK70vGaDp2oGzq8wAeFb0lvgS0r VS4mW291ilcR4qIYw8nhxR7IYqAklgiVZmiqbb69YogaHi+DJ08s1dCW9iLhVBcy317h 8SU5yNibZTrutV4wRJSIJZG4i5AJKX/FdU6LefVYwKv/wH9Cywm9DhRd934fmhoq/qHO WuYiAN0nSSSoJWXLS8rCHCe6S0C7xHOyEngtsRDLoXK5qOgBn+dJ/8CbHVfnKO1J7Sc+ bqqRHF+OlOoolHJejGV3lhPxe6W6zWQlXiEWXRVo8QTFtaf8nd60UcDrBSqwk3Qmg+24 tZRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=u2Ngzertxgs5wbvnUqRoc+yVez0IqvvAyWKyMwIxbh0=; fh=Kq+j82KAzmGmQWFXLzKYJ5gjhox7wFalgIKwAznV6qI=; b=HOcwhBOQ9bvJUGfD5B/Pip6QSauW85mu0/mMeHLRkbkbq81BQBRwtU0Je/PWAg+vfS 06HwEH8/FSoG9yeiMpA/1dxE9SuAuMg8PamTipRv9ANZZ/DLPsXeambHq+ov268YUbVu smayt6mv2Etu7OXkIBw6iMnr42JIe2jzqQWqGBwsBWXqTXe0/r4V4i77Fxm51Mn87WR8 E+7LN1Eqo4xWwMOFMsvnKMFeIM+JIh4ZaqxnvR4IFxRpHRwQzzmoXRrWs+YzoKLIT4e3 45CZ811iAYS+vrGwMb2KAHSRI8X4Li11RKfjkMj6xL/CGhz+ALMd079c6H7mCBMm/L9x 33lw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZEwr7WIk; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-31529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31529-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m8-20020a67ed48000000b00467010a8345si1928027vsp.303.2024.01.19.12.04.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 12:04:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZEwr7WIk; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-31529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31529-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 14AB51C231C9 for ; Fri, 19 Jan 2024 20:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C9E356B80; Fri, 19 Jan 2024 20:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZEwr7WIk" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D19A756B67 for ; Fri, 19 Jan 2024 20:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705694692; cv=none; b=PBRNWr8Dc+xTwvZ4ovVacqREKyBLDJFOt7O6Y7kJM/U13jKypCh/+y5xJoJrdJQc21eaX0UKRdcbKG05CY/1eInOI3829Fxw9lyn/+06eb9Ziojrttoe0Az0qcjL0wS/pOqNCjPZAk72x1/J9aDqv4PG+kPNI9o45MaMxA1boR0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705694692; c=relaxed/simple; bh=1jXHQP7UTMnFwVBm1ubhhVIB166fwDCh0qe4WUKBmTY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NWG75Q0eO1znOnKzefhHVB8ZwxkwbGLLEpOiVj8kcmgTM/al8ne4GTEzEn1qE/0bnkjXgKqAkwTW2PamVhNgCmPgslrUz3Q5bHirUkuGvMgmDD96D7nqVJ4R+RRGT4VwwslbDJVfY0jgFflkpVnbGCY+0gLctw6Z7oVjvPX7ubI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ZEwr7WIk; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=u2Ngzertxgs5wbvnUqRoc+yVez0IqvvAyWKyMwIxbh0=; b=ZEwr7WIk9ZlwFowRWogNHvF9ce HkQAUSB9FvijMpXdW7VWoHMyVoqz2QvsHCseEsdCjSKBYqemQ7dOQbOGElE1I/iTebJK0wFNnfc0a ar3IIrh/m1qezdYgMIPIlwELmOWJJ5IVYVbv8GxW0QOUNHphM16vu/8l8nvHukkJNdFseWaeATu9f 6TFhR3AR6mU3RotDjMJkT7rPzyAWEi7GlVdGoEq3L6Y3p1ol90hJMdaEZTm8HQiPKS2mBlPwfPvjR MrwHh4rIwKrMDXW9iafpZL5RlJavkguUpNLInO0tYVbvbU1/insRWQX4TEdFrraiE7LRz3x/m/zmP G0qMV1MA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rQv6O-00000006SWw-1SEY; Fri, 19 Jan 2024 20:04:32 +0000 Date: Fri, 19 Jan 2024 20:04:32 +0000 From: Matthew Wilcox To: Yosry Ahmed Cc: Chris Li , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei =?utf-8?B?WHXvv7w=?= , Yu Zhao , Greg Thelen , Chun-Tse Shao , Suren =?utf-8?B?QmFnaGRhc2FyeWFu77+8?= , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song , "Liam R. Howlett" , Joel Fernandes , Chengming Zhou Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap Message-ID: References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> <20240117-zswap-xarray-v1-1-6daa86c08fae@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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().