From patchwork Fri Jun 21 07:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13706933 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 15A16C27C4F for ; Fri, 21 Jun 2024 07:15:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8031B8D013D; Fri, 21 Jun 2024 03:15:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78B458D0138; Fri, 21 Jun 2024 03:15:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 605DB8D013D; Fri, 21 Jun 2024 03:15:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 39B0E8D0138 for ; Fri, 21 Jun 2024 03:15:45 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9904780655 for ; Fri, 21 Jun 2024 07:15:44 +0000 (UTC) X-FDA: 82254035808.16.F6BD25D Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by imf08.hostedemail.com (Postfix) with ESMTP id E259016000A for ; Fri, 21 Jun 2024 07:15:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Zefbg62V; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 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=1718954137; 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=tOqrzNN/hVJKUhpB295MtNPXD1lC1GUlx7tqQgCRnPA=; b=Ndi/StPWVI6+/+FbUIjOqubrsT8V1gf6A81fMrQRdiswkdyLcaE92xBSNa6MVqysQ664rc WkBaD+suSXCPg9mNVJgq6uGROGr3CfC143/9xVz4J53bk4WQ0ejo0TcBOP/NNmKqTuTwn0 YtacRVxTL3/TzFRL3ZCJ/+8uAXcT6zY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Zefbg62V; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 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=1718954137; a=rsa-sha256; cv=none; b=igWlhC9NyCGiTIXCN0pfx68djz4AFhsJ6BXUbxaQ44MwdOdDBZQ8B3GcApGdS1da9zlKkH qwe5+EtvoQvO3iL2zs1kldklxxb4tfAFkcvxH1jXoOcQjdUjB4HdYeqq2pWcGAkjVfwfoY LcIf2kCLz356W2w+WqG5q+tMjRb1My4= X-Envelope-To: nphamcs@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718954139; 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=tOqrzNN/hVJKUhpB295MtNPXD1lC1GUlx7tqQgCRnPA=; b=Zefbg62V36nuWtcHlL8rHv8yJSAts/gdbTUpSU26lKcKadShZFr7b3INq0P3kGHIlNHc+w 3KfFaGbjq+7Lb9dA8c4Di4KDwbSL5ooEL523a9ZpYEJ1Ix+fqeaAyBsIrV4MpfbRMXZVf/ b3S647Wzzs4fwypFVjLTrw18mbztNCU= X-Envelope-To: yosryahmed@google.com X-Envelope-To: dan.carpenter@linaro.org X-Envelope-To: chengming.zhou@linux.dev X-Envelope-To: linux-mm@kvack.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: zhouchengming@bytedance.com X-Envelope-To: yuzhao@google.com X-Envelope-To: senozhatsky@chromium.org X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: flintglass@gmail.com X-Envelope-To: minchan@kernel.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Subject: [PATCH v2 0/2] mm/zsmalloc: change back to per-size_class lock Date: Fri, 21 Jun 2024 15:15:08 +0800 Message-Id: <20240621-zsmalloc-lock-mm-everything-v2-0-d30e9cd2b793@linux.dev> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAHwodWYC/42NTQ6CMBBGr0Jm7ZgW5EdX3sOwqO0IE6E1LTYg4 e5WTuDiW7xv8d4KgTxTgEu2gqfIgZ1NkB8y0L2yHSGbxJCL/CQqWeMnjGoYnMa0J44jUiS/TD3 bDoumVkZVVCh9hmR4eXrwvNtvbeKew+T8ssei/L3/eaNEgSWVopGkpLwX14Htez4aitBu2/YFj Vu2+MYAAAA= 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=1718954135; l=2161; i=chengming.zhou@linux.dev; s=20240617; h=from:subject:message-id; bh=XaO4Z0+DtOg24zA1OThoXiLI5A9lBnk/os2EEmz7b7Q=; b=MaNU41YtH+wB6JIswCj4bvQET2ZJktB31PF0WTzqMTS+g61cKj0d0rRlcreBVK5g34wBX9Yh8 sxYuNFjS9YsC51599x1WG8we4RP6XjdSxbLspNKRjPf2DhYfZuqBWWj X-Developer-Key: i=chengming.zhou@linux.dev; a=ed25519; pk=/XPhIutBo+zyUeQyf4Ni5JYk/PEIWxIeUQqy2DYjmhI= X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E259016000A X-Stat-Signature: i9f7y1qtmpnrb4jjqgsdxw1ejpjo4x46 X-HE-Tag: 1718954141-916410 X-HE-Meta: U2FsdGVkX1+EITTTQimBIUtGi/5ENUI1toXbuuMv1TEDP5QViysdv/DBlMwbq7Dy45sh0hAbI7GkwgevVAxueIsB65Hej6ax81Jsu9W/rydAw+e8ht0hGsxRdzX4veYfxee37FZNa7+XChnEgKCZ2rRsWBnGgeSnssInPM0+CHOxj//MAa139UusUbB5eFntAdK19Q3Il/b/yCRcu/L/z/DGND7KyvsTnyf9sxJPL2JItiznyGGGyde50vTgJzEru1YkmusP2gv5UYG52K4IVCnMSE9a9AcQmAiOubjcK+Gr9I+cr4ZbBPY2opUTtgVMAYOU+OPbpJ7SlJ1om7x7Oiq7m+65LDW79s4qZbl6ZJEBVuxsCZ7jJOvPgYBBs0OS9kuT+e667/G0V4x5wfaVuqCXBjENb+0mk47PHgIxr9Fk5p2MH0S2I3jpsD7QI8qUujaGK91f08lcfjknHn9/9RFc2hag20tN7aX62+CmsZAGp4FYWwTnCR8rurRc9hWlXCmM+1JQw5NthSMGqAT83tUQEfGCDVrdURKS9DP3PICkgmC9oC/45UbZ0UqeBjqnjXvu+PFscgS98EQ6tY9UYCIqsw5rjBXrQizvfh1GnDV9/AbegS7AL9zjrVzgE2DPTyJQSrUKYR2bNjwOB9Ke4snDEzTeJAWhpb8hgv7wOWA5YBX/HcCkzdoyE+cIJDACYcXtZdbGcMDvPTn0VkkCDz46FGN5e27KlJjIN0jMkqSOfp3LhTGXnT5YzF/xteLTh9FsC/RGnlwiVEE7e7+s053VJZjYvFPW8+nszzPG1E9q7C+yXCsv99P1YkXV/sfXmowvsm2inlY3Z4j+DFjebJ+G2HtJNhdcQSc9YQecFVDhVHKovpLedCw76Z4MFQLfmYGXK8gVqxv6R0phZXFLupESggKxcUr5R+3Tc74ne7Vd+TjIL2PmNM+o3l6Dqiwntao41iDJifbaj2BhOys IETTLnL9 LOBNGUEMSGdLvo20UXvkwXDYL6ORxUs9svhAAAjsPd5+rB4YkZVJ+/UHJau5VmLGmS+CJ+IfmbpaURv23x1OToiJaKZV5Bs9BQht/u8YztrGZlux3P1+vcyTHvjnYe4uQntP4HziyU5y1n8h1+lOH9ryujD9FPWXMXTf1yPtEMfdwL1NXYHLMQHzaC+QDvFhMyCUP1wiK5IsuYaae2qMdYdx0QIy63KQL92pddPf6nS0gkC8= 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 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 | 60 +++++++++++++---------------------------- 2 files changed, 69 insertions(+), 76 deletions(-) --- base-commit: 7c4c5a2ebbcea9031dbb130bb529c8eba025b16a change-id: 20240617-zsmalloc-lock-mm-everything-387ada6e3ac9 Best regards,