Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1280632rdb; Fri, 19 Jan 2024 14:08:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IH95L3W5EU7N6cdNQV8WqCyFuSQ+hJaDP6W5mLywpwZ8r/cC7m2qh+AwiyyDpwOEe1vRzHe X-Received: by 2002:ac8:5704:0:b0:42a:2a87:5d91 with SMTP id 4-20020ac85704000000b0042a2a875d91mr533936qtw.74.1705702132792; Fri, 19 Jan 2024 14:08:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705702132; cv=pass; d=google.com; s=arc-20160816; b=Ff1ofJnOdSa9vbEefi7JtrWm40vVD5tl3wV9NknbluS3p+CXNg/RcZchheq5LRre0l SknZ+xOc+xDgl2Dxhr/L7RLGD/fb2LkfBSMnolGks0bFamx59o/nCjcD15FuFv7M/DIG 4URIaldrWJU/5UuwP7miIvGLcCP48s2nAnNp77GKpZ8wxo5L4rJYBjOwupvqFrpPZZzA qrk3HgZxWiKVDBmSFGYuQCoMbVp24GdiksNo+FHv10iKFb+poS1U4M7GkHmTF9nnHtOW im94HvobPiqPsJWpTVXQP0TCitAR6iTl1PedvRCF68EiG9kJvOUdnPeEG5eJmJYECHhe 7UeA== 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=Qbi1G6F8BUFvl4DD/h7+WYMvisIsLuju9f0daY5rOe4=; fh=yfridrn2TSeoGyM4Eq98i5W5PxZCw3RkKP/Hvci9t+w=; b=Koua+4IVoQwqHDMPwm+oDgsIrHjgxNf1ruAumbuVND/rwUqT0tN0fIHGvHPRThq9L0 v32D/NpibDzUVj8GmEciwvKxmNbeF2Uql+qQSk2DQMU8u8vZOTg1cXnwg2qnZLdXyRum xRWU4FPQlet9620b8tCaYBq0LCA55ZlfmgyeDWNVLu/hdH6yXk3w1MhAlx0r8kFkmrFE 3JeSYqaYQbtAfk1+33MyfzhLQ23jZoS+IcVHxxnrHaQreMN5ID6SKM4+2c7qSPXRVY/8 /eONEYCY8tZ5sp2zhdg1PNkSYd4Ykl9Kuvo3Znih0BjOeN7vxPLKdmiPAd34uckVYb0z TbWg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xPZgwrvU; 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-31604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31604-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 g2-20020ac87f42000000b0042a2e27edc4si179296qtk.701.2024.01.19.14.08.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 14:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31604-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=xPZgwrvU; 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-31604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31604-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 8AC621C238ED for ; Fri, 19 Jan 2024 22:08:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45A1758ABF; Fri, 19 Jan 2024 22:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xPZgwrvU" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 F40C354BDA for ; Fri, 19 Jan 2024 22:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705702126; cv=none; b=g9dATKjO05zyMMaPS5bqr0JhQZevZ8lJFuOCjMx8QFZ+lseyNlX5q6Zt0ex4VwJ9EPUZAO0twsWoTjvFMy5a2v64c1Hxh0+xlEgX8g9d/00Vnpxxg0zY4nHMVWRz5vvO0DCf25i64lPFjaB/KZUDPq88lvN2bOG4hkFzZgNqa4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705702126; c=relaxed/simple; bh=I+h5o8ZkdqHgAOD1hCY6AzkDWjWnjqpzJUeO4riFkuc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SEpQlPD5qXXBNrxPPwdUAurtKRGaj9CCMMooONKv4IAtUk9GPOOZV1kmybaJDVpSv9p4l/kHvAuUUpY/xh8DFVvUvz3rW8hDVi2xnKASIfelqgEarvlb4w5dZhT4zwgFIaTkyuZr8akLwv9F/3JgHbjSY8UoFMaZ7DMCg0oQS7E= 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=xPZgwrvU; arc=none smtp.client-ip=209.85.208.51 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-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-559edcee495so1424053a12.3 for ; Fri, 19 Jan 2024 14:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705702123; x=1706306923; 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=Qbi1G6F8BUFvl4DD/h7+WYMvisIsLuju9f0daY5rOe4=; b=xPZgwrvU22DYbkuTzU+V7/8K9FVdiPFOMUfjfx+gZB4+z+T2tqwEftKBwfy04ps5QN OV8NYMoHwoKIhb0BhKRU6PWA5JHgTm/YtNxvQB5NimrZuSvvi3sIli3kUOUsjQIzD9BT rN2PEYq6JMx7OHC4gzAfUjBxRCXmeb0Y3mtX4FbKv9dMve2EtF/rGRlCHf4W2j+Yj1DI p+4AQqmR5drG3/RqUg5vOhgg/GaXIenONJMYRCYsFR5maanvAn9DnsC/LsTsGsb9Hbqp CGbIsJ1CYhtpu7lKo4TFHMSZ2qxzaRdwUnzySNyTQGEbUay84DiOmk9R/xiKgAEtCZQi 9Tqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705702123; x=1706306923; 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=Qbi1G6F8BUFvl4DD/h7+WYMvisIsLuju9f0daY5rOe4=; b=aH6wJgif8ZWPOMbcJPH/7U45AVqTCDL9g6NAItGuVdFODzxQIFWYGJ0fWLGVnZm95F C90uEAACOFJlUeTsqy+wpjNCl5UvpnbEsjVEkbsKTcwggB/yE3IjEl3KVvr1yEDKZQ99 WbsG99mygfJ8JXXRoOt7tSpZvadaej1h7nCyF2FpWt+bEVM4+wcDm5S6gdaUY51zooQV BwvhlRVSD+B3AUNo7RCuz3z5Mp6WVvXUkZBZrs4VcbDI+9gd8N9Jo9Cxj9g2/Z6GB8Bo 6FHYXfnKLBebOLyjbJlWIyghQzhHBc81053My4P+diezZdh/vqGuaQW5hrTnaBnfJNOk iZDw== X-Gm-Message-State: AOJu0YwHgmnV0PYCrMR0FFBe/7iE4La0RTQLccDhgjA6KDJL55tCtkoc dl5OIwXZ/FfoTymEW37pehK/ez4kDAZIDQyoHA2Yn84Nzjou+6QQMeusfZWt3IVdpQCb9kgPFN7 GRFtDqmo8/RD3utjSc75b4UqD9/fmUySvY2AV X-Received: by 2002:a17:907:2812:b0:a27:f465:298c with SMTP id eb18-20020a170907281200b00a27f465298cmr227334ejc.124.1705702122995; Fri, 19 Jan 2024 14:08:42 -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: Yosry Ahmed Date: Fri, 19 Jan 2024 14:08:04 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap To: Chris Li 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 On Fri, Jan 19, 2024 at 2:05=E2=80=AFPM Chris Li wrot= e: > > 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. During swapoff no one should be trying to swapin or swapout, where would the lookups come from?