From nobody Sun Feb 8 14:10:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93F4AC77B75 for ; Mon, 22 May 2023 07:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232356AbjEVHLH (ORCPT ); Mon, 22 May 2023 03:11:07 -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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" __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, i= nt n) =20 int __swap_count(swp_entry_t entry) { - struct swap_info_struct *si; + struct swap_info_struct *si =3D swp_swap_info(entry); pgoff_t offset =3D swp_offset(entry); - int count =3D 0; =20 - si =3D get_swap_device(entry); - if (si) { - count =3D swap_count(si->swap_map[offset]); - put_swap_device(si); - } - return count; + return swap_count(si->swap_map[offset]); } =20 /* --=20 2.39.2