Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2738268rwd; Sun, 28 May 2023 23:23:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wj5ohb5jFhxdBSUZepP61FzBoRwgxufopUOjwLUMoJE2Zg7eMhfYZcP4lhODyqyBczAKT X-Received: by 2002:a17:902:c948:b0:1a1:d54b:71df with SMTP id i8-20020a170902c94800b001a1d54b71dfmr7606439pla.0.1685341402881; Sun, 28 May 2023 23:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685341402; cv=none; d=google.com; s=arc-20160816; b=MuPgZPl2HzD1Jqepjf2z53EdCwGq7XPC6MamBp4wdZvpoaZh/ATiIYU/Uq+NhWe8DY MU/BgHTAaWIu+Bhc4NmTN6zPWVoUau8O3ydMqcQLhF1b93qVJrcghpbaQPJI/brOXU0B fKgzVD/2K7oRfSJIuW0HHex40lIui82U9MuR23u+QwxEgpmAceg49AmBmRlKr3e0G+ko oEBmFCsjztyquO5Yv0efafT0JMy8rkURAFFR1kGd/1oq4C0h0Bb/2/XC5oMt9eHVESkE glg0cqxJT/c+1Um+pLnMEHuimd742bPDu9hbWzPMx98FVnicEIN/OM1C4iZ41MAVIaoh Pldg== 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=gTjWga6OsszRk2MnRlZS+LYEg6py10ZYIDqkJr0/juk=; b=kTb0nmu/gMZPUSz/kGAxfzCOazQiNQuToJptQuTM5SFAm7ocLwFZ7Fwz3oF6WcW6ml bljrQ3ZMSV1+Ur9AZLCZGk4EbzDhYn5MNVaS548BDSnEqD2HjBHNg6RxWUSVcyGFqax7 52G1GXZnsHg+nGjvmxF3AlZGnIno58jmSEZlytvanxsSR7PcLDWtHOwXOQCyFIvR1+x9 du/UO6+BOurs9JgPJ9Qgqci7B0eRxcP35N2F60MDxp9ekYz30grbdzxQJeRWlAXQ+1vR ODIjCv7q1frUpEFUEVimPVNcuAuUbVbSDCVSbV0wgJda+Y518ifh1J+ADtO1oolY0wb7 KrGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gr+8bmWa; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a170902e84c00b001a69f1cea63si3043549plg.223.2023.05.28.23.23.08; Sun, 28 May 2023 23:23:22 -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=Gr+8bmWa; 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 S229652AbjE2GOW (ORCPT + 99 others); Mon, 29 May 2023 02:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjE2GOT (ORCPT ); Mon, 29 May 2023 02:14:19 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA7FAF for ; Sun, 28 May 2023 23:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685340858; x=1716876858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kl6+gAKi9abH9eFCSqmd4OqB2g+JQSA7OXalXR3MGok=; b=Gr+8bmWaXfU1i2tRBYM3nL3PQXbZgt/268Xjsm3ZBxKQWYMWzVcN4SEH GTXk2TJds4Gwexzcvj+SHCAYk+1anls4nGNRc3CQs4g+4nvdq4e0GT7ow sEPM1GgBQf6lCgXyomfpD1ez3ZBzPHz1dcyfpluD8iqwnlTu+wQlFl+iv uNppnq6zP5xoovxHB+RjR397xsmApZwGhzO1VABvAG7Z1rEj4zV20TLef zu6e5SVZ0AHwR/NBQYD8q1zPc8DMeIyIERDueZynyDNM020OktvQDmmln Fcpxa9178gNssT2pO+A+/s2xOOS43VzsI5N8IZ5PowrraH6txJw++bLL3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357881783" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357881783" 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:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="1036079982" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="1036079982" 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:15 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Yosry Ahmed , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Minchan Kim , Tim Chen , Yang Shi , Yu Zhao , Chris Li Subject: [PATCH -V3 1/5] swap: Remove get/put_swap_device() in __swap_count() Date: Mon, 29 May 2023 14:13:51 +0800 Message-Id: <20230529061355.125791-2-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 Content-Transfer-Encoding: 8bit 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 get/put_swap_device() are added to __swap_count() in commit eb085574a752 ("mm, swap: fix race between swapoff and some swap operations"). Later, in commit 2799e77529c2 ("swap: fix do_swap_page() race with swapoff"), get/put_swap_device() are added to do_swap_page(). And they enclose the only call site of __swap_count(). So, it's safe to remove get/put_swap_device() in __swap_count() now. Signed-off-by: "Huang, Ying" Reviewed-by: Yosry Ahmed Reviewed-by: 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 --- mm/swapfile.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 274bbf797480..8419cba9c192 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1432,16 +1432,10 @@ void swapcache_free_entries(swp_entry_t *entries, int n) int __swap_count(swp_entry_t entry) { - struct swap_info_struct *si; + struct swap_info_struct *si = swp_swap_info(entry); pgoff_t offset = swp_offset(entry); - int count = 0; - si = get_swap_device(entry); - if (si) { - count = swap_count(si->swap_map[offset]); - put_swap_device(si); - } - return count; + return swap_count(si->swap_map[offset]); } /* -- 2.39.2