From patchwork Tue Jun 25 04:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13710592 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 EDB30C2BBCA for ; Tue, 25 Jun 2024 04:40:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61F296B00D2; Tue, 25 Jun 2024 00:40:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CEFD6B00D3; Tue, 25 Jun 2024 00:40:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 470826B00D5; Tue, 25 Jun 2024 00:40:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 26E186B00D2 for ; Tue, 25 Jun 2024 00:40:20 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CC7181A15EE for ; Tue, 25 Jun 2024 04:40:19 +0000 (UTC) X-FDA: 82268159358.10.C1208F6 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) by imf29.hostedemail.com (Postfix) with ESMTP id 6FE1412000C for ; Tue, 25 Jun 2024 04:40:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=PUFYFf1q; spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.184 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719290409; 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: references:dkim-signature; bh=NWzsDJcE2ZGjLfrjR+FqTDXeK9M6Lj1WnqJTcUe3e3o=; b=tOxLW7mrUoODO5exaT02KbncKLJ8ebLvGKC9LI5r+k3Cv00QXIareHspjP+ywKjRQlvkzb b13IhPuc3r2PJ/3Y5wfO03Bb+pY0lFaxIcJEv93hx9DAuo+VAVIGs2/ypkxN93oIcGcl67 0vcXYxwgo1NDKZdrjcbnXkOOJ4DzSHM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=PUFYFf1q; spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.184 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719290409; a=rsa-sha256; cv=none; b=MuqouP93rDmwjGywevLR+3eVfaQWU4j00+RctWZQ9VL2gtTGhXosn7mJWpyEe07sYMolyb mEl3MmG8rGoVaUWuLeMiZoKJxjgbXyQo11sUljHpjikS6tMh1TKOLKaqDFrwfqwNN5+pZP kpY12Vdi9NWowWmoNlsBN6RSxlxmaTk= X-Envelope-To: senozhatsky@chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719290412; h=from:from: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; bh=NWzsDJcE2ZGjLfrjR+FqTDXeK9M6Lj1WnqJTcUe3e3o=; b=PUFYFf1qc2nM+r11biw6TqJiZhTjk41sRs6H0tl8Rn5ZkTruvQCaSHxZYAphOFSCEDqIZP vSvzkcZSljrWJ6NriL1CyXCPvmoHfTOX6vTPPnaYBT+LoAruO8A08b4bDIH/Qu8Cb5dCRh JFeaJyoKnAP0y+GmpRlNirr8vmgJ7/g= X-Envelope-To: yuzhao@google.com X-Envelope-To: flintglass@gmail.com X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: linux-mm@kvack.org X-Envelope-To: nphamcs@gmail.com X-Envelope-To: zhouchengming@bytedance.com X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: dan.carpenter@linaro.org X-Envelope-To: minchan@kernel.org X-Envelope-To: chengming.zhou@linux.dev X-Envelope-To: yosryahmed@google.com X-Envelope-To: linux-kernel@vger.kernel.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Subject: [PATCH v3 0/2] mm/zsmalloc: change back to per-size_class lock Date: Tue, 25 Jun 2024 12:39:03 +0800 Message-Id: <20240625-zsmalloc-lock-mm-everything-v3-0-ad941699cb61@linux.dev> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAOdJemYC/43NuxKCMBCF4VdxUrtOLnKz8j0ci0BW2BGCk2AGZ Hh3A5U2jsUW/xbfmZlHR+jZaTczh4E89TaG2u9Y1WhbI5CJzSSXR56KDF6+023bVxDvDl0HGNB NQ0O2BpVn2ugUla4KFoWHwxuNm365xm7ID72btrEg1u9/bhDAIcGE5wK1EKU6t2Sf48FgYKsb5 IclxW9LRssojkVlZJkVX9ayLG/OhYCAEgEAAA== To: Minchan Kim , Sergey Senozhatsky , Andrew Morton , Johannes Weiner , Yosry Ahmed , Nhat Pham Cc: Yu Zhao , Takero Funaki , Chengming Zhou , Dan Carpenter , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou X-Developer-Signature: v=1; a=ed25519-sha256; t=1719290409; l=2396; i=chengming.zhou@linux.dev; s=20240617; h=from:subject:message-id; bh=O8QdBXxrsum2SV7qd5wRhBGHU0wBN+EES3FXqsIwH4w=; b=p/LUsswEUWEnH8m8uFyE1N0ekUkhp2BHnwL2iMzDXn/O0I+Vb3N1x513aI0lVDCAmn3NjOwqO TS7CXqWCEE9B06S5BNzLLbEor1ddxpzRjMJLRyjvjPO3vn74NShyvY8 X-Developer-Key: i=chengming.zhou@linux.dev; a=ed25519; pk=/XPhIutBo+zyUeQyf4Ni5JYk/PEIWxIeUQqy2DYjmhI= X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6FE1412000C X-Stat-Signature: h3ixko5eg8j9xdmg1u1zswgbto6jq4pg X-Rspam-User: X-HE-Tag: 1719290417-478746 X-HE-Meta: U2FsdGVkX19ib4XXMsXkIn3ueHkZG+LIgul+aDLtZ4lAF3yW0NwprZbAUhmCUXlKcArJJ4uLAYl+pMUyKhH2fWIMxTwlrdNSJkS119QhPkg9t5sdOq3r4nV3d/aXmU0LedK1qwwCWvhmh3qGEah1tHNEBrNQDoqKHC5tlm4b1wSBLyolE99Xy6I7hs6mc20dOtoSPy8AsUGhJzcyiwVNNzxpJzinaYCMY+9nwmP+Lps5SzYvQ/1A+AtHC9R+or14ZCP9WZJys3ki54p8YXjZFOxiEdHjiqeOnr7g6xXjXP3pE+wYK7Bye8pVBGmHL9tPQiFoVdmxUBFvGDuUW1pgPtDJ6cusy4KMsfISFtsD2AEUFLtkpjFCDdsTfeaWy+GL0rJ2xtyOkGr60xSp/NSPHzsdcsSEiaCG87hXvEjYhcRQwC8KNUBWdPOMD3fh6Rl8rFq75GxETFwcm5/LRsXc5M6MimuPzyNRHzoQviKTQVR7AKUx4zFI+fSpnoBS4xSp6borSYJf2CI89WToh2c0GeomJpRlHZDVb7FbLnkzpQFJEmgYEm7jCUYsfd5vzbN/PDu+OLjcxd4/xFrM2u7iS/G13U/tp40/Xs4GGhgxfMRvsZOSFSOIFnuuX1PT+xN2rU4oy6B1VWAr+TF2qPvZ3IcKNLQNm6jOxYyL3OYFOjV3MG/e1VelvWifYNDMgMFQCKvp7GKebj5oUMUgh8iExmcwHdHVIe2LlBwDvUp0PWb5Uog6oWBF+3vwHaMGCoxiuB7GFmguwYw8T6vYfZlUJhmWixzuJAaPLyz8ZWf27FvoZElOkvH2uRU0QDhl4bNCTWjN8SdLZ4/JgsY0I8+TfOQ9p9yqVXSUqD23ip6oUxvH+myNwtpYosc0JnVbbKGDqsY3oc+mtAXI0hOtguWKt4Az4plflzez2RSwkOC78PdWsPexFQw7SWIkA+0aTitvkP59P/xLMafUwRtHarc W7cuxHR9 PKHSXf+qjEHUPD1llOuf750UTxWj8odVK4NV2DFig4lz2tN/p3Ty7fO93A+Auix6oYRiP5DWaB3jlc6e2jHgh1eMkm4bWK0Wl4+hhscoepNpDTfv4cnRbRowqLN53zO1XTrxsB8Y3mAURm9W5jc0tmjyFYzjGnPmN+04cP5q/h9mVKZdonNCZLeWrd61Vb81bpM5KhDD5lOPTF2TW4/DSYFWa9X7zH0WZ2WNitOGlPCff9f4= 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: Changes in v3: - Fix error handling again in zswap_pool_create(), thanks Yosry. - Add Reviewed-by tag from Sergey, thanks. - Link to v2: https://lore.kernel.org/r/20240621-zsmalloc-lock-mm-everything-v2-0-d30e9cd2b793@linux.dev Changes in v2: - Fix error handling in zswap_pool_create(), thanks Dan Carpenter. - Add Reviewed-by tag from Nhat, thanks. - Improve changelog to explain about other backends, per Yu Zhao. - Link to v1: https://lore.kernel.org/r/20240617-zsmalloc-lock-mm-everything-v1-0-5e5081ea11b3@linux.dev Commit c0547d0b6a4b ("zsmalloc: consolidate zs_pool's migrate_lock and size_class's locks") changed per-size_class lock to pool spinlock to prepare reclaim support in zsmalloc. Then reclaim support in zsmalloc had been dropped in favor of LRU reclaim in zswap, but this locking change had been left there. Obviously, the scalability of pool spinlock is worse than per-size_class. And we have a workaround that using 32 pools in zswap to avoid this scalability problem, which brings its own problems like memory waste and more memory fragmentation. So this series changes back to use per-size_class lock and using testing data in much stressed situation to verify that we can use only one pool in zswap. Note we only test and care about the zsmalloc backend, which makes sense now since zsmalloc became a lot more popular than other backends. Testing kernel build (make bzImage -j32) on tmpfs with memory.max=1GB, and zswap shrinker enabled with 10GB swapfile on ext4. real user sys 6.10.0-rc3 138.18 1241.38 1452.73 6.10.0-rc3-onepool 149.45 1240.45 1844.69 6.10.0-rc3-onepool-perclass 138.23 1242.37 1469.71 We can see from "sys" column that per-size_class locking with only one pool in zswap can have near performance with the current 32 pools. Signed-off-by: Chengming Zhou --- Chengming Zhou (2): mm/zsmalloc: change back to per-size_class lock mm/zswap: use only one pool in zswap mm/zsmalloc.c | 85 +++++++++++++++++++++++++++++++++++------------------------ mm/zswap.c | 61 ++++++++++++++---------------------------- 2 files changed, 70 insertions(+), 76 deletions(-) --- base-commit: 7c4c5a2ebbcea9031dbb130bb529c8eba025b16a change-id: 20240617-zsmalloc-lock-mm-everything-387ada6e3ac9 Best regards,