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: 100087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1308980vqr; Sun, 28 May 2023 23:20:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Hcb/2G1ImtRQezSNqXqygbwr4fW2iyAheNSg4YE9OfoGm1ziPsfq3G4YBe1oReoUTJQhp X-Received: by 2002:a17:902:ea06:b0:1ad:7bc5:b9ea with SMTP id s6-20020a170902ea0600b001ad7bc5b9eamr12684448plg.60.1685341244503; Sun, 28 May 2023 23:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685341244; cv=none; d=google.com; s=arc-20160816; b=uPTebiEWoCj79owgU1oH/XgS5sguH/gqqJivNxFQUCH3j2D8ZO6ZQtONVpdpoa76xN J2EENyafUCUtb8Ks4c7S3MuCU/b47Mhlg0mbu9b+U6mf2cb+JIQxaKqH/zCYO8Roz6DO 9prJyaBT6jxGnGpw8dhxFQGcjYe5nODnXKYIwGH/TB6wwW4o6pCT7CYP9+nO2xrdq6rH t/EQb4NK2f/NZ5PgARJQBtAebJqH6t1iAgVlnFfHfEfB2NS2mMZhY9Wq/6LbriLo4rK9 /l/yHhDz8ckUVWZ/qaZIXaGLAXa/3t4qDWxkbdrgdSaIZkNFpZHRi8rED79Vom8DJjaM 36yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3xIj4lwktXLAySa7XqSBq9+rB1Zc0DD28GkVkkU93b0=; b=xC0XgW+BWAhsPPkXztw2MnFLLHblYBXR+XhqU+52h6s1NsFx1nQt+qWKQ8dlc7GyAQ 7lRn5Un5gK73Gh/EoRrBRyLM8jEx0MXvIgkl9Vx0LZkE8m2jlMRFqoJdOSR99bNv/ERo 2T8hqtF6u/SpVeUqFIbmOQaJxqoO6599uLmP008QE9rf0TtHO9lWmN3EMLNH87RBAmNv 4ms8b8vCBr7GhXX4r+OECL5vXFuF6FZ/gyQmmIMo+KLSRP9M07VDjm+g79qbtizDnnnp MFZOds4swRR+/snFCQSH8nwE1+dz7hpr8VHmt0bw7rTFfOPo7ZpVpk+Z4b+2AzNucVEP I1JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZS60TbM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a170902a38400b001a804319df8si4939807pla.391.2023.05.28.23.20.32; Sun, 28 May 2023 23:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZS60TbM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjE2GOe (ORCPT + 99 others); Mon, 29 May 2023 02:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjE2GO1 (ORCPT ); Mon, 29 May 2023 02:14:27 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0B3BB for ; Sun, 28 May 2023 23:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685340865; x=1716876865; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tTttI7ks79EVJT0Lkkg7CgRwuqqX+cQLYrih/1r1FtU=; b=ZS60TbM6qYbN/Q3CVL42COpkGiFTtmto2DACxT0SSW21D9JEoDmHh7Cx ZHNrykD1KPtmB0FZc+9nL+MNg3sr9yZ3ZCxkFizkchdiDHy6wAg568PPg XdwLE+2T3omXzYVzcqxW3BWshiZe4UK+gVgGmqGt/iAyiJYf6BLlNOUiM IudLGi0St3ihKDDHY2Qmrumqs3J+AQT3tYjF3uFCdDy/hXYXvHoHBWylP qh5kQGpLN7oEMgdY6c+beM648+nu+q5ZgfwYH0V5chQtSr0Qgk4HYEQYb Pz12B7hf4p20YEDh+YPy0bgQsTSDsPEAqMUvCequ6LAOSsA+m8Q5rlCKx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357881834" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357881834" 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-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767208380902641233?= X-GMAIL-MSGID: =?utf-8?q?1767208380902641233?= __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 Reviewed-by: Chris Li (Google) --- 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.