From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C791C54E71 for ; Wed, 20 Mar 2024 00:26:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BD3B6B0088; Tue, 19 Mar 2024 20:26:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66D936B008C; Tue, 19 Mar 2024 20:26:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 534636B0092; Tue, 19 Mar 2024 20:26:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4243A6B0088 for ; Tue, 19 Mar 2024 20:26:59 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E08811603D5 for ; Wed, 20 Mar 2024 00:26:58 +0000 (UTC) X-FDA: 81915527316.09.8379655 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id F18B6A000D for ; Wed, 20 Mar 2024 00:26:56 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oeU40jhz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710894417; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DbG6uE948bAIFRvB1EKnnMr2HK4pF9FexhL0rt8cJes=; b=aFeoO0kCoKUD+V2/b8otEbfIPJdujS+SExrJekfTjuYdrHS7CeyVsHbGRI89I9zD3/RT8+ a3N0De82U+SJCCyP3NwwDg23IeirFipEtwcFXf818ygKTQST8MO+zb/MMlIpIzk5dmF+15 V9e0XQjwp1oXg7YwHXKKqBM2G3LLkaI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oeU40jhz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710894417; a=rsa-sha256; cv=none; b=OT/Naq4XFw1N7NoU+NtgBokvx8tT2oHWsKOTTF+8aEr07yQRn8D9L3mWt7ErYrTqdXESu/ w87BOWrNK9YXY6flh/IL6iQYc6/h7+kSdg1FPxzFjnIHCllTbfcA6usKADHUU0o2t6EHBi JrWHdIYOuxqez3wsSjWic/GUfED1sT4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ECB0960EFE for ; Wed, 20 Mar 2024 00:26:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87883C43399 for ; Wed, 20 Mar 2024 00:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710894415; bh=laonG8fzc4W0KLfhP/nh9FxfIgaxqhil6/C//Bp4GJs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oeU40jhz/tSdO8fBrm/BjW9wAs6R57+IuguVj+3W/coLupGMdSBELe57dApyEW+Dy aRWXa7NVgwQ7oZgvuuKZLR17yf5g6ge0NthV8fee+pBJTUhWL+9RyVPrsnDMuGPdY/ ZMQdgMA4HCyhNA8NhFctYppAWRYpg5f7sEn32BXjKDYq4UYQggPOb7zk5wHrM5UfBX ge8f7YRPhh0JxhswjWH58uSCgz7Zrq6jxtPHlnVlNzhT5VichIammsGmr2+Thajksh Bwn+bWGB8QuUHSeBpr5+LyEGms6yzOJlHu77MVPEmnMpunvfTRr+reCzy2RGn4DrXd sEfb1bkK/IpUQ== Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-7cc05d36c86so13173839f.1 for ; Tue, 19 Mar 2024 17:26:55 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXSHJeMfLTuaZeuNTIkSSuOOjlg6rY/vfe8AwvuVdvVPOz7Wk6EgrJBino+rfEEiORfJ1MhbW9l6ezxpgT6FYrNLQI= X-Gm-Message-State: AOJu0Yw58eBk2G4CuWc5DDRPDNkAufDFVJTSCmOReSEB63ncnYWaUs/+ ts82Q6bPayLUNHPkW/dlYp54xvyviSyd7HepAZx+pYdjPrxleayQ0ndrbLt9EETiy5WZSiIjeQM M2Z2+YfOUTCFA7mbekHKuDNUA4ywYGSqdk3lm X-Google-Smtp-Source: AGHT+IFGCIu2gy3PVJ5M6fURfHkdTqF0RyxshlZnMRPY1pOkAJ7qwPFuX+07tEMYD1jL3L8CrB5fQrDKMdM2PLaKZMQ= X-Received: by 2002:a05:6e02:ca6:b0:366:b269:f4dc with SMTP id 6-20020a056e020ca600b00366b269f4dcmr4509037ilg.14.1710894414846; Tue, 19 Mar 2024 17:26:54 -0700 (PDT) MIME-Version: 1.0 References: <20240312-zswap-xarray-v6-1-1b82027d7082@kernel.org> <20240316133302.GB372017@cmpxchg.org> In-Reply-To: From: Chris Li Date: Tue, 19 Mar 2024 17:26:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6] zswap: replace RB tree with xarray To: Yosry Ahmed Cc: Johannes Weiner , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nhat Pham , "Matthew Wilcox (Oracle)" , Chengming Zhou , Barry Song , Barry Song , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: F18B6A000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: b333ggfrggriii5hekp6c9njjb4h78qt X-HE-Tag: 1710894416-9439 X-HE-Meta: U2FsdGVkX1/m7CWLl+1CBZstHyaxNxPy5zAaTQrwiD7ikpxlwIhS9mQtE0hBmaenmlYbGybrd0idHCNY5BBXnLbaaaFvLXtqJp+o7TJMJDz0Dn5Enu1s/Tx9zDmfv1YpddDkQUjiHzctw9T0mNom29Rkna/N/ATymlwgKBxcR0yQbwIuBL5p4EL+fVoBTHioH7GQd8RUBRLnpBpHK9wt2Qm2vl0mwUIrWW+c3cMHxsy+0DlrQgNYVE9IHf8s382UNwHGuVTkrEuUZ48Y5JFJYAFf+Rl5vz7g2Hf19p8Fm1JvFAq6UPF+ZyGCibWhqB7swG3Qu+w7POpsGY0zWu+hkWXmGNPZ5Mlfy2/SKwDiwjZhjpBykvdPe639ucoquuNITF5fxjLqkXNf619CaZbfn/3oRcVmEQpV6GKW12cQTcBy9+7RO8PRxmUQEs30biZtYKxRiwrERTEKV50dywrpNz+d928nNJQh8w3k43BmOHceFcxtHaEeLnFv/xzRFx7E+lioXz0uHlUuQbuTaAUwEtfJ6CxRoFT3/AEPmHyiy3JfXY8esfBqBaIbArA02U/u6+REXocGHbWy8C7MWN1iz92w7ElMy/cLMpBUsVrpfWw1/2YseoJkD/uK72F3U/4vrCFlLRUh94Npso+dN7xkHzHBELGXFjNcZB56Jp4hUyq4AHga122rwSoQSf/nn77p8/vfer49eOYCMTVn5tRoPOhyIwAJnrmvvRS8sKXCFVYDgi4woOMni9X8vVMveZwQBCAShFQY9ZPVjqY0DK9QkxItNO7DSPio9MNaeu6VRvjkETjckPHOs1VBz4E7FNqdfBEy3dp04tRSzZMLDVLRw8nj1itUyym1V8bywq98zeDokRn8Vtx4n1NWnI7qrdtg7wSbl7SPrapoytxENFnKhlhdwNleEKVv93ea4X6TQ8QmsDChZWQOT6ht00X6BKBXtAmXP992r/AcSiaEAz/ ez4J1u0P jzx6d+T2HFVHJ1+twJAJ9kZJIsU3Klb6jMNcnyMIfTJAl79s3WO0x0rvo1QNbz0J8HLmrf9bHgnLBWvr7ME8s9K/hklXMdCWK1MnhwVZDdVbwKBLqDLUqGgUykJIwpFFyNMcO+b6kkaZYXCid5EZiOEh2yOYU6kikGCDQQkn0xjkYrf1e/2kQlCMNq4RMmsL5RfXjUsKWMpbhitO4waK5noF78HdomCFNkcb8o8mFFtgemChkCCHXQ3jsAiXgUUkTsH4RjHZ9sa3bCQjThwgJqg7hYx6lyu6cia1pdADgloydz/I= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Mar 16, 2024 at 11:12=E2=80=AFPM Yosry Ahmed wrote: > > On Sat, Mar 16, 2024 at 6:33=E2=80=AFAM Johannes Weiner wrote: > > > > On Fri, Mar 15, 2024 at 06:30:37PM -0700, Yosry Ahmed wrote: > > > [..] > > > > > > > > @@ -1555,28 +1473,35 @@ bool zswap_store(struct folio *folio) > > > > insert_entry: > > > > entry->swpentry =3D swp; > > > > entry->objcg =3D objcg; > > > > - if (objcg) { > > > > - obj_cgroup_charge_zswap(objcg, entry->length); > > > > - /* Account before objcg ref is moved to tree */ > > > > > > > > > I do not understand this comment, but it seems to care about the > > > charging happening before the entry is added to the tree. This patch > > > will move it after the tree insertion. > > > > > > Johannes, do you mind elaborating what this comment is referring to? > > > It should be clarified, updated, or removed as part of this movement. > > > > Wait, I wrote that? ^_^ > > Well, past Johannes did :) > > > > > The thinking was this: the objcg reference acquired in this context is > > passed on to the tree. Once the entry is in the tree and the > > tree->lock released, the entry is public and the current context > > doesn't have its own pin on objcg anymore. Ergo, objcg is no longer > > safe to access from this context. > > > > This is a conservative take, though, considering the wider context: > > the swapcache itself, through folio lock, prevents invalidation; and > > reclaim/writeback cannot happen before the entry is on the LRU. > > Actually, I think just the folio being locked in the swapcache is > enough protection. Even if the entry is added to the LRU, the > writeback code will find it in the swapcache and abort. > > > > > After Chris's patch, the tree is no longer a serialization point for > > stores. The swapcache and the LRU are. I had asked Chris upthread to > > add an explicit comment about that. I think once he does that, the > > objcg situation should be self-evident as well. > > Perhaps it should be clarified that the swapcache on its own is enough > protection against both invalidation and reclaim/writeback, and the > entry not being on the LRU is *additional* protection on top of that > against reclaim/writeback. Right? > > > > > So in the next version, please just remove this now stale one-liner. > > Thanks for confirming. Chris, please remove this comment and update > the comment Johannes asked you to add as mentioned above. Thanks! Will do. Chris