Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp640630lqb; Sat, 16 Mar 2024 23:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD/2mZFbiWggvlLl8qVJ6YlSCYwNu+soa13CiGnnWtchjISEiVeROJXpWYJaRRBPiDg6XBX0yWwyei8AaI2cUg1eBBnwrkt+GUdlVkTQ== X-Google-Smtp-Source: AGHT+IFTDIk5oiQr8w7Itx0w3gcfYFW+I9VTXeDhEkoZ7dbbwfwMkJh6c/EWbYSWjnii0NxuAknh X-Received: by 2002:a05:6512:3119:b0:513:2ead:4f86 with SMTP id n25-20020a056512311900b005132ead4f86mr5737377lfb.12.1710655983183; Sat, 16 Mar 2024 23:13:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710655983; cv=pass; d=google.com; s=arc-20160816; b=jHXNx49OmwCZDVmzFq/WzJ9FlDjbuHbUjHi5tMghXrzgBQCPM+KUoAyEPAhZvpQ7i7 s59T/rADUEIROHC/K93NwLDufZxGKaVr49hsihhTrw3ANRSChhIkO8r/XvCX2LnKq9FZ QeOWO6qEhLwr+XpXUxCvPnmUQHhvUkwNblnXGexuAl0AQb5IhiG7x0niQssAlY9Vuw8w 91Pbgvse8areGl4mP84dLbBSeXmwZywW8t7HqIvC2RzhbAvHfL4/Ipi8vkABrJFOeW18 QpTbJfz33vIgiPoFWXm/Kgyd4QaQVTbLIYi3N4D4+46M2OwmHGVAOVqBpsra9FDY9Cgr 2kFg== 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=b1/EUrAw0DouFxLVGsQPEl2eEcK2Kdi+7MtyL3HOCTg=; fh=yZQGD9CKB/jtvqgq4jniA8Kmr2dyBSGLiVoAvP2FI6I=; b=Wyv91eh6bX1qz62muGbNQAt/0qJqNb+g96BlVcBBpcLZUQ8Ne9Wo5bwttNoCihd/LW VkLrIOIFxfsuwJFRvG0QIsyE4102Lv4DiCG8offI7o8f2zdu9ax1U1ssFwZ7FU1a2YcB 5fIO/hr7g4Hxw+ALzvAW+u0R2+0VoKXF8gwCfnZxusP4icWbrf2YgXcQz79aRdI/Yw30 gYOpebQEUzhaKLuayUWXRN+KCFtp23Vw1ZdoSxGPz1oceiIXi8G85hjhDza7WlessxGv /OI/WeuNYXYA8YCE7fh/A1f3iNxZD5LwlwGcYm4SCJTGN6Xd3TYXJY0GOwsLj5J1C6+U oFqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Bjik4FoE; 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-105337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l3-20020aa7d943000000b00568a2f733a1si2959230eds.47.2024.03.16.23.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Mar 2024 23:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Bjik4FoE; 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-105337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105337-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C6CBD1F216BD for ; Sun, 17 Mar 2024 06:13:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF13417984; Sun, 17 Mar 2024 06:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Bjik4FoE" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 5C5BD171A4 for ; Sun, 17 Mar 2024 06:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710655974; cv=none; b=rbne6U1ZNI/PW8papV4C6QsXfkYJdich4Ezp2iXqYcXb4NPsk1XgKx2t9NyjlGhHLidIk37UzgGETUi17+DiB/mf/ZDk0aK8YWMU4tkfqYqboEyUT/wJQwQQPZm33MjFyKaoj/+54MbW0qK3MsxCaiAqcccZQHse1LlW1l4htqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710655974; c=relaxed/simple; bh=nSvcpxIehmX6l6cyameIDwqMlQP0wKA3hl900RFWGe4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EdfvG/bB1+P4GvVo9QxC01Zi/wM1TBFeQ2jq1ZvF8d9o6CzRHPwT+euyvhhzdr5fEW2S0ryGiYY5c/6EeLq62aPSAfbO5Q40BJHE8ACitkRQs20DOw2jAI19igo/bhFTL9f1F+OwLR1E8hTMcfNPaG1nnNvM92jhTCQ+m0c/rwc= 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=Bjik4FoE; arc=none smtp.client-ip=209.85.218.44 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-ej1-f44.google.com with SMTP id a640c23a62f3a-a46ba1a05e0so4399466b.3 for ; Sat, 16 Mar 2024 23:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710655971; x=1711260771; 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=b1/EUrAw0DouFxLVGsQPEl2eEcK2Kdi+7MtyL3HOCTg=; b=Bjik4FoE9t+VuELwMhQ1qPYBRFAQ9mRidR+fDQfqw1QJWIANyZQVS0D8Dq+CReCwPa NOAC3Z2fBkpg3byqrMQEsWai1nd7uNsKD0uxrqiJVxeqczw0fra1xRrZ91UGLppctdvN rLsH2MYut9bfHYfOz4kTZIxTdBHJ6hIFM5n+SZXkCPv2TaRkjRnxUJ41zMnxh9Kl5j06 G40Sr+gJiZAgZ6Zmor56AAug1qb+7Ie7zpChrtAy0hhnjn3jJKc2qDFXZvKAkpbrJ4rq rtptpHr2yIoCOmN4/yR3DhepGlt5rDcuieHXKI828OPDCXmGnGUE/t9GdRtBwCzePG9d SSeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710655971; x=1711260771; 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=b1/EUrAw0DouFxLVGsQPEl2eEcK2Kdi+7MtyL3HOCTg=; b=Lftr/Dfa2IiKncqz7nq63iVd6bf/oEK+VZxTugassQxMVwe7m6MT/BnWj/phN3Pwx2 tOhxAvXW8N10oELGzXbrRZQkYtQP10aC4VR+SDsIxtHuhDkcGBx7IrU9gii7j3BUscCP 9vXpmBHm0y3nv3AgZDNH4sc/3Hqk6XudlHPjZCbsWaLLhTH+tL0dMOcCF1K9488I8yfr FPLBStNH1TxlEeeCxL5Ou/tkHg/ts6mR03v+TAOc3te7UzVko3T0zGzDZQuCISUWmYyX WonpX7HEZffIeMf2iNTzkKUr3ctVzkw/L7YeHmO8wVdZ1oWlV0mcotYRC/CNJ4AmnJgS lZ3w== X-Forwarded-Encrypted: i=1; AJvYcCXIXpGlzj6wZNjJwJiWdRM1q1uXYNyyURdqCMzCMFQA2H0qtL1CwvsXLNY9J9YVYxYWEtTAfaFsknuHecrz9QWkdvZS/MnwjoUObPcj X-Gm-Message-State: AOJu0YwYXv0GwpwaH68QL/1xH+ddHTIL4/1Q2jDOWErGFhNXJvTZFcVn Q5ex5pUdIxijXUnmjSuixvHnEU/LahC9fiQ7W4i93orjzsyl3qDa84Dg1Hd9dhs2e7IOWOxqqBx g3Tx8u5S8sJhiQGRnr2d6SDy77Dy1RG8lt2+6ixy+kuz0sIQHngPn X-Received: by 2002:a17:906:6d46:b0:a46:b8a8:98e9 with SMTP id a6-20020a1709066d4600b00a46b8a898e9mr192482ejt.25.1710655970494; Sat, 16 Mar 2024 23:12:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240312-zswap-xarray-v6-1-1b82027d7082@kernel.org> <20240316133302.GB372017@cmpxchg.org> In-Reply-To: <20240316133302.GB372017@cmpxchg.org> From: Yosry Ahmed Date: Sat, 16 Mar 2024 23:12:13 -0700 Message-ID: Subject: Re: [PATCH v6] zswap: replace RB tree with xarray To: Johannes Weiner , Chris Li Cc: 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 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!