From patchwork Wed Sep 4 08:40:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13790188 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 384EDCD3431 for ; Wed, 4 Sep 2024 09:11:05 +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=tk95RNkkDehbkhamWLayl+Zcs7 nY+u2P0pjaAdS4TDbhn7fzycq3LuB2iwKmvR8VUkVYmrTN4Sa8TD/L32j0XWmZvHedGy9GFex+dXV M2386IMX32VNFuAB5wqvSV8GBNG9jVGk49+PAKL/nO6KtdjtEsHh1PSXo7IeOqChFNOHjE5hpbs8x MJUJ//N+EB/+37ZLAHP6bXq2lC9XK3WE02gyECuEthJF91C56I+STvhj3c7VYMnMWocFi2GlMH6rT hK3QAGP1Kv+CsHwK+vZ/x/R4dt3aJwZqFKtl8/eqZ1+chbTjWTbSVbTGyBdzLzHt+TfH0G+VkmoNT CJB1Sa6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slm2Q-00000003bwj-0Z1H; Wed, 04 Sep 2024 09:10:54 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sllZk-00000003TBd-3vOy for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 08:41:18 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20573eb852aso3453425ad.1 for ; Wed, 04 Sep 2024 01:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1725439276; x=1726044076; 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=JG4ABvCFwlyto3OQfNEfuh7r1skbu1Lx5vFKpxfNV0MZPj5KQK4MRNY8bjUp958Jwo K+/3S/qgD9H6gMpL3FMvNrkGBDIUCG6UIYeu799vfSh3syVevlq4s0Kf+YhWkC4knQ+u qEFl9qMPk1pBr+NLRgAY1PbbWtDPDoclK4t4fvmQrbKuUneZhgbQAxQQEO3yNzFqI+7u /ZEZnbYEvaH4Xz7/xskux82pG2r8/UZKdtiPkAg9e7Dx82044O4wCX52Tb2G7Y0VaHQo ILVWAw+KhXM0xzhO1SYrKrVLOwhq+g0kfPbfUJ4PekCHDgH9RWCEF3HpBAhoIoiGjpim mROA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725439276; x=1726044076; 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=DG3MOfXuJTHwsDZPvCyL/VurQWJHOi537Mde86dDd8dA86xeEo3FCr+L4GV1zVCt2d fLrctLuf+2L28inPOxbDcAaAp5V3jrxVNS6gwBDshbtzcNvSqTQA/CM+HslmeYwvAZSa Y+TdJD4nrfdFeTja1E93g2qIBEV+bzhpJO3LFCZdjlKqJMxj6d/XvnjSNKojeX5lUKPI 3l4qRXj9aMjMt6kQ9FDEJ2+0YMTBzxCf6S2lElNiSE8EIMoztutO/7/EAc/MQRXZYJwA hOf918HM8JkoDKJXwvhlAuTJUx9cuKKkAAWW7oejnoppQbgGDqQQwbAUfNAok67PHL2O 1vbw== X-Forwarded-Encrypted: i=1; AJvYcCVIVQzrknYPZ9l4OWb4cWQNNwqT2snVmCrjRLWqMyTPDxB/v+Fmjd60g2gpbaZ2wXbsD/PaHFxe0Y3YzMf7SUui@lists.infradead.org X-Gm-Message-State: AOJu0YwD/pcvaMJOeoG88s3tJoGbBkSRHN6cs2iMo7ijNXVApU+7mftN LqofL4v/3eZ3SnsOQrshbUeQRWk7jPx8ODOK/uilhBzdc7U2Vet5E5Xe1WOS6PE= X-Google-Smtp-Source: AGHT+IEy+qEnEqpj3sReiKH3tPFUkwjqR7spuVkWXeQJodyHWsfCM0cenE/z+pCdCppofQTZA+ekKQ== X-Received: by 2002:a17:903:283:b0:205:76c1:3742 with SMTP id d9443c01a7336-206b7d00d3amr22901025ad.3.1725439276249; Wed, 04 Sep 2024 01:41:16 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.242]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae95a51csm9414045ad.117.2024.09.04.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 01:41:15 -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 v3 05/14] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock() Date: Wed, 4 Sep 2024 16:40:13 +0800 Message-Id: <20240904084022.32728-6-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20240904084022.32728-1-zhengqi.arch@bytedance.com> References: <20240904084022.32728-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_014116_999198_FF286B19 X-CRM114-Status: GOOD ( 12.41 ) 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;