Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1772332rwd; Thu, 1 Jun 2023 23:05:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DKIx0BPjniogyIjphSv9LaaeBrA9jF7HGKc58CUlrkEQUf7+ZTpI9LZ0CQz/FxqvM0Iaj X-Received: by 2002:a05:6a20:3d87:b0:10f:f672:6e6b with SMTP id s7-20020a056a203d8700b0010ff6726e6bmr9013885pzi.5.1685685914738; Thu, 01 Jun 2023 23:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685685914; cv=none; d=google.com; s=arc-20160816; b=W1gKZaKyPx+zw/o8A7RFBOMByjxpuW02PnQpuct8PWaVynGUJ0jdzfhel5kof9Xj8T hDN5F27u6elg3CQdtJ6SlUNPQncOUbyp7ZdBWb811iM+Qv90n/OrSBqv06GhdrkO/NAF RpT2/jJa0oHVv+/51CRRydbiSUQiWBAE/qdmGBukTs0mxK+hs+uMZKQeSZ142BuqG+FW Tmq5Pdi/gq+Kk5ttgbef1rhkDUoTk1kgkyKUAQ8SOQvb4dk+b59BUx5nxqyoZymUOMU4 Nl3jMDDJrY7silmyNl7YgBSC1AKA/1H09ZMLHh9UQXonpotkieqmOnW4IpHODRmuw2Hl WNfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kJPr5ghcKvRu5s4hDigff2dHcB6JH9KXIu1XdSMJD8w=; b=x4zTzjj1GLQODDAD+hlaOSCnrASS+OZLcRPUfKEO+dGd+/vB82/OceNv8j9461LoJ+ X5FmateVq8P77b6QUeqTUNPkhsXhz3jYe0jXBqKgkYhc/oKkLIfAAxbVTdJzg13DAOGB 8lM2A4rLBn/Yy+qVB5XsZ35lA3NrtmwwugI4oCgGJohasb3DYv+5yRHMBCGQbSzpts+w hv7HP+bZ3vgLyAIBr0Uh2S0eX22WxvLeRDk6LmhPZbmHqsvkuX+/7EmoHdJqByFqJHOd OMOjiCuaie5mADYQc827btrpvvOpP8LmBg2B9n89l8rWGSqj8LHbgMpsjuFNepe4/7mX Yblw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DaxkSclI; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170903121100b001aafe3f409asi400166plh.205.2023.06.01.23.04.42; Thu, 01 Jun 2023 23:05:14 -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=@kernel.org header.s=k20201202 header.b=DaxkSclI; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233676AbjFBFxW (ORCPT + 99 others); Fri, 2 Jun 2023 01:53:22 -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> 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_PASS,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 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 >