Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1786384rwd; Thu, 1 Jun 2023 23:21:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7uhPFhMU/bnZhxPIW6/lkmKzwdYpM4qH9mGs1LWr/6J2B8ul5MgqqnmMf/jK8xtE4M39cc X-Received: by 2002:a05:6358:7f1a:b0:123:a2d5:fb6c with SMTP id p26-20020a0563587f1a00b00123a2d5fb6cmr8463361rwn.3.1685686909138; Thu, 01 Jun 2023 23:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685686909; cv=none; d=google.com; s=arc-20160816; b=eR+AQN/AilcuqPC9I9Pi/FRBTeqVBLkHtCrKkrOg4c21pTlKwW4fX32ROuVrkBE8TQ N4N7WqyV+reoUT7XyBOfN+kHGbYEy4b5hsdqOw1jRQ2Sb0T4dGZCGD/VABLWvfxJzYUB zsAIPAxNkQj1QMv/igPAwuK16tRaf+Uw97GneUxu6S4khAatxYZbMHg0qFHQYyw/8F4Z mQnIH6OPOPSc+RJT83FdEyS0VtZ6wI5jbZdeh0s3KXzR+YbnZe8YdN79zr/RrS7pEIFf qjEeQLjF+Qax6DWPhVEjOECz+cCF7Tb9ErWdz8SpmnW/rMNC4FWOEb1uVWPCKRlPn5+K SDNg== 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=uXqfDA3kiCN9qMlnUjuY73MJVdDRjpN1FZjujlht8ds=; b=JddkkoeOD5XdlC2q+b4TNyb3Ct/L8R+cniBJqO0XLQT0IzaTSICdomsuKNNUqsnFsN s5Ro3L3Zm78DzdXEDmRN46W/IbDMY44gC3gV9E9rME/WDXn6dQUZd0608cXmv/9FE0NR kQ8JOSwfRchMtXdZ097J6hlHlAsAIEDd4A/WxBIRp4qKrFXXOqHJjyRmn4xspAiIvS0P GZQworLnE0g3D6Mo2AFVNXJ/YDvHPTSHeJ7RadXeuiY3Oi2XZ8Px/vcb3roWjTj8u+4v EmgwrXj7yemqk4IjkXXCXUrP0XcDxZnXwzPCAyfO5nGMlQYtIbCsbhukIJ5ifBzUswqQ qGhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pb8Ubp3R; 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 w63-20020a638242000000b0053011490008si431427pgd.885.2023.06.01.23.21.35; Thu, 01 Jun 2023 23:21:49 -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=pb8Ubp3R; 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 S233664AbjFBGIx (ORCPT + 99 others); Fri, 2 Jun 2023 02:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233709AbjFBGIu (ORCPT ); Fri, 2 Jun 2023 02:08:50 -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 77FBD1AD for ; Thu, 1 Jun 2023 23:08:47 -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 E1067636FB for ; Fri, 2 Jun 2023 06:08:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C70ABC433D2; Fri, 2 Jun 2023 06:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685686126; bh=/8Fx5MgOM8Y3VrkJfY+HxO7JcKDJ80iHzD29KFbu03k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pb8Ubp3R6tgB8H6vTQGgCH3tzWuD6oyOcOcf3ttcPYGj23huLTU0fHliTjPjmoDmF S4sDcA7+EXMHvkpmS2kTOOaf7woygcNK+jA12+b7X5QQn0szOwPe7nv1VasWWku++E UaXf2nCcQW9R7RPcQCvN+Vl2ItI34SvfzRqE7Oz6PN2Z6HAMyHFwrLD3Mre4s+HI5V i5geif2esZ7rlS9IwLkVV4zoMMyWTSJpV2EgoMIPRVWak7g5haPUTAw13YWgILQsnE cXzWowOFTIyJeUX6ayuvHs7T7t38btPgaZnC8Dvls9o7WHVEcOeh5hS/530SQ4Z5NX c+w75go6yxWew== Date: Thu, 1 Jun 2023 23:08:43 -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 4/5] swap: remove get/put_swap_device() in __swap_duplicate() Message-ID: References: <20230529061355.125791-1-ying.huang@intel.com> <20230529061355.125791-5-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230529061355.125791-5-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:54PM +0800, Huang Ying wrote: > __swap_duplicate() is called by > > - swap_shmem_alloc(): the folio in swap cache is locked. > > - copy_nonpresent_pte() -> swap_duplicate() and try_to_unmap_one() -> > swap_duplicate(): the page table lock is held. > > - __read_swap_cache_async() -> swapcache_prepare(): enclosed with > get/put_swap_device() in __read_swap_cache_async() already. > > So, it's safe to remove get/put_swap_device() in __swap_duplicate(). > > Signed-off-by: "Huang, Ying" > Reviewed-by: Yosry Ahmed > 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 > Cc: Chris Li > --- > mm/swapfile.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index e9cce775fb25..4dbaea64635d 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -3264,9 +3264,7 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage) > unsigned char has_cache; > int err; > > - p = get_swap_device(entry); > - if (!p) > - return -EINVAL; > + p = swp_swap_info(entry); > > offset = swp_offset(entry); > ci = lock_cluster_or_swap_info(p, offset); > @@ -3313,7 +3311,6 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage) > > unlock_out: > unlock_cluster_or_swap_info(p, ci); > - put_swap_device(p); > return err; > } > > -- > 2.39.2 > Reviewed-by: Chris Li (Google) Chris