Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1279295rdb; Fri, 19 Jan 2024 14:05:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5RswJd4gKYNV/91aty2WU08EQypRN6A4agU3so7K12P26ecAOifuKHMk1av+mXW0PFUU2 X-Received: by 2002:a05:6808:2102:b0:3bd:a807:7fe with SMTP id r2-20020a056808210200b003bda80707femr564217oiw.0.1705701953011; Fri, 19 Jan 2024 14:05:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705701952; cv=pass; d=google.com; s=arc-20160816; b=nm2SMq+T+8J2GncmAd+zSSZSNHq1wUwpr6cK4Mat3+nqlMZeBw3yPWCFXmX4hnTk6Q 5GvOHrvPOYAK942y7ltiddyLBk9Ws388d5DLn9YF/tzSH1umYZzDePn1He73dgBJdjnP pdnAI3Rdmbrp+wIffNT5Dv7B6gVjk6Za9mTuySI9F4g+oXGYqik9R7fhXR1pSYG07KyW Du/oinhMfwtLpv+3Beaw3iPk9Ha0zXN8lX39+vcQPyd5YpxufbFtvKjhv+HrzuqflISn 7N6s9VKOUFPDxnmnOpKYhTV0RV1rmw2IyLDrjMPqlYWdndh06Ktjtqg4o9tqpZ73J3QL GjqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=JvLEJ5iYwm0j9MPbrk2yPdPy/G2pUyzqxjNRaXk3G/Y=; fh=861bKca85e8A0gRrF7xfNDdlWRI0Exbat9Q+Hfjwx1I=; b=lIYwtc0pZkWSs5Sk6lM8WvzC5fDCr55fkOVY4VRWYxGlRPP+z3UqLRNw/5BvZYlmt6 9hpKQZAYzL73aRhhmiV990M+ZkCANVhT1A9TnyCTkQ+47nFnansZLuIzKIvXnsTC5U+h +1VlG8dxuFaVMh8gjYQYO3qOpO4mIKG3rwOSso3zvs13+UBgLeVMPYPBq+lAkVvRRCWI 7sCnMvJ6m3b23rlX98FBlPvuFsKyaDWjzS/Kjq/SqryRmfl64yNfqVR6qTp83yCrbwQf fDSl+pnUXcxqNw5p7jzYSeTcm2mBoUhgtJhl2t67wTtwwjnwMglrZzXELtlaz5IfKA8l OlVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bR29Uwb7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-31601-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w8-20020ab06508000000b007cdd875dfd8si18952uam.114.2024.01.19.14.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 14:05:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31601-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=@google.com header.s=20230601 header.b=bR29Uwb7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-31601-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 B884F1C236C7 for ; Fri, 19 Jan 2024 22:05:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2692658AA9; Fri, 19 Jan 2024 22:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bR29Uwb7" Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F38B58AA3 for ; Fri, 19 Jan 2024 22:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705701949; cv=none; b=HAFiLaowKeZ+DKPav+od0LxKZYT1pPw6whRzyeYdhjQLkbVe1vQPkEm0vcMLdhksXZt9ZZeYnuyDC4avGwhgcuRzLwWHOQDC75J+gPbHal9MsrcftDf8Xoawbed1J4ycmtFi3AkZv4B1ZiOEMOXSo9rJn9ohZriCDs42V2/TA0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705701949; c=relaxed/simple; bh=p1hTh7UD1WJVTA0jl+hmxaQP6FZFEni/5gYHeYnGWcM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=a433nucHdp1938/HoZaNsF0VLzsQ8lpfwfYxRM7WPyI2SXkeJZencjQ+VZc2aKgjkJDsAxSnxVgh2G5g7QzO3xqYY0y2a8tA324dmYLtXmnApNfuWSf/n7CadL+8Qkng3lrtc3o/NP9j1yB+lAPH6Xfs0iJV3SnsAFR7ZkFS0q4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bR29Uwb7; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-28e724d9c47so916020a91.2 for ; Fri, 19 Jan 2024 14:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705701947; x=1706306747; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JvLEJ5iYwm0j9MPbrk2yPdPy/G2pUyzqxjNRaXk3G/Y=; b=bR29Uwb7U3sqnKLcy5PLSBZxTXyNK8i5S8JnNFN2Bg6/UnXHnkRVrKhk+0G9fEGVmW lfGbv4m6bOs5XoWqhW40cX8ed/LyWoR5JR0MsHUGASMVSmi10DB6wTvJM3fardjTKbyL 9snS3RJRaeHu1+yYHoZ00B2sZaCcBOkztC1yfP7AiS0lRWdN4uugD7CRXq6WTG8TlvQF 4TU7WpYSTpDFIIkvwAMv8GznP6cJo28m6AeM2XAuXtUDFrc80S3p0Kmh95z2FB5BLaz/ Cr+BbHeN0zfpO4q9uGmNJud4NlqrgC5lQiC/NEmuk9BEVRUyuWdjLypJzTdDje6ARuFa xAEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705701947; x=1706306747; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JvLEJ5iYwm0j9MPbrk2yPdPy/G2pUyzqxjNRaXk3G/Y=; b=pOoix6tAsrPETZoMT1ONciDywruVKr7w0d/1wUSNtvtdLtwWCil2rfhiFwi15jMKgy GjxPdfsHfmu18u/d/1c+qc+7KuzUUxccUcKW5GokO8odCYRIx5FUGhuQbhQP9oOl81Am vm1B4ImTIE3btmeB4vUIo7k8/iHsTVg1o8YldJGuwvcPC3R1NrGZ73GVOmybyifVa1ER JbNLUJyp0ChKLm3maTd/AlFp/UZKKaUAho9rkjfmaToWbz+FpUW28N6wWzcsorxAQ5K2 Qnhj2ihpMbZjxkhB5/jFDRGHG4rf/Ajz7QdnIIHva5WVPcs2dFNBICGpr5bg3RoRRAab kqyw== X-Gm-Message-State: AOJu0Yytapy7owegQQk1pAKfQCUci6lYaYTGKjQhRbCvdU98sf6RRMKw TRspdJOyXYooDddg8AIe6jEFp0LDLKOETvnZeHmXWz8RCPlOl7XoZotvE1J92o/TlTUJd06M/1F J1VLrE+WoGMy1q1uQRyfa//xq4OED10siSwXPG4oleDmC6q3fmw== X-Received: by 2002:a17:90a:d905:b0:28e:7964:1257 with SMTP id c5-20020a17090ad90500b0028e79641257mr404465pjv.97.1705701947215; Fri, 19 Jan 2024 14:05:47 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> <20240117-zswap-xarray-v1-1-6daa86c08fae@kernel.org> In-Reply-To: From: Chris Li Date: Fri, 19 Jan 2024 14:05:36 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap To: Yosry Ahmed Cc: Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?UTF-8?B?V2VpIFh177+8?= , Yu Zhao , Greg Thelen , Chun-Tse Shao , =?UTF-8?Q?Suren_Baghdasaryan=EF=BF=BC?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Yosry, On Fri, Jan 19, 2024 at 1:41=E2=80=AFPM Yosry Ahmed = 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