From patchwork Mon Dec 18 08:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13496353 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 C5DBCC46CD2 for ; Mon, 18 Dec 2023 08:22:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FAE28D0009; Mon, 18 Dec 2023 03:22:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AA688D0001; Mon, 18 Dec 2023 03:22:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 425268D0009; Mon, 18 Dec 2023 03:22:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2CE958D0001 for ; Mon, 18 Dec 2023 03:22:43 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F1F651608AB for ; Mon, 18 Dec 2023 08:22:42 +0000 (UTC) X-FDA: 81579247764.22.8DA2044 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) by imf08.hostedemail.com (Postfix) with ESMTP id C488C160017 for ; Mon, 18 Dec 2023 08:22:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.180 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=1702887761; 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=zJqTjnZTPjIHItkHechsbAK+vOUzSf9pl11pwS87u1M=; b=Vs28ueZqt1ZICZJUXXeC0nXSp7PThPuXyUXCb3u9xfRVzVKDScm0jTY6AzQFJS+1LYy5DD XCqxVR+/4iTJ+OZgNiUS2NKPyu0i6CtVWYjeGF603Tv4U5B4sVEBMam3b6qQ0QFVofF769 Xz0p54uIGPYFnyGvmWR60TKva1E69DM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702887761; a=rsa-sha256; cv=none; b=QMLeO4uhmNgN0I+3GAol0X3af0C9eXxsigLqe2wHG8CISXGMKPg7a55WU6YTi6L9GbDUoo n6sx5eQRkZEzBpo3WW/ZLBsOWedXtcikjJ/SqSodN9+dRkX7e3zVizqE2YPDfVl4uItIGK WKSyrPG8C5T2v3gkJSPR42xdVbJ2+8s= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Mon, 18 Dec 2023 08:22:03 +0000 Subject: [PATCH v2 4/6] mm/zswap: cleanup zswap_load() MIME-Version: 1.0 Message-Id: <20231213-zswap-dstmem-v2-4-daa5d9ae41a7@bytedance.com> References: <20231213-zswap-dstmem-v2-0-daa5d9ae41a7@bytedance.com> In-Reply-To: <20231213-zswap-dstmem-v2-0-daa5d9ae41a7@bytedance.com> To: Seth Jennings , Dan Streetman , Chris Li , Nhat Pham , Vitaly Wool , Yosry Ahmed , Andrew Morton , Johannes Weiner Cc: linux-kernel@vger.kernel.org, Nhat Pham , linux-mm@kvack.org, Yosry Ahmed , Chengming Zhou , Chris Li X-Developer-Signature: v=1; a=ed25519-sha256; t=1702887745; l=1470; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=1eOM2WlTMMQMFmZcsE6sU450y2r77yOSYBMqqAB7HFE=; b=YOV157KveESD/iXPiDgVC9WaHMxuNJOt5qyf4ENQkrp7X4z9UFu4fkqe1LUaOnVs8aXOn3lks OXH9Dwct4c+At1moBhyAct1e80egxjcQg0Enm77kPeVULGpQ2btQ6ci X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C488C160017 X-Stat-Signature: j6xc87ejhfpsngnp8ytdbmyog6ip4rkz X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspam: Yes X-HE-Tag: 1702887760-111152 X-HE-Meta: U2FsdGVkX1/K5n+C3JjYej18XyFJfbTpzqpYx7nyf+86rj8bmcw8nrkTYRKWbhe6E9WBgppcWZjIBceOqO+B7CVqyCbNriro1mQkODpNrk8FXEBrCbSFODkl4wWg6lrFNHErqlCx/FaD9nVxNRVGPrx8/widFWarkImMnxDvbTGdHIxM5JanNCKgllF+LIa556ViO2JQxanDiDqNct0jTXyWtZBvJbJbc+XdYp9K0MwwmZ7TSnee9W8oEj90qkDeNmYf6ojwjKMAg+md4fm54dmmoFvGLDRKehTrzkg4g9AIvUdi/hOV1DUJA3mKXlOq3nR0rPoypFGnx/r4B6oRUtXmedDTiax/0ZCVS0b2JEtPee9prnYfkwOVLRjV/flStKL7rb7L0p1zF4bXyiaIcKs5ZNt5trw2HMkmq39XAbld+TfI7MRId/L68/FTBouDSiqVunRpqCThTlkfxYq8kUPWzsTeZYRBqxCkvUqo5xDH6mcggrlkv84epzgTFx9RQJ5/c/OP7xAbbITWdxtVdUJD+mAGqXm6XN1oJR8goOfLV67QwH+kkF8jggbhQix8aAqYIs/GErofwEnRPW6RTmKiS4pn1T8wPMiqcRV1GDI5oIXzXe1aS0+v/Yw0pLq4OG9fnFB4LugiuWl57jcNgDsMxRZxcmzXC+clgahKxgeyR40CfEiC0O27Ye4j4WYLAhdMx7i9kYY7W1CcxryYisAHNkEVvUIPIm4oIwHOfb0WhHHqj3loFP1vqShuXygpBQSa+DEXUIUGGw03gFAqZtdNxIO3Ai1sHlTCTeS75ykvhWsZkOFH/35XTZveJPtoPeYZiF9cxXT8YMjijbGEizzzJW4fUH/o+5fCQpKdJZqxoxOleC6iRDH+hf6t/cLp9J7cP60TpNrd3cPjuHfzaPRUwSc8FRSkcornILviWZceknZHNpHAy7iRrngY9CHATmyPUKVVs5gW/z9mKgV BYgaIvGs 9Ed9n8AmIdkNzZDnmBxGrv9DIVgDhgzBNotKooKpqsjxUfdZdYrIkvF+ipbM79N/a6b5cVqnUbC1QWw7umNBvulEvgUedDxvxG7ty+7cWkC95TEAOtUUIQJwovindWd4CdHd5deABYUH+76ylVI7dQ7gziuCvKeF/+06fr/1gartcQw42wdmNthstz+fB3o9Z59Ka/v74NHbkY2QpONDl5I1rDWHJv+WskgEthArrM+pkuyXvDBLFcKKcBVEaSyhpGZZrULJOqEgD41T4hu6/kvdPprVpbplUCTuLtbngozTSslhdFVTUcVBADdowTnEu2LK3i8+slb6kjZ4COIoLa6GnShTRm8oTEILUDATo9lUX/YLiNdvmZx4mkta3dUTlZfPKwsJXdBkNhmI731z6ZOMfRTsPg9FMku4GCZJ4RXCkEX7FauhY2I6F+g== 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. Reviewed-by: Yosry Ahmed 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 3433bd6b3cef..86886276cb81 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1759,7 +1759,6 @@ bool zswap_load(struct folio *folio) struct zswap_tree *tree = zswap_trees[type]; struct zswap_entry *entry; u8 *dst; - bool ret; VM_WARN_ON_ONCE(!folio_test_locked(folio)); @@ -1776,19 +1775,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) { @@ -1798,7 +1794,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)