From patchwork Wed Feb 5 09:27:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13960704 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 EA3DCC02192 for ; Wed, 5 Feb 2025 09:28:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78449280006; Wed, 5 Feb 2025 04:28:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 733FA280005; Wed, 5 Feb 2025 04:28:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58661280006; Wed, 5 Feb 2025 04:28:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 30700280005 for ; Wed, 5 Feb 2025 04:28:23 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DEFF2470FD for ; Wed, 5 Feb 2025 09:28:22 +0000 (UTC) X-FDA: 83085365244.11.F094D22 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 209EFC0005 for ; Wed, 5 Feb 2025 09:28:20 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K0Jkqwiq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738747701; a=rsa-sha256; cv=none; b=NK3PbdMXmpblYXjUa84dIuXR05NiIms6NVrePDO/2l9+G5MhrFsLtDOJOQFdA3FpANLHW3 ixd5YG+FpPop8KCdrXJsELxwEYlcjsqEaWDH6ZTEWCd4EiRy03iYqPrrfx6XU4cEEbjDhD p43wS6Q7etfKUYgd4UyQArUjxl7HmZI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K0Jkqwiq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738747701; 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=8vVxPS21csuuvYhubTDPbniUZC89uu0FzC8UHkUR7f4=; b=EPIdcO1uX7/1w78BKX6NeAQnC6uuByYV30XrjscwcjZ8km32F6BvsBsbaxqcni4fZ2VdeF MqSFYCWux8ihdoU7kfl0fPBEPRoyUbhKhhjlnqhSqKircO2zUaJZbM2OXqTS1Qc16+LRCI CkOmp7+WWQAyUSNUMSCeCc1ozkA1CtY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738747700; 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: in-reply-to:in-reply-to:references:references; bh=8vVxPS21csuuvYhubTDPbniUZC89uu0FzC8UHkUR7f4=; b=K0JkqwiqoSFHzA2SEdjKI/4+4bmPtDiPzvD7ABsmChFsWJ3BrnvA73iQPmF+QSSxaHK3WW /DBzD7X47LkYDd1l8Ffa0e4GyjbdN87O0XnZkfnWZDuK61zNFwDH9MeCNJMu64wkcNter9 KmbfM9NxNhj67eMYMnMN8tRlXsbXnr0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-YcE78HehONax1pGIvqF0gQ-1; Wed, 05 Feb 2025 04:28:17 -0500 X-MC-Unique: YcE78HehONax1pGIvqF0gQ-1 X-Mimecast-MFC-AGG-ID: YcE78HehONax1pGIvqF0gQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F6261800877; Wed, 5 Feb 2025 09:28:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.190]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9B8CA3000197; Wed, 5 Feb 2025 09:28:12 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, ryncsn@gmail.com, chrisl@kernel.org, Baoquan He Subject: [PATCH 10/12] mm/swap: rename swap_swapcount() to swap_entry_swapped() Date: Wed, 5 Feb 2025 17:27:19 +0800 Message-ID: <20250205092721.9395-11-bhe@redhat.com> In-Reply-To: <20250205092721.9395-1-bhe@redhat.com> References: <20250205092721.9395-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 209EFC0005 X-Stat-Signature: pastzuzw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yONOSK5qqz5/KpKMRB6dDbxpDulldlOngKEk0UCKUOTIajqWVQa1apH9B623q23gdq1YoA8x19f6+vl/KD3U+FN3vNWdSj/iPn7QkwK4unNipoFW5dtlHg+XrlMJ0IYLeRqwoCpGNHfX5sp7wJhamuLVniGx0RkH2eO01LCI86dVwK99TkygOJjtgXUZDW7qx7TJM8kRdFQPRDB4g/5xUOzhMieEtV34yRtqe9ydPY2WGeWdCMcewqB663zPOndR0Vnzj/tGgAP/yWvw49eDAuhtPoqjIqH6wlyEWyxsu6veHQ0r4DeQFeNPCAud0RKqnfiu6/qDJNHi5PyZC48BvNA== 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: The new function name can reflect the real behaviour of the function more clearly and more accurately. And the renaming avoids the confusion between swap_swapcount() and swp_swapcount(). Signed-off-by: Baoquan He --- include/linux/swap.h | 6 +++--- mm/swap_state.c | 2 +- mm/swapfile.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 20bfedc8c4f2..395d41cf9676 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -500,7 +500,7 @@ int find_first_swap(dev_t *device); extern unsigned int count_swap_pages(int, int); extern sector_t swapdev_block(int, pgoff_t); extern int __swap_count(swp_entry_t entry); -extern int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry); +extern bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry); extern int swp_swapcount(swp_entry_t entry); struct swap_info_struct *swp_swap_info(swp_entry_t entry); struct backing_dev_info; @@ -583,9 +583,9 @@ static inline int __swap_count(swp_entry_t entry) return 0; } -static inline int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) +static inline bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry) { - return 0; + return false; } static inline int swp_swapcount(swp_entry_t entry) diff --git a/mm/swap_state.c b/mm/swap_state.c index b393cefb3be0..3dba6eb164db 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -457,7 +457,7 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, * as SWAP_HAS_CACHE. That's done in later part of code or * else swap_off will be aborted if we return NULL. */ - if (!swap_swapcount(si, entry) && swap_slot_cache_enabled) + if (!swap_entry_swapped(si, entry) && swap_slot_cache_enabled) goto put_and_return; /* diff --git a/mm/swapfile.c b/mm/swapfile.c index 2a25ff5f31c8..93fd12c12bba 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1615,7 +1615,7 @@ int __swap_count(swp_entry_t entry) * This does not give an exact answer when swap count is continued, * but does include the high COUNT_CONTINUED flag to allow for that. */ -int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) +bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry) { pgoff_t offset = swp_offset(entry); struct swap_cluster_info *ci; @@ -1624,7 +1624,7 @@ int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) ci = lock_cluster(si, offset); count = swap_count(si->swap_map[offset]); unlock_cluster(ci); - return count; + return !!count; } /* @@ -1710,7 +1710,7 @@ static bool folio_swapped(struct folio *folio) return false; if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!folio_test_large(folio))) - return swap_swapcount(si, entry) != 0; + return swap_entry_swapped(si, entry); return swap_page_trans_huge_swapped(si, entry, folio_order(folio)); }