Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2738325rwd; Sun, 28 May 2023 23:23:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sKYgWqNlBXCCZ6RQonxOWUsNLqYlYW6owLkFEkBcHLB+JtEAoOBZ7bMwYuLS7s51eC2iK X-Received: by 2002:a17:903:2291:b0:1b0:4c6c:716 with SMTP id b17-20020a170903229100b001b04c6c0716mr52898plh.4.1685341406047; Sun, 28 May 2023 23:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685341406; cv=none; d=google.com; s=arc-20160816; b=PR8GInYPgwuWnQOF04nvEO+nS3eIEju9EKlZgeP9qEGKCyciChe3ng9kLuohdBzHFi Ao2Zktkj3nV6jzo6oh6n8c+9MJkZa4Hl4I9at3FUHeXIf60ALT91lc+Y1YuPCEj0jelH BNrT2IORh9TvjO57S3aF68YzIyKoOZNcwCY8ug7eJ4+baTwSf2HrCZEApy8h6PcFVTbV ccdzBCNSgsOp5S+3TP/AuYvENjXBXOIzdqEpQfzHozkLHEAzy+5uSpuaBovnzt1JBxu4 16djedMIBuklbe+gJL0MQuHWuN/J3oFmDF8Eo/JazighAwSwGFvRvuPcMdfBVeiFdXVk LWow== 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=OXQpXUyD3R4+lamxgQGM0SaoDtlSH6lRmsX6AawfPEk=; b=PQmIN089FCeSEY7btRzho0EvUQu/KELECNJClC1dJBlU/F9ge64169+/faU0/KuoFh 0o7JLv4lr0Xl0nZkEXhub7mk+U/Bqnu0NCG0WM0vjiOdqOAzOCsc238JVQRp0qRJEH9F TiufnGVUJR31W9Rze49WFCL6tiLCv0byvj7he3okDUQDAlu1CB5f01bkbuiSyGbpnW/Z +oMoZL6R+XHbIIMsS57alGs/WSVsAwNFCqR0uRKfStRdINJuk3lpsCPMigkRHY7KAdl5 DGJgSURIQUOF6/cV+7NYzLHO/l3NdqvqtYwA8yodJPoSsCiueCpsJNJ1ZpI0aI/XubkX X8HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cJxrFtlC; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a170902ee4500b0019cec50618csi509545plo.159.2023.05.28.23.23.12; Sun, 28 May 2023 23:23:26 -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=cJxrFtlC; 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 S231437AbjE2GOl (ORCPT + 99 others); Mon, 29 May 2023 02:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbjE2GOd (ORCPT ); Mon, 29 May 2023 02:14:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F8EF1 for ; Sun, 28 May 2023 23:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685340869; x=1716876869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BU9rFfysv4elNLJ2GHzqi2liUatC3EzDYJWAUuFdw+0=; b=cJxrFtlCwIuI2Qjv4t0svwIYrYf8UN4laXVC3qIsq+xZpAtNS+1bPG4V w2QJ0pcsaEAY83MpX20jynYcuQx85NV01amjXU4pw5N6Wce5yK3+ICZco 41D0VgIKfZ9U9tBkRoE7eoSFx7zxvflNl4lFRqZMY45WpwvyXiKECzKYT elWTHgSozyruFTewpFqcuPxnm6cR/8d9Em19AQ7PGiPVR9H9wt/F3wPRA 2g10+RcObIGDHtdXWDAVaetUpmjRsxIdChk2PtJOWHZ0/DvM+vgpYAjU6 bVaEpse+rgKHOv+FqDZRH/c4SEyvpOKupgPB0uKd3jBU92DGtOy9Zzq3I A==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357881854" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357881854" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="1036080010" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="1036080010" Received: from azhao3-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.126]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:25 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Yosry Ahmed , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Minchan Kim , Tim Chen , Yang Shi , Yu Zhao , Chris Li Subject: [PATCH -V3 4/5] swap: remove get/put_swap_device() in __swap_duplicate() Date: Mon, 29 May 2023 14:13:54 +0800 Message-Id: <20230529061355.125791-5-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230529061355.125791-1-ying.huang@intel.com> References: <20230529061355.125791-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_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 __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