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 0B548C4167B for ; Fri, 8 Dec 2023 15:41:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75B226B0085; Fri, 8 Dec 2023 10:41:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70BB36B0088; Fri, 8 Dec 2023 10:41:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AC476B0092; Fri, 8 Dec 2023 10:41:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 451926B0085 for ; Fri, 8 Dec 2023 10:41:44 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 173031A01C7 for ; Fri, 8 Dec 2023 15:41:44 +0000 (UTC) X-FDA: 81544066128.06.24B3AD2 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf08.hostedemail.com (Postfix) with ESMTP id 25232160013 for ; Fri, 8 Dec 2023 15:41:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=b189WnTI; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf08.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=zhouchengming@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702050102; a=rsa-sha256; cv=none; b=fyVg+mlc+61II7rEhwuWi8vjQmsZVt6dDYuSNTup3KL0JD0rRqbO+oXjCgtuSMuApkXuCn oMpU9myh8cxdWakxl3p8jGbJnZrrUtbPi8c/9auWMIzKNqxYhd5asdrJjXAYuRvddTuM8+ WS5ApknB/u4EUXf7Vm4ronoI5lNUdg8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=b189WnTI; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf08.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=zhouchengming@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702050102; 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=1E9d4ZCyxDs2I8Fmuzv+F6C7pJm1TGZqWQ9mMucS+jA=; b=ZY+d79WpxTEvJBLrmV+ubBauSyOfxooRLyaaaz9ezfxpQ4tdO60jDVIOoirdxOx3sLAXx9 2T1pK17pjy693HUTudU0eG4LYjVr+WPvwh/WiUpcp7mhOHH3kzW5kwG5FQczB9BB+YUqWW +OOTZmVuFN8ZtDQTNOnORXa0d1o3gLI= Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5c2066accc5so1559066a12.3 for ; Fri, 08 Dec 2023 07:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1702050100; x=1702654900; darn=kvack.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=1E9d4ZCyxDs2I8Fmuzv+F6C7pJm1TGZqWQ9mMucS+jA=; b=b189WnTIFdGzHe2whd6tU7aXUpW8eUp1bpV4ioOZSRFgD1bHEToQa2lBWZ0zrGKDQH CXI62ytt1NODBAFfnmOb2YJD1M0VJ6+dgtoGh0ngmU2F/Wx8e5jcRrGfOVfd1+AAGPf3 7VQTTaQLCv5uT4vzyBm9IqRGPN7gSqe2kQSC/H83//z64d6Cw5IdeGztIL8kEg04frWz Rh1V1qTQNMgSnuXt1EIDRTzBKL4p6LOBIM8zyxNtDckS2GK6hSijQY4qbb/VLsukTeZ1 DV3KU4VTyraIIa07RHDIEc0VO2cAhaKntuU1e9BSJmpODEYuyu6IYRtYbYid7GyiUFJi WbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702050100; x=1702654900; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1E9d4ZCyxDs2I8Fmuzv+F6C7pJm1TGZqWQ9mMucS+jA=; b=cQdI2vuvqq31DpCveNnQ6zUaLXczMHL5gjKSN4yJwyhLZnnGAjLcEgCBS0zAHe8W/c 8m4fC8GIQ6xVh81j+y5Im3FRj7GOrZKdRPK1GBgIfPv00hmcTlOjfvDx1T/+nf1GMeYW 4RnYtBfBFL3D/U/4V7XWJyicByD5xlOhMl8DKCGcTRiUII1SekGdyU5nzNFumYN0S8sE gxPUtvPWNR7AQtj6HTVpi+0d33jZ7+EdR+nGJdN3/FF7sr6WXn28WrHI6cAkA23C5uPY GS90jJuRQ0JJ+5VFTBAQZoMLnZIWSJSbQPbxxGiEjnzPhxiiJM5j4g65QIje71yYXAcD FKKQ== X-Gm-Message-State: AOJu0YxXYPexZzlT2nerdsSLQ6VM219CEg7nj78YjmgmzfkVclj+KPCO Ygr2as36clJaF81rrCg31TmL3w== X-Google-Smtp-Source: AGHT+IGJfvmrPJwyCawGxJHud5fZ2Zbt4ByzGPXIwtHn9bfTKIBH8HCQlj6HdZlqNy4B3oqp/h1trA== X-Received: by 2002:a17:902:6848:b0:1d0:8383:742d with SMTP id f8-20020a170902684800b001d08383742dmr203436pln.37.1702050099735; Fri, 08 Dec 2023 07:41:39 -0800 (PST) Received: from [10.4.166.75] ([139.177.225.252]) by smtp.gmail.com with ESMTPSA id c7-20020a170902d48700b001d0c1281ef5sm1837836plg.89.2023.12.08.07.41.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Dec 2023 07:41:39 -0800 (PST) Message-ID: Date: Fri, 8 Dec 2023 23:41:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Chengming Zhou Subject: Re: [PATCH 0/7] mm/zswap: optimize the scalability of zswap rb-tree To: Nhat Pham Cc: Vitaly Wool , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> <6bf18314-7749-476e-aece-064ecfb0dffc@bytedance.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 25232160013 X-Stat-Signature: cmoyheghuf5ja6m8iw9kdfczo3jjo93s X-HE-Tag: 1702050100-63530 X-HE-Meta: U2FsdGVkX19Q1P9Dd7d0onWG8pII6hYL0zc3cEielCJv1K602YBGZxQeW4I7H+MtHaDlvN06akg3dLbFKnhf9uLI/cNophmSqFbCzLg3cwhsIDVmE3WU0tCzjjbFehN3RycKYV+2Cuq0+xdDHr3S3NOinPRsO2OLr2b1LWz940Bv/otqChmNHY6VvHTLWLSFcCsFqaXC5RAWQ+y8zT4cl3Ip9AS0FhC4fbj6YphwQsW3iLy/hIY4PCk/mBsx65VbwPbAbKwpoAZ+TPj7T5dMkpjJdrd1Oc9WF7XyOR5nSBIsVJQ7lNywiPNhtjd/Nf7Mb0qloS8rTGFmZAdiUKgMyV51F96O9r58S9oCbTYIpHfuRd9pE9VXe/I99+cOXA0fCuUyEm5PNzgKZa8NhetRHYRNp+F4t0UJiPbvY/iU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ilter, spamicity=0.000021, 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 2023/12/8 02:15, Nhat Pham wrote: > On Thu, Dec 7, 2023 at 7:18 AM 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 AM Chengming Zhou >>>> wrote: >>>>> When testing the zswap performance by using kernel build -j32 in a tmpfs >>>>> directory, I found the scalability of zswap rb-tree is not good, which >>>>> is protected by the only spinlock. That would cause heavy lock contention >>>>> if multiple tasks zswap_store/load concurrently. >>>>> >>>>> So a simple solution is to split the only one zswap rb-tree into multiple >>>>> rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M). This idea is >>>>> from the commit 4b3ef9daa4fc ("mm/swap: split swap cache into 64MB trunks"). >>>>> >>>>> 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 = 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. Right, both optimizations are complementary, to make zswap perform better :) > 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! It's my pleasure! Thanks!