From patchwork Wed Dec 6 09:46:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13481323 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 2D8B2C4167B for ; Wed, 6 Dec 2023 09:46:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 937F56B0081; Wed, 6 Dec 2023 04:46:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E0846B00A6; Wed, 6 Dec 2023 04:46:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77D456B00A7; Wed, 6 Dec 2023 04:46:47 -0500 (EST) 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 682096B0081 for ; Wed, 6 Dec 2023 04:46:47 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3FC42A064A for ; Wed, 6 Dec 2023 09:46:47 +0000 (UTC) X-FDA: 81535914054.07.4D0C66F Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) by imf01.hostedemail.com (Postfix) with ESMTP id 5E38C40017 for ; Wed, 6 Dec 2023 09:46:45 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf01.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701856005; 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; bh=BO8VowIXT7NgKBMLiN+PSMhPCGB2s3h8IYWpMrQuxwQ=; b=Spkc75sXV2zKPagSL0UE6J0lZQ5/6jRepKYWbkSM+RFtpD2neMp0ob2ZIKxA9sZJ6mNgof C0cmtElQDcVnG9tkQGq0Z1af2H9b0F7li8JDKoU1CY4cyaS0za2tm/wFmO3wHiB08OAb4e v8zjBwCzDmmkmt7GCSyE/5CyHu8FZ+8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf01.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701856005; a=rsa-sha256; cv=none; b=drHigeKOAVTpW3fDC7DWTf7n3mpHV3wMEtPQ/G8HCNvwuTS9TQRpADVfrC6X5KGgsc8DLE nSc649zmw2+4Hpa/NJM6jnq8/yo1B/3+F6bZCXuYhA+0qSadU5gdsWXmD7r9iM67d+CEPE 9G1FvmX6W/G0IOAL1DKkw7N52R08Ag4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Wed, 06 Dec 2023 09:46:29 +0000 Subject: [PATCH 6/7] mm/zswap: cleanup zswap_load() MIME-Version: 1.0 Message-Id: <20231206-zswap-lock-optimize-v1-6-e25b059f9c3a@bytedance.com> References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> In-Reply-To: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> To: Vitaly Wool , Nhat Pham , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou X-Developer-Signature: v=1; a=ed25519-sha256; t=1701855988; l=1423; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=4dWwyqNx8c2zAiSbKiIuSiLwoPGaeKufk6rm1H1OjyU=; b=mZ9Iu4zkHefQk19MezNP9JCSi8K14mS0atJNAlahjaBU1aLDqTWfFZSjHbYanEfMEBZ7TUpMw gqC7DA3KfbRCEXYKYzA63WfdprZF2BjpqhLC6VPExYC46NfHkEsxMYf X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Queue-Id: 5E38C40017 X-Rspamd-Server: rspam12 X-Stat-Signature: 5itmjuk4bgtp7nr3aw1qh69cinmw414p X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1701856005-378208 X-HE-Meta: U2FsdGVkX1/ul6FV9Zx3zIBMIuaThUIdyQbgGBgPAvuxB9LYg4CQ155kyZkTDJhMwJ8ypKPRCMnc7fLdhaqvyzhOBZDTBE/9/qGVFRrQgdtKC5wJiv+8bO01ijqIe5xn7CaUjTptd/yP16fdY0ZbgnnnS9RR2sgvXfNweD/MSyhUSHWQ+fslzd81o1ad/FWGOsY0NjaWsaTlW8alSaWurAMDVhRNKBxvnKG64INL4gwgPd0UXrUWHcjoa88Sc+OyxeK5BV2ErLCUVlcqNfJh1YJHgYzAOk6VNT6inQk2mCAjiA7sg0bE9/ogYu/CQpZ7cHdJCtPQO3RCxJcGEZcd1HTMLbEITV69YO4Cd3k8H1UyJere8Az3549PhF/GFR6FTqsFpjMfJSptOBrBH7WKEJbI72CQ4a/9LUcZHtwSm7u+fsTwnIPq2gx9KIPNtxU6vmpsnfzy/iV8fQg2o3gFr6QRe/pKkWuq4/msrdYDdcaY7a/iQkD7VxhAVwopWE+qJ6+bAyiutsr4w6Tmd1gdk76gotKlPmjB/XEcSxdD+5hIPyQ9jCDLpM/Sw9y6tue9O8Ity++jxehyF/KN/vELM/0UMPqx4IFt1O0zIrkniYoJQjzz9n1JTwY+lvcx+DKwW1D55g1PBLWgrMM4lJX7RTWaxCzMSV4B5AWtP/lpox8Rlk5D+fk37YQDUpAyVyG/mUssBjsOIMGcirfq6uGoC8V3YYgmVm3X8uD1N7EE2U3VW4hwkt7C9cKz3ekDfRcSolBBiwcEbWw+1dNlLYMf56qF8zq3zvOm1skOTPkF6rRB0KiirX0bZ2aHF5RLRUavmLzCKSL2uWAqERfVUZfU4atso02IUsNFIc+V0OA45bm7dNUa3HGywivK6nXs9zVWtEthJCx4KqYnm0hYEVLaiCgK72aOBRmxFc8sEUxU7CLHyyzBTuFBobO7nDanhhVWifM4n9hwcVUOV+b5ieb k+ShLHuc yY+ofTTzBNK1GR6zlVBqHs7zMNLJaLAabuwAWvmda3/52sWMYmk9egn8Ofu5LR6PslLBZNnucKZQaqajYzGsrMR2PeeTqp0cb0dUBabtk9h8Svz1geLuSEbKxEKN28/k/4fYwS1lILPaUdAihIySJVnCHLvLGo0uTaunjI8leMqVc7LLQ7XK2nU/hUbrvevKr/hDnM+qheTOQ0D6a5yQiksJVm/2hsq8niHQIfwht6PHLwhOqVhAxrHyxO8q5PsrwCu9FD9n4QwW6du3JJ3v7pJG1SWhFrRFrdcPpcqsbsb9Z1Mzy5cHW4M3lMVv26LE0now6ZqmI1/P12CTMBhtFZLhH/qpFhxkXcWGwxxxN6WZDF9AKsDW/Xz1AMA== 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: After the common decompress part goes to __zswap_load(), we can cleanup the zswap_load() a little. Signed-off-by: Chengming Zhou --- mm/zswap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 667b66a3911b..50405811cd7b 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1752,7 +1752,6 @@ bool zswap_load(struct folio *folio) struct zswap_tree *tree = swap_zswap_tree(swp); struct zswap_entry *entry; u8 *dst; - bool ret; VM_WARN_ON_ONCE(!folio_test_locked(folio)); @@ -1769,19 +1768,16 @@ bool zswap_load(struct folio *folio) dst = kmap_local_page(page); zswap_fill_page(dst, entry->value); kunmap_local(dst); - ret = true; - goto stats; + } else { + __zswap_load(entry, page); } - __zswap_load(entry, page); - ret = true; -stats: count_vm_event(ZSWPIN); if (entry->objcg) count_objcg_event(entry->objcg, ZSWPIN); spin_lock(&tree->lock); - if (ret && zswap_exclusive_loads_enabled) { + if (zswap_exclusive_loads_enabled) { zswap_invalidate_entry(tree, entry); folio_mark_dirty(folio); } else if (entry->length) { @@ -1791,7 +1787,7 @@ bool zswap_load(struct folio *folio) zswap_entry_put(tree, entry); spin_unlock(&tree->lock); - return ret; + return true; } void zswap_invalidate(int type, pgoff_t offset)