Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1849021rdb; Thu, 7 Dec 2023 10:16:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhTHV2mPAWXPdhECfTNuMFXVfqP8x8pZPatg6BO5ZM0JFUjxvkkZyxHfVAuWhsoDlbv+e3 X-Received: by 2002:a17:903:1245:b0:1d0:94fa:ba0e with SMTP id u5-20020a170903124500b001d094faba0emr2664538plh.47.1701972985046; Thu, 07 Dec 2023 10:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701972985; cv=none; d=google.com; s=arc-20160816; b=o0j2RR7lPRVW/K0+piFIoalPFDrl8f45gAQTRedADy87iWOzF0ehWIdgpSRiVPbnbX 0aPPlSvaBadj40//foVoDYIlVnWI43XuMYuI3Zni5dXupzNZ0bquawDAuaPNXBgPwTZB xr3cbYJTdbH6UZzxdsTHX9BmG90suLyApvekZqc9VO4OCZBHt6JkYPL7ltWiS4XS6Inc szVk8ym0IxVeO+tJqrZe+rdSVScc9jtv2I3BFMyDd6RJpqMhhRSKjD1ROVQMryh0RUTi 4nwF4SoBmkK7DrN5NUVLHt1FHvBd7lV02JalKOQjASIGPktTRQTU7gahxiUgN8x2IlNs gFvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=d4OjwNy8mbYcl7XPkSSgPHOa+dg/ygA00wlk4vTz/nQ=; fh=OYyyqLl+7kHm8cIdrlovIOx10UybNbaabSjUs6DJgRA=; b=Kt9A7aJV5f3YbJW8wg6aQxtu+ldcK793e+HMpRKoX+w+VFJKE+Fec5DRjL3mF6XLWz 0NU/ATe2RGdXBiZh0oha8lGVdiL2Hsty9BZxPU7THDb6eWtFSxXFC4rLRtwnJEy2hKdr zZaFVOywKcKBlOy3Z506sZbKTOM6dP0evqID6Vwcg3CwzSs+02OF3eFzK8bvWg4JvYYB v8lAhajcoCBI5KVUqpiZtvVL+uMS10Ea0b9pBAk1wVEBBzYXYtlQhjXwTPfUMdon74OM c8UcD2wG1DZSY6CNNUuaSMTto6/BPh8r6WCla5bOuQodz/zadyu9LWp2GueJEz/erTy3 w6bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LD5pRtYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y2-20020a170902ed4200b001cf9e86314dsi120532plb.637.2023.12.07.10.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 10:16:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LD5pRtYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9251C8088A42; Thu, 7 Dec 2023 10:15:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443464AbjLGSPj (ORCPT + 99 others); Thu, 7 Dec 2023 13:15:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjLGSPi (ORCPT ); Thu, 7 Dec 2023 13:15:38 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9097310E3 for ; Thu, 7 Dec 2023 10:15:44 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7b6f19f3af9so35258339f.3 for ; Thu, 07 Dec 2023 10:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701972944; x=1702577744; 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=d4OjwNy8mbYcl7XPkSSgPHOa+dg/ygA00wlk4vTz/nQ=; b=LD5pRtYKXE8ostzbgZeFos6wUmsjoOh1aRrzvBjfU6/mo6kQn1B6qq5Mm3Dl1DUiHU KKTZRHLRTOQnbR0Vaug0r9TirzbR4416+UdF+tYEHmCUQci9J0k/ipaM32Tjg3/pOzb8 yI5r/fCt+7PKDf730hM60mBa+WPktpkI6UxR/BcaEwKnAGmeS6Vyk9hCEHen53jwVaXm wM1DY8sdoo2Exb6yktHh6KSaNPrlF7ZiEFeTlDfIQZJEWx9OiMEM3tiobaIgqYDg2lHA Xyr4lI8n28yPSjzcQhNxzy6w7mTvp+jTaleO1kEXU6TL+3DXhnkz56gCRA+ZjME9jjGp sY0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701972944; x=1702577744; 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=d4OjwNy8mbYcl7XPkSSgPHOa+dg/ygA00wlk4vTz/nQ=; b=X0KwdHEF9OUj/lT2IadvTiasBESsojQseZdj5EVOqK4cs/abjlu4luH3f9MR+hsN1M ZK5PuPdwmHu46sxrs+bycMStigzr0eGiJR1lgjeNmlCtz52vctY54ieZfkcibA+FRGna wllg8lVvWDj+CnVm4mMEFGis4I8uFTmC6eI4sA+sVw03ixM2CQ7MmEoCzZwXnVGwzsrh KPUnbmVpIJAG15awDSDmuMkmtGYXOnq/0QOa4/nKyBa26Ilxq8K5AyR2nibOg9DEkAaN tY288GALAlnWw0buaZgX25BGYZKHecZRJO2t8l0UDajmBdXJKqopuVTyS7L99lJgai2S U+3A== X-Gm-Message-State: AOJu0Yx2WjJnuK0qfgRn/xtNFh6ZCVZCOmv7Kyut1dtGtZoU2Oi9xgOy HfQqtbTAm1CUOeikS9nnzkJ5vpXBcpbtPzyb+/s= X-Received: by 2002:a05:6602:3981:b0:79f:da3d:c47f with SMTP id bw1-20020a056602398100b0079fda3dc47fmr4069859iob.13.1701972943812; Thu, 07 Dec 2023 10:15:43 -0800 (PST) MIME-Version: 1.0 References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> <6bf18314-7749-476e-aece-064ecfb0dffc@bytedance.com> In-Reply-To: <6bf18314-7749-476e-aece-064ecfb0dffc@bytedance.com> From: Nhat Pham Date: Thu, 7 Dec 2023 10:15:32 -0800 Message-ID: Subject: Re: [PATCH 0/7] mm/zswap: optimize the scalability of zswap rb-tree To: Chengming Zhou Cc: Vitaly Wool , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 07 Dec 2023 10:15:59 -0800 (PST) On Thu, Dec 7, 2023 at 7:18=E2=80=AFAM Chengming Zhou wrote: > > On 2023/12/7 11:13, Chengming Zhou wrote: > > On 2023/12/7 04:08, Nhat Pham wrote: > >> On Wed, Dec 6, 2023 at 1:46=E2=80=AFAM Chengming Zhou > >> wrote: > >>> When testing the zswap performance by using kernel build -j32 in a tm= pfs > >>> directory, I found the scalability of zswap rb-tree is not good, whic= h > >>> is protected by the only spinlock. That would cause heavy lock conten= tion > >>> if multiple tasks zswap_store/load concurrently. > >>> > >>> So a simple solution is to split the only one zswap rb-tree into mult= iple > >>> rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M). This id= ea is > >>> from the commit 4b3ef9daa4fc ("mm/swap: split swap cache into 64MB tr= unks"). > >>> > >>> Although this method can't solve the spinlock contention completely, = it > >>> can mitigate much of that contention. > >> > >> By how much? Do you have any stats to estimate the amount of > >> contention and the reduction by this patch? > > > > Actually, I did some test using the linux-next 20231205 yesterday. > > > > Testcase: memory.max =3D 2G, zswap enabled, make -j32 in tmpfs. > > > > 20231205 +patchset > > 1. !shrinker_enabled: 156s 126s > > 2. shrinker_enabled: 79s 70s > > > > I think your zswap shrinker fix patch can solve !shrinker_enabled case. > > > > So will test again today using the new mm-unstable branch. > > > > Updated test data based on today's mm-unstable branch: > > mm-unstable +patchset > 1. !shrinker_enabled: 86s 74s > 2. shrinker_enabled: 63s 61s > > Shows much less optimization for the shrinker_enabled case, but still > much optimization for the !shrinker_enabled case. > > Thanks! I'm gonna assume this is build time since it makes the zswap shrinker look pretty good :) I think this just means some of the gains between this patchset and the zswap shrinker overlaps. But on the positive note: a) Both are complementary, i.e enable both (bottom right corner) gives us the best result. b) Each individual change improves the runtime. If you disable the shrinker, then this patch helps tremendously, so we're onto something. c) The !shrinker_enabled is no longer *too* bad - once again, thanks for noticing the regression and help me fix it! In fact, every cell improves compared to the last run. Woohoo!