From mboxrd@z Thu Jan 1 00:00:00 1970 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 B90A8C77B7A for ; Fri, 2 Jun 2023 05:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233686AbjFBFxX (ORCPT ); Fri, 2 Jun 2023 01:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbjFBFxV (ORCPT ); Fri, 2 Jun 2023 01:53:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 267FF19A for ; Thu, 1 Jun 2023 22:53:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 80F8264C5A for ; Fri, 2 Jun 2023 05:53:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58B96C433D2; Fri, 2 Jun 2023 05:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685685198; bh=JkCLgSoY6/mH3spjDh4/wCaWaV2J+a3C8TmXVA/eMyg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DaxkSclIHjvLETuxnwisvEI5KvnhgJQMGKhGZ9VfWO0jiKgAQkOGCNcgZdl575Ary MJxCkBoGiAfGkzMOmjG/FkX+Hli+uK856rdeTB8edZQk1/EwytR+p151JNP12e5vA2 XukY8epZx3dPSVQoyYOs+6oIe9gjtMkgLuWpOgYFFnzbeSnCaoyKhDRNZNH0imk/XZ Klsg2cnIFa/QYnBCvXDumnVKLUd4WGDngBD6zB1eZ1pZ15iYPkvGqzGmxxkMHj8gV8 OWNREb8KjvKc1wEgxk0cj78OFdVEYfBQm0pm0kPX/cQgCv7p/qvSmSspSGoVsX+SZ8 2FW3MyqRMq28g== Date: Thu, 1 Jun 2023 22:53:16 -0700 From: Chris Li To: Huang Ying Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Minchan Kim , Tim Chen , Yang Shi , Yu Zhao Subject: Re: [PATCH -V3 1/5] swap: Remove get/put_swap_device() in __swap_count() Message-ID: References: <20230529061355.125791-1-ying.huang@intel.com> <20230529061355.125791-2-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230529061355.125791-2-ying.huang@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 29, 2023 at 02:13:51PM +0800, Huang Ying wrote: > 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 Reviewed-By: Chris Li (Google) Chris > --- > 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 >