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 E60B1C47077 for ; Thu, 18 Jan 2024 07:28:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 762936B0099; Thu, 18 Jan 2024 02:28:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 713286B009A; Thu, 18 Jan 2024 02:28:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DA3F6B009B; Thu, 18 Jan 2024 02:28:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4A6196B0099 for ; Thu, 18 Jan 2024 02:28:41 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 16DAA140557 for ; Thu, 18 Jan 2024 07:28:41 +0000 (UTC) X-FDA: 81691604442.30.C6DCD66 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 79DA4100011 for ; Thu, 18 Jan 2024 07:28:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dndPNy9V; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 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=1705562919; 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=Q4W73qGRou9IGq3hjJrftt/KTtPOdqFsTzXiRX/xyJE=; b=ALrJdSKM1LhO9y3aqC/qHGfh781BtD0ZaOMHTkI6AaZE9OSDOHuvEDONA8z7KDQDKFdFNi ECWu5N9g+dqpi9xeeFgNrxb54+gfDpCJY3V1mZBTz85tpcYjST+2W350v+9Rhr5Xe1RnOw e42qm260r/40fTp9FOVthAlyOu34NuQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dndPNy9V; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705562919; a=rsa-sha256; cv=none; b=Cj0UueN6PN+A7Xr22EVKIu+XOl9H0kGguTbuMX4XKIs8KRG7FCbLb7fUbIcres/c8TIDgf ZvH4Ta+C1kcKW+5EIWgiTPrb9PdnRQrwtqwrN9N0wcPe5v9CY7mgjq0LnA71wslWjiuKSe L2C/sZzkodCxe+EOR1Nw5UTBrAimL0M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 06F66CE1ED5 for ; Thu, 18 Jan 2024 07:28:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88A32C4166A for ; Thu, 18 Jan 2024 07:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705562912; bh=Q4W73qGRou9IGq3hjJrftt/KTtPOdqFsTzXiRX/xyJE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dndPNy9VJENMWrIKU2nCk5fC4X0VE+7job5eWhxWkfIfUsyr+MHu6dQhDn76BKxxL 8YFfaVZ+lz4/bArAngZSIsd6w825idl4a4MWVKTdfd87WRyouNp84snfvEWUNXlrK2 6qEK8a9yXOml2xrIV/+npFbUZiAV+9VZxUv71SXwcw4jW3QB19aNXqOEZDeKRf6h75 Mwp5KFYZDZATcQfEDBNX3aovFDFYTf9bNy/CKmzYgt65fPxpylvN+fxttxgNwVMwNf HfdPykCLMr2hcCQm9okjrLNM954PWz77MmOcPF8bbc44g5Mwojkg/aCgf7vpbGt7nl lR/nCoHj6hCJw== Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6db786df38dso3707151b3a.0 for ; Wed, 17 Jan 2024 23:28:32 -0800 (PST) X-Gm-Message-State: AOJu0YzS7RmbAN7RuezMykZDBPFyoPwIhpzMk/ZkL6WKOd+bOYvLtVuA 1PXO4c1HtOp/WglZoh6YZpp7iSYr87J3XFYe+tCNKtgeOqKIWwAs9R8h+D5DqDrvjyuXvHI7US7 djUmrKoTu2iwLGO1zFgEqJKBJY6w+i4BDOq44 X-Google-Smtp-Source: AGHT+IEFemehfe6/DrMAtEG1vHhXUhrk5g2FOHwJRKu30v09T4UMg5r5CLMLptOB1U7v9XuMrZyw0+GtWyo3BdDb7Lc= X-Received: by 2002:a05:6a20:d80c:b0:19a:4073:e178 with SMTP id iv12-20020a056a20d80c00b0019a4073e178mr526568pzb.25.1705562911908; Wed, 17 Jan 2024 23:28:31 -0800 (PST) MIME-Version: 1.0 References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> In-Reply-To: From: Chris Li Date: Wed, 17 Jan 2024 23:28:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/2] RFC: zswap tree use xarray instead of RB tree To: Yosry Ahmed Cc: 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 , "Matthew Wilcox (Oracle)" , "Liam R. Howlett" , Joel Fernandes , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 79DA4100011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dd4su3byxmpf7z19nkyxx67yc4yypu9q X-HE-Tag: 1705562918-695424 X-HE-Meta: U2FsdGVkX1+AtAHAOEQMWhJx5d62NtJuU8cFP3PJpgB9oDno3rMAuUFhDaJAHd0a2qLOeldc2CLNVlfL1qymi57Xi+CTdq9DsWzwtCSL5fw0h8pzxvC6QsOGZwIjVyAclyBFDLCeKxdkqNEKKnxItfTY40CF7mi7HrjmL3YzrM5ktInppOySYykXObLLLwrr2DBwu50uRmLu97xQS7ZWuJtosE0r6PFgaXtsoRIY4NbQM7WGK80p9nalXmVlJ2psoK0Vq1nIpTqL6DJltYLQKIStCBl7KgfVA/BLFMpb2tsdjHkuXxak7HQGbsXcer1qcEQAHtMGy87XysaErr0wtmki6C+W4NrJ5mcf8juvZl3JFX2cAwskstaJ8gYWfNTKhbfKzBDMK9UIFMnlQUzrl2KhoD58eaSq4m429ZGH513OtTXVCScDkIwVsySm19iyjXkBtGc1UOsn9K3xAGoqLvdwI+ygCAVxGibYk+0vxMO10xA/ymNngPK7fFNYnT12GunFaCQa/LPEziGUgkg5bHwLw5DsKgradEkfgPYU3I4VnzySrg1wfFD/9E0ruxONtIOPzyrEAg1vJM0Z9tuSc1Vzd1kibaxh+FnDUkBl0Qh/2P8Nfn7IfC/TJC4nDmpgyosmhrPnjBizJFKLxdGj9bM8Tdj+gktByQMtI3vpgSkAElJaGrXzYdtfEHHhqDEulBoDEthaYK4J90N1KXTSmlb6uaw0XzQQKY36Pv842iLbJgqFbAuVgAgceSAD9AIbGp5bzIxavBv/KItd3cI9VPhey/Dzd6agsqoJQOVDc9OrCMiFXqr/Ogx6WopJnZBIVj3VqEbcZArQhJ0O0grSox6xoL0QLexyPQBY4iYJsRtswB28OCyf4DYvVMsEytAYss+ZKSxSsAZbxrCB9tEjNY68TyLgjRmB+SFXdPdCf2qZcsPH3JGm9VmjsO8lQbXz6+CEFtw3ImRsnF7z5Ep wpQ21xh/ aB5/zfzaoekLWGAvfjZNuhseAFe7DA1m5YK2gORWQH0E+ZvQSNcxE37Gr/tySMgR1w0I4j3mZ9sU/LSEyTlPagXKDQsxy5BBsPmfTgfMsMRrsn/YoT956H1HH6j3XVUkRCeKHIAq1L9M7F1mhWKgpPg3288jBA9WZwDFmRJG9SCnR8L0JM5iBK7NUKVneXGXZhbJE9BzGdg7bwM6jla010iWjFSFzy6PbMJsYCeWmz4AxEuPcIwkr/h/RMg== 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 Wed, Jan 17, 2024 at 11:05=E2=80=AFPM Yosry Ahmed wrote: > > The name changes from Chris to Christopher are confusing :D > > > > > I think it makes the review easier. The code adding and removing does > > not have much overlap. Combining it to a single patch does not save > > patch size. Having the assert check would be useful for some bisecting > > to narrow down which step causing the problem. I am fine with squash > > it to one patch as well. > > I think having two patches is unnecessarily noisy, and we add some > debug code in this patch that we remove in the next patch anyway. > Let's see what others think, but personally I prefer a single patch. > > > > > > > > > > > > I expect to merge the zswap rb tree spin lock with the xarray > > > > lock in the follow up changes. > > > > > > Shouldn't this simply be changing uses of tree->lock to use > > > xa_{lock/unlock}? We also need to make sure we don't try to lock the > > > tree when operating on the xarray if the caller is already holding th= e > > > lock, but this seems to be straightforward enough to be done as part > > > of this patch or this series at least. > > > > > > Am I missing something? > > > > Currently the zswap entry refcount is protected by the zswap tree spin > > lock as well. Can't remove the tree spin lock without changing the > > refcount code. I think the zswap search entry should just return the > > entry with refcount atomic increase, inside the RCU read() or xarray > > lock. The previous zswap code does the find_and_get entry() which is > > closer to what I want. > > I think this can be done in an RCU read section surrounding xa_load() xa_load() already has RCU read lock inside. If you do that you might just as well use some XAS API to work with the lock directly. > and the refcount increment. Didn't look closely to check how much > complexity this adds to manage refcounts with RCU, but I think there > should be a lot of examples all around the kernel. The complexity is not adding the refcount inside xa_load(). It is on the zswap code that calls zswap_search() and zswap_{insert,erase}(). As far as I can tell, those codes need some tricky changes to go along with the refcount change. > > IIUC, there are no performance benefits from this conversion until we > remove the tree spinlock, right? The original intent is helping the long tail case. RB tree has worse long tails than xarray. I expect it will help the page fault long tail even without removing the tree spinlock. Chris