Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp20579rdb; Wed, 17 Jan 2024 15:41:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrn1VEQxHaNYHgE/Ul35yXRlGB3Qf+Q2vekd9hSqAvPOVyIJH9/iyM6Lm7JFql+zjtfjyR X-Received: by 2002:a17:906:79c4:b0:a23:482:ee74 with SMTP id m4-20020a17090679c400b00a230482ee74mr4499082ejo.28.1705534916792; Wed, 17 Jan 2024 15:41:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705534916; cv=pass; d=google.com; s=arc-20160816; b=CXyAod3d0BXZXQbl/vXpcYPr66tkgs7eiaXoTOEhawGQAQyl5oKKkrV6lBddth0v/Z jdA5UQwdCWCj1c2Ev2++U9wVp5gEfrs85lKalzTg8oXWWBXP9R9Cd7AVcDjb1u6VDy/2 Q5RnK//yjP3EgQWnHoqN2lDsU18c0RyByLXztBXh3g08POoejvNb3Cj4KMS+HPSYWXMk nbEHvtcK4E957EH4Swa9B/wE2ESWGZ460Y1XQFIm9TTGc/uQCpAYuDD0f016FTm7GRAa Rk+DY9k9BRBxi/rUGXLbB5EKm3HY84lYUDrW6R7Y0I8Ix8odWSWWjP8hNo66G1b2frY0 FcQA== 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=Nf1/s8K10TSDoTvcJ7yzFPVYZ5HobJbsF9cEHByGorE=; fh=o9jM6dHVkCSZXtG8mwTAzhM+Da81GC95VbCP7paW61I=; b=C/v32vzPMIlrAjtdtqGi3vwmHlCtQyJqTfW4IK9hAu2MKLnSvYRlYNlhdrM/2gBjFf 0X4J739V2LrsQJoBg5op2YA3Dg4lyII5XJrBWpR9L6NIaWOF5qRegtCyyo8Q3wtRTKuN OWaS5B5byIAXRa9nSowOfyzhqOwf3sALco8n5xszCVLKA5vAdnVLxMmRvxSIs3AjuqYS 9JqghP0ILPuEK/Q7ko39s3psJR6+wYZedEIn1GioJIeefTReD5s//YqJ1Tx9lnJFJAWY CZdANp/2nkR14yEZwvJR96ckMZV9/Wf6f4+zEWA1z/2sqZ/KL4/1lkuBkCaiROu5AqWD 3VVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JVwTYqsN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s9-20020a170906168900b00a276e0d85f0si5983719ejd.418.2024.01.17.15.41.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 15:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29555-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=@kernel.org header.s=k20201202 header.b=JVwTYqsN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 8D5201F257A2 for ; Wed, 17 Jan 2024 23:41:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA5D6286B4; Wed, 17 Jan 2024 23:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JVwTYqsN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D17AA2561F for ; Wed, 17 Jan 2024 23:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705534908; cv=none; b=q0hAFlEy4HxIQ0iBeZPkokmy7D+wwXTwpcq76+c6z9uPHvO/QoBaqonL8OVpv6NmTKkDGgsCCGkvOg41nh/zChIeQiMaoovWi4NWMHId+xV1lEGLV3rY5gb8bZAzlHhZzaIYeP2uasKZrwxlS+DlrJ4wpfA/P5Ca+XopPevshv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705534908; c=relaxed/simple; bh=cY79/Cfp9xIflNIDwfUmZ2vm5pn0cwkYXSHLUwKaasQ=; h=Received:DKIM-Signature:Received:X-Gm-Message-State: X-Google-Smtp-Source:X-Received:MIME-Version:References: In-Reply-To:From:Date:X-Gmail-Original-Message-ID:Message-ID: Subject:To:Cc:Content-Type:Content-Transfer-Encoding; b=rxMbIucivtzmKf/E0kOCkER85Cruay17K2ovY+Q4BqbV7koAwEwqN5H1Z3mD+nwEHR26SjvA+BoWeBYi/dPForbFRFa+XJZGEgqjTYuP9lng8ONH60lhADP34i4g8SjZ8hgDu2Pa0X+Ixuxg7ZRtNMXcB+ESyjiYkx7ahYz4RMc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JVwTYqsN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95FAFC433A6 for ; Wed, 17 Jan 2024 23:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705534908; bh=cY79/Cfp9xIflNIDwfUmZ2vm5pn0cwkYXSHLUwKaasQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JVwTYqsNhQmI0YoHxpkxpGD41oMoBmdB5gB6csq63I1W8k3eO4j97Q59XcVo+y3J9 p06o/RNx3V4rGt6wYHkHMCFqD+1MtadTpTH7CstvD8mBnOYGppldPi1rDre7hoyooH xOHFM4HZqRT+olNjR75ncyorWJtChHNy0rGjmjmaxi7SAXs0XTWGWo/WPITTk++I00 3xcKhb6zFSguSfcNla8ajfSCKMuSzkBd9VB76r2idmf9jpOs1PeLjD0yPopxBBmxa+ 7jSwy7dIgDNhcZrt1InB7Eoq5PqzFjnOkMaauBmU431Nmw8xwuPRQa74xZTVAyLjtt DQeEXKfajnkzw== Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2901f9a9d00so39658a91.1 for ; Wed, 17 Jan 2024 15:41:48 -0800 (PST) X-Gm-Message-State: AOJu0YzRiRhUMUieFFGAhr+GZRiQCaSRDehqZK2vmQyO2sPRzKO7pbAw RtL+DuC1f+kWN4pI5lAQrwPY4fqPvWkIJP11K+9DKY6qJpsEkx037WwPGYJ2FNPwPfeCzpGfKPr mGxdSNcTIP6LBR8RUl5EkoWktLzpAx3N9aK0R X-Received: by 2002:a17:90a:12ca:b0:28e:89d2:87ba with SMTP id b10-20020a17090a12ca00b0028e89d287bamr43131pjg.12.1705534907954; Wed, 17 Jan 2024 15:41: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-b4-zswap-lock-optimize-v1-0-23f6effe5775@bytedance.com> In-Reply-To: From: Chris Li Date: Wed, 17 Jan 2024 15:41:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/2] mm/zswap: optimize the scalability of zswap rb-tree To: Yosry Ahmed Cc: Chengming Zhou , Andrew Morton , linux-kernel@vger.kernel.org, Johannes Weiner , linux-mm@kvack.org, Nhat Pham Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Yosry and Chengming, On Wed, Jan 17, 2024 at 10:38=E2=80=AFAM Yosry Ahmed wrote: > > On Wed, Jan 17, 2024 at 1:23=E2=80=AFAM Chengming Zhou > wrote: > > > > When testing the zswap performance by using kernel build -j32 in a tmpf= s > > directory, I found the scalability of zswap rb-tree is not good, which > > is protected by the only spinlock. That would cause heavy lock contenti= on > > if multiple tasks zswap_store/load concurrently. > > > > So a simple solution is to split the only one zswap rb-tree into multip= le > > rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M). This idea= is > > from the commit 4b3ef9daa4fc ("mm/swap: split swap cache into 64MB trun= ks"). > > > > Although this method can't solve the spinlock contention completely, it > > can mitigate much of that contention. Below is the results of kernel bu= ild > > in tmpfs with zswap shrinker enabled: > > > > linux-next zswap-lock-optimize > > real 1m9.181s 1m3.820s > > user 17m44.036s 17m40.100s > > sys 7m37.297s 4m54.622s > > > > So there are clearly improvements. And it's complementary with the ongo= ing > > zswap xarray conversion by Chris. Anyway, I think we can also merge thi= s > > first, it's complementary IMHO. So I just refresh and resend this for > > further discussion. > Sorry I have been radio silent busying on a few refreshments of the xarray on the recent kernel tree. There is an assertion triggered on xarray and the rb tree does not agree with each other. It takes some time to debug. I ironed that out, also glad the assert did catch a bug. Currently the xarray patch should have everything it takes to use RCU read lock. However taking out the tree spinlock is more work than previously. If we are going to remove the tree spinlock, I think we should revert back to doing a zswap tree lookup and return the zswap entry with reference increased. The tree mapping can still decouple from the zswap entry reference count drop to zero. Anyway, my V1 of the xarray patch will not include removing the tree spinlock. > The reason why I think we should wait for the xarray patch(es) is > there is a chance we may see less improvements from splitting the tree > if it was an xarray. If we merge this series first, there is no way to > know. > > Chris, do you intend to send the xarray patch(es) anytime soon? Thanks for the heads up. Let me send it out now. Chris