From patchwork Thu Aug 22 07:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13772868 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 A748EC531DF for ; Thu, 22 Aug 2024 07:18:10 +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=toohyZrQNwk2kNUrhQFlaPWHYnggLi3YB3M65Yq8QzA=; b=OptSDUCAl5fa3bbobuEoGGPApE NSP+GqB0vUt3KZBMUuKJzP+Sl4X80vpgbHZEUU1xgnBKlaOxoHH16JHxpFkylvN/Pm6A1NpSUxUZb wAO7DqX/7aZ+TF8TEJA9YOckUJug2HipMdVQxsBQXuMoz9LI4nAd4VWVbYWKSFemoxDyzDWVF8+UY jY6TayHgSXMhvhGBuYSl2nIljEDrhbn/Qbu9Qt+9ESopExMdhFckG5eI7qnbXSkKzYGou2e9b2zEb TNB/Q/a5zSMOw9rWfBDqQBCmpxJIqcAxTiW9HX9SeslFFW2sJAM6u68EouvP9fVpHdBKu/YVAaOdH Na2+eD0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh251-0000000Borq-1Ks5; Thu, 22 Aug 2024 07:17:59 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh21S-0000000Bn0S-1jrY for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 07:14:20 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3db13410adfso298689b6e.2 for ; Thu, 22 Aug 2024 00:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1724310857; x=1724915657; 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=toohyZrQNwk2kNUrhQFlaPWHYnggLi3YB3M65Yq8QzA=; b=kbgVWPW41c40VN4U0L4EVHMUGYRViD7yikXg298Vxkqy0PnT6d3rn1knB6a2vL3CIR 3cqgHSnuDS3nkBxOWq+fwh0qcCvEmvPsGbr17HKrP05lAP3JuNfPy53Lz8jiZvVscOb3 Qv771IjE13+bbx9sFssRwf72etnUxRObspY+Hg/U0BH24YxKQNp9FO55rB2pxYdY/XAN XQcEXmDEgNu4roH1EEJslfOxtS18A9zcDptD3JQbgsXcoNgFvBZsD8i2vs9XyaQFQ4DX cgxscM6sc3H28re6uxES90s62kiUfTUQ1qhBh4pbBiYP6UcaJIiF/w0mTyTPXzkJd/Gm VK4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724310857; x=1724915657; 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=toohyZrQNwk2kNUrhQFlaPWHYnggLi3YB3M65Yq8QzA=; b=O4WbDuDVigFWJd/EzSqI9MCcVWxXJYOPdXIBtLnJ0nTIE9PB5f5x+7xNdZ/rbtEEwI FGyeg+OaWAwrU6vTWZQpu3SLwqiUmlwa+6JyxKgpj7QAO1yzEOtDzK2h+dWEiuZRHupO mdV9TEweFqDsEk9VL7Z1NJO9rs2OWcaoXFjAoQv59t2wAUUSRnM5LgVunUGYxC8UeT4M Mda/FiJiiD2PfoAQZiuIgaChDUmIBDIoH6Nij/yuTqxW9pWtlw6SrKGdbSZDqyErpSWs NnL08ROOHFwu2pJW+kl36O3dA9A0NfmfMK9v9I2IWi43MDnO8l4eBBSM185HkooRuzKD RuMA== X-Forwarded-Encrypted: i=1; AJvYcCWlBuALtYK+3UprqrPsU+GFB6T3kU8zi4dMKvTAWzRwHIkiRsRsM8lWO3fu3d8e+LQYR/JiNUPSNB/LkxRJUVdm@lists.infradead.org X-Gm-Message-State: AOJu0YwYIZ++sOa9cILmrOQkJuHlkeYnx+NSQ/1+X7sVIVushO8gRMfH NtAiN7zLbrwZBQRNR3P+/RQG/Zpt/hCxhBrZ63TWJM4830TzUl1IcipHqm77Yfg= X-Google-Smtp-Source: AGHT+IGgjighdWtbrKc2Se12Iutexgq8AwJLXy8Rdygo/b6qt6ZS1aEL6K5S14xFU0XlAJpbImifsA== X-Received: by 2002:a05:6808:179b:b0:3d9:38e2:5392 with SMTP id 5614622812f47-3de195c380emr6158328b6e.36.1724310857179; Thu, 22 Aug 2024 00:14:17 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([240e:473:c90:f96:d029:ea8a:4e6d:d272]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm695095a12.16.2024.08.22.00.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 00:14:16 -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 v2 05/14] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock() Date: Thu, 22 Aug 2024 15:13:20 +0800 Message-Id: <2b7dceaa12da273c6decf92e3bf2ebc4f4e85ec5.1724310149.git.zhengqi.arch@bytedance.com> 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-20240822_001418_472526_90448D8E X-CRM114-Status: GOOD ( 12.26 ) 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 4a83c40d90538..53bfa7f4b7f82 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;