From patchwork Mon May 22 07:09:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13249900 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 CD847C77B75 for ; Mon, 22 May 2023 07:09:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27ECB900007; Mon, 22 May 2023 03:09:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 230DF900002; Mon, 22 May 2023 03:09:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03D93900008; Mon, 22 May 2023 03:09:41 -0400 (EDT) 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 C9CEE900002 for ; Mon, 22 May 2023 03:09:41 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9C06FC0C43 for ; Mon, 22 May 2023 07:09:41 +0000 (UTC) X-FDA: 80817015762.30.3C915AA Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf27.hostedemail.com (Postfix) with ESMTP id 86E8140007 for ; Mon, 22 May 2023 07:09:39 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gr+Oscns; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 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=1684739379; 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=j3s2hbcFbRPF0j1Q7iTE/aGqXvtHfLbmjAyrk5TfK5A=; b=mWk9tNsGkGMkL1iqYQhAEv3DZN1zh+Y+IhgflZGpur5sumypLuSbhs68Um/vK8/d1ZpBDg v6qRquZBdr7dLLEeZlKzQW75ekINCSfrOaLQ+koI8TL8dXkrfchJZ77p9ssxdD5MJIAWjx oA3HNy67tdDZvxYWWxAlb8buWZkjtrk= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gr+Oscns; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684739379; a=rsa-sha256; cv=none; b=UW7w2QAc01XrR8QrxgvBKnlmpPKsyaNuoqYIS0zBgmQlAwd9xIyvSxswd1nGIqMSilmqLc RJ/OhF6lU7gfMQZn0I1KR9Rwxon9lNai1XrycvPcJrmM3BT9YOQIddVtnvk4W0yj8OhVy+ JYv4YjwmTKY+pUjzHON9QpO83gpmRrU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684739379; x=1716275379; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gm3LH1lmJVZ4Ay531OQCa0nV/AljYlwBGJj9BjRnG/w=; b=gr+Oscnsv/PJKvBvb2TAxxeIiv1sPV4MlNgnVlj5+VyAK1HpjckOV9UL NjVGsU9s1mx2nUwzjYp+TXcJMEPjyKibSNEw424bh85oFx5tOlAfykk60 xK4GjnSY0Q/GoyJHlivwFHY9HF2idHL4rZxNk60sjWjWqqphKil5th/8P EPddKRIV6Pw3UP/V1MIm5dFOv6I2HbUI0QH1V2QcU7nOCo6AobQE0pb4h vr3RDb9t9fd9oSsk1REjS13Vths379/jIBxBGwthX/Mmp/8kUDZLhmomw wjcVDgloa7iMYwQZayrzj/iqE+8mykWe0u9oKMQf59WpbcCsshz/70F1B g==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="337437020" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="337437020" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 00:09:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="773212698" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="773212698" Received: from yhuang6-mobl2.sh.intel.com ([10.238.5.152]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 00:09:28 -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 Subject: [PATCH -V2 3/5] swap: remove __swp_swapcount() Date: Mon, 22 May 2023 15:09:03 +0800 Message-Id: <20230522070905.16773-4-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230522070905.16773-1-ying.huang@intel.com> References: <20230522070905.16773-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 86E8140007 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 5jrnf7i3nrt1y9b1s4o86y5opxrmxb6j X-HE-Tag: 1684739379-84634 X-HE-Meta: U2FsdGVkX18x1s6NaaI/a4hyWCxus10Jrz1TXIVPtm6puR3Z8jo31BuLH9OKS1q7t8hfSZZ3bVKGMuAH6N8jAxi3sMpYmtU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91ms0DTnuGAAXiDSTbBKQxqz7nid33a2pAtvDZIvUhEj0HpLmse1cvEsWnZwSvzFukVPUe36uvrVTqAAI3GAsg49puvOyCwRJkHe4VVZGb9R7uuUlehaC0G+17hAkT40pPdsh7wxYNK9p286iAuXqNvnwOQeM7AUE1M/VyDsA7Pc8WubyhgQzGAcxA2l+2vCyYPQ9dWioG9BRpGeGRUbzwW2VNfs3wbXpWsGJgZ0J/eZW4lEHaBF3VMvUl4be3SRnZXP/c00Nj6ALWtK0ZXZHvwRXbmaKj2BqpXzugYbOoPbYJmWVkFIIaqKN1exanj6P3J85Q7iY/XS6Ug3ZrN5O1Brn/HtbmCiV3fY= 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 --- include/linux/swap.h | 4 ++-- mm/swapfile.c | 20 +------------------- 2 files changed, 3 insertions(+), 21 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/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.