From patchwork Mon May 22 07:09:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 97121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1269117vqo; Mon, 22 May 2023 00:36:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XQUzeoZo9Fsf8DdMzYcT9SQ+6MNco1C1WvlOwfPSgQCQ3bNHR4OkVl2Aj65XIKwvWwQ6T X-Received: by 2002:a05:6a20:a58f:b0:104:2200:8933 with SMTP id bc15-20020a056a20a58f00b0010422008933mr10846755pzb.62.1684740960308; Mon, 22 May 2023 00:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684740960; cv=none; d=google.com; s=arc-20160816; b=obZ5MlYsKDqmjRAE9kWRwd+Z2AqAORQJKEPlGR5/81UoSxM/CV5+xSn2KypwXNjYGS skDcYMrDWvjiyVtgyGCxTNjUbXXYKNWEKSc3u0fEbcMu8coWcqC7pHCIvgUziWAiYdhU miYNpvebRWaiS0iuYsUpJQKvh0COShjCAkctjyXahHAZE/uzju/5w3cb7sdhzp75GZuG 9WUWphAj8uzZD2ppfaOHM2xG2eYShnRAOUq+zKey2Akxjqebus+r2hPzRrT7vps2ytco HHeY8a0tLFIZPPA1pz6+2PJeBRa1r9ZCBsUz2jG2uqNDKpx1E67oXbvB+IPwFS8aCfz4 gRWQ== 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=AL/AHAqtFJKsPwKJ9HgR1WU6kXa6VgMjAHwiDhHscpI=; b=P7I9kQycFm19jsR1ExC4P76E7kGII/vuc6WcDjqtiKELtShTFf1Xh01lXtgkkcG7pC EE9EGsVDUN0jhgsuDE7zlHbnbpw9bIlIbFjapTRdDA/L9bCJlT7lsH92THvwHGvSR5yF /ILh8iWPaydbJZJp4Ar3CaoLvSJkl+OXcHjXdPb4pq8NKc+Wmx+/ZjtrM7U9DXVGmnnW kv4MZHkJgr4JAtW3P8/TQbOrfdUMC/GwqJa72SVYvSIPE8n3DW7tIj+eRjGM1xn7R/LW 4FnpOljNSqV0BisWHc6cuGoDjHcny1Pxy1FsCH+MdVraJK8W4PAGndJr9KcVIqnl+QQU Yvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jQ7kzQqN; 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 x26-20020aa7941a000000b0063b76333d9asi4339888pfo.217.2023.05.22.00.35.48; Mon, 22 May 2023 00:36:00 -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=jQ7kzQqN; 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 S232408AbjEVHLF (ORCPT + 99 others); Mon, 22 May 2023 03:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232457AbjEVHJ7 (ORCPT ); Mon, 22 May 2023 03:09:59 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81675129 for ; Mon, 22 May 2023 00:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684739375; x=1716275375; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CAvLy4/ErwSMMyC1M2gR5vND9soNKvGVJOF+Oh8rPBI=; b=jQ7kzQqNSlMe8jzZScES1iN5M7sHDn2IentIcu0hBl/1rAre/gNE7EJz qyEN+e1EcjZ2s2CfIEFpUcpSw+hNHZ+g3IZEiYvtbgfypMHWI45qCcv3r X0oX5LXcc4ry3oo5KeQ2xoQAjkQAsISucPjYIJgVjOEwYNRnWfxJhlnm+ nitOjbh9tuk8fWrsxnN+2xHmHHE8Uwl2uE65TFkAVvTXhUMnqWoIsW4+R 9c9PCzAsD7iUsJwjDIYXre0tp4351VB4iffcMJqfpM5ZA4B3tG9luGEMA 0CKsxzS+Y/LWj5C+tjF2TneOlWlzCXEDAV7mXMLCnmmMiDq/YCMNMq4SP A==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="337436974" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="337436974" 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:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="773212678" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="773212678" 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: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 Subject: [PATCH -V2 1/5] swap: Remove get/put_swap_device() in __swap_count() Date: Mon, 22 May 2023 15:09:01 +0800 Message-Id: <20230522070905.16773-2-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1766578937295719510?= X-GMAIL-MSGID: =?utf-8?q?1766578937295719510?= __swap_count() is called in do_swap_page() only, which encloses the call site with get/put_swap_device() already. 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 Reviewed-by: David Hildenbrand Reviewed-by: Yosry Ahmed --- 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]); } /*