From patchwork Mon May 29 06:13:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13258142 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 EEA5CC7EE23 for ; Mon, 29 May 2023 06:14:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 901EC280003; Mon, 29 May 2023 02:14:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88AF5280001; Mon, 29 May 2023 02:14:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70505280003; Mon, 29 May 2023 02:14:28 -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 58AC6280001 for ; Mon, 29 May 2023 02:14:28 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2C6911A01DC for ; Mon, 29 May 2023 06:14:28 +0000 (UTC) X-FDA: 80842278216.29.0456912 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf14.hostedemail.com (Postfix) with ESMTP id F03A810000E for ; Mon, 29 May 2023 06:14:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=G9u8V89h; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf14.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685340866; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3xIj4lwktXLAySa7XqSBq9+rB1Zc0DD28GkVkkU93b0=; b=7Bv9VeQawm9tJcHo3O/CMTkO+zk/5BwdAravcTXF+jjSkr8GRw/IZznVLsCX5PJUqLs2wW EAGaQm5+FzINk0FsSx80YwBv1NmdLluvyQ2/wgJVfZq4kP19O7Z/WcFlsu1GzoWTlZVZGW Er9qhyhoZevPF1D2em2e38PdIDt6wMM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=G9u8V89h; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf14.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685340866; a=rsa-sha256; cv=none; b=1nTjU1niaLWU1dCvE5Si5zSjaYdQ8Afjw0yiHOt3XGVcamiMcTZa9q4RDxx9Ja60K6UbT8 PBQ8rc1fy/Axhjiqix5OSR7MtXXzzGFZxrK7Xp9ASFzSxIOx9zux3jMDlh1n3bStTeLgE8 Qlx65XIC2YtgAFCRQBlok/4dtgWw0xA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685340866; x=1716876866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tTttI7ks79EVJT0Lkkg7CgRwuqqX+cQLYrih/1r1FtU=; b=G9u8V89h7gMnJ7E0iHEEsg7GcBbp7vosAx2TvrJpo3wcvC/hdeQD3xpG 0cGI0545KoXp6XaBd7z1iHFAv3Jl5DF43zDfyzag+1URZ3XdzFSMjbknt 53X39dQYjoo11OjYleFeitis9txRax0uvJyUQ5o1HG3qI6YFBYGooXsBK RfrA0UAXdbgd4fZZYewWHBDqlnOTKtnuWSj4RojhLzrpzYMcWOPlQm/LO +yiAl21C5lAqUjlvPEZy0saXg8w83BzAd6nX5QdaFHr7XxTQWA2v8fTXr xya+guCeq9sBtEFbo30IqiJeVGqp3nhI6vUdQdM/M6i3HMRcOB2UGZzS/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357881842" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357881842" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="1036079999" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="1036079999" Received: from azhao3-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.126]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:22 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Minchan Kim , Tim Chen , Yang Shi , Yu Zhao , Chris Li , Yosry Ahmed Subject: [PATCH -V3 3/5] swap: remove __swp_swapcount() Date: Mon, 29 May 2023 14:13:53 +0800 Message-Id: <20230529061355.125791-4-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230529061355.125791-1-ying.huang@intel.com> References: <20230529061355.125791-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F03A810000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ejb6ifdxkdk9j677whpkpemikuzed3uu X-HE-Tag: 1685340865-149910 X-HE-Meta: U2FsdGVkX1+cDJpYbZ/KFXvJE+zW/oZuTdBIX7WvRmhF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Hz7Qrk5aNJHM34Lh1OBqRoX6Wxv1fi7eYIVtuBh/P7uL4FNUOUTdBk0C8/+byUhMisy2S4081lvShAaatSu7iSksmxb4Ea0g0jiCT9Jc8aUtqgx6P4TrIUF8UxcfJkpcUHgZL5YfwpND0WtSjCgwKhjjTx7XllWK6P6uYqwAtzA33vwWENwpjVaNRkmfWBFwwnKRwFI0Z4E9fNwUHZKW10m7QFz1RnMQIzukV2eHBKviq2oZwtNgfaaeDxXbq4PrH0J6kroMYN4bfxuVjVo/VEz8gNCqi8WGvgQcZ/E8Kx3WwKJCcaBEvAgafWjZYM5ZnMVfmFi3YSS5e5lOtxE3tGOVc/cemq//BglWl5QzLhD0uMoXP7h6da96Nt4tqG+rCx 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: __swp_swapcount() just encloses the calling to swap_swapcount() with get/put_swap_device(). It is called in __read_swap_cache_async() only, which encloses the calling with get/put_swap_device() already. So, __read_swap_cache_async() can call swap_swapcount() directly. Signed-off-by: "Huang, Ying" Cc: David Hildenbrand Cc: Hugh Dickins Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Michal Hocko Cc: Minchan Kim Cc: Tim Chen Cc: Yang Shi Cc: Yu Zhao Cc: Chris Li Cc: Yosry Ahmed Reviewed-by: David Hildenbrand --- include/linux/swap.h | 4 ++-- mm/swap_state.c | 2 +- mm/swapfile.c | 20 +------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 3c69cb653cb9..f6bd51aa05ea 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -512,7 +512,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 __swp_swapcount(swp_entry_t entry); +extern int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry); extern int swp_swapcount(swp_entry_t entry); extern struct swap_info_struct *page_swap_info(struct page *); extern struct swap_info_struct *swp_swap_info(swp_entry_t entry); @@ -590,7 +590,7 @@ static inline int __swap_count(swp_entry_t entry) return 0; } -static inline int __swp_swapcount(swp_entry_t entry) +static inline int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) { return 0; } diff --git a/mm/swap_state.c b/mm/swap_state.c index a8450b4a110c..ef32353c18a6 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -447,7 +447,7 @@ struct page *__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 (!__swp_swapcount(entry) && swap_slot_cache_enabled) + if (!swap_swapcount(si, entry) && swap_slot_cache_enabled) goto fail_put_swap; /* diff --git a/mm/swapfile.c b/mm/swapfile.c index 8419cba9c192..e9cce775fb25 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1443,7 +1443,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. */ -static int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) +int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) { pgoff_t offset = swp_offset(entry); struct swap_cluster_info *ci; @@ -1455,24 +1455,6 @@ static int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) return count; } -/* - * How many references to @entry are currently swapped out? - * 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 __swp_swapcount(swp_entry_t entry) -{ - int count = 0; - struct swap_info_struct *si; - - si = get_swap_device(entry); - if (si) { - count = swap_swapcount(si, entry); - put_swap_device(si); - } - return count; -} - /* * How many references to @entry are currently swapped out? * This considers COUNT_CONTINUED so it returns exact answer.