From patchwork Thu Sep 26 06:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13812878 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E50BCCCFA07 for ; Thu, 26 Sep 2024 06:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=OPev8hwJDwNp7MqDiubdZo6m3A +P2CNrjC4DzlL4bnRDEM+lTNTwGlU0Xv2mMaXPGoJ3inubCZ4B5n2YBKUcRI/Vd+J+d6+q55dH8xd 33NHxpuoXAuULVjpjN7Jys8Sxkc41MFrXw6k3v6LgvzScggty6xs+9SDm1jaW+2jd6ywEYylhIiG5 z4B387fGndPwj1TFjn3rRZMfoj1FIPERF6ESdx2SMT7yJJvHZBBa8iASt6lTjLZnuAQjsdkytr+Ld oRgm4xzOroD1ZJNfBwfNOoOII0lYez6p0AViiuAGkQ0r1KSLBxDjE6FB0YI/hR7OsV+VzfrAV6lY2 g1MZBkKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stiO4-00000007Oub-3KZd; Thu, 26 Sep 2024 06:54:04 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stiHX-00000007NKg-44RG for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 06:47:22 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-49bc7387371so271698137.2 for ; Wed, 25 Sep 2024 23:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1727333239; x=1727938039; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=R7qC/HCrYKJGrFuunD5WZDpikoghB1FOIj0VNPgrfQ2AniOLjSeQtvZ5ebivIkSAyq UBm81zoWWlzXkc2lxpX2hf1UI/CzSBtGBRoMR3JjUCgbLYjTVBzeXvsLT5ZX167sXl4M 9ZSZAyPfTNP0qwWD3hW5sYS1S5RECrEbeyNkUUEKIJFD4dFydRCjmzi6ZU6pngWQykn1 l28INegK56+UwjE0cfNVAXScFtNgXWRoEu/ktkVIXVRCp4+vun/7DJGyy7EDt5kmg090 0cFzcg/lvO0vuyvGWJx8zoyXAcTAY4Cwyzs9FAHhC9PVe0cpZFLwiTH0tft7I1SwskVQ uc6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727333239; x=1727938039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=YtT3CgCiWbOJJV39my+UIptixmkv+D1ixGlmPV3Sx+0XrNoWI774x07qBf697stcRS K1WkE5kuFUF1TpnM6tw8BMfsnD8ywBd6ugFmMNnc+X/oWrzwKBg1t+suj6JWhnbsiDGH E+6vktZvg5RWFU3kNX6GkUNMxIuyl2BRXaayde7SnNyOE49XSuGeFdE+BVbYmKPLp2kI /bs34riRnXCZe3dWwRxengAAUJoTEsGDcM9ZbYRTpm7v5QUGZT8qYv4lqxaiH35jllwK vjJaj/p591Tvf+RRQeTUqx5H4d4byrSbVG8fBli/ibIlkLytqR9+XYDsJxoQSVW7PypT 3vfg== X-Forwarded-Encrypted: i=1; AJvYcCVqpCE+btnsJclkLrfVF6sCnjW8KVwEZm9CyEBv0mcGrgTLKIPLCmtijwTvJ96b1lhosk5pXntKSugBzxzw7/Xo@lists.infradead.org X-Gm-Message-State: AOJu0YxcU3fZ9XE2P8BGNnx/Wbp+aTGdlpIVHz7Lnuk0KyUgc57Z4Gyw TpZAEe80chd3lY04SV+9lTiAgy+fpTEkU/5xQ/KVXJcaIhqQJxO/0aanNTrqzpg= X-Google-Smtp-Source: AGHT+IHnBlRBHwKCxjYpHBiGYKwBIoiWGnfAohABSGODP2aU4XU9V+T3qIbiD3kwEf9HDK6sMKBjlg== X-Received: by 2002:a05:6102:6c3:b0:4a0:1cdb:3eb4 with SMTP id ada2fe7eead31-4a15dd1a11amr7011565137.20.1727333238630; Wed, 25 Sep 2024 23:47:18 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45b5257ff1esm23024611cf.38.2024.09.25.23.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 23:47:18 -0700 (PDT) From: Qi Zheng To: david@redhat.com, hughd@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, akpm@linux-foundation.org, rppt@kernel.org, vishal.moola@gmail.com, peterx@redhat.com, ryan.roberts@arm.com, christophe.leroy2@cs-soprasteria.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Qi Zheng Subject: [PATCH v5 04/13] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock() Date: Thu, 26 Sep 2024 14:46:17 +0800 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240925_234720_047839_2786B0CB X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In __collapse_huge_page_swapin(), we just use the ptl for pte_same() check in do_swap_page(). In other places, we directly use pte_offset_map_lock(), so convert it to using pte_offset_map_ro_nolock(). Signed-off-by: Qi Zheng Acked-by: David Hildenbrand Reviewed-by: Muchun Song --- mm/khugepaged.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index f9c39898eaff6..6498721d4783a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1011,7 +1011,11 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, }; if (!pte++) { - pte = pte_offset_map_nolock(mm, pmd, address, &ptl); + /* + * Here the ptl is only used to check pte_same() in + * do_swap_page(), so readonly version is enough. + */ + pte = pte_offset_map_ro_nolock(mm, pmd, address, &ptl); if (!pte) { mmap_read_unlock(mm); result = SCAN_PMD_NULL;