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: 13772828 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8962C531DF for ; Thu, 22 Aug 2024 07:14:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EA408000C; Thu, 22 Aug 2024 03:14:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76E3780009; Thu, 22 Aug 2024 03:14:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59CAB8000C; Thu, 22 Aug 2024 03:14:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 315CA80009 for ; Thu, 22 Aug 2024 03:14:20 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E1519413C2 for ; Thu, 22 Aug 2024 07:14:19 +0000 (UTC) X-FDA: 82479017838.25.6B64A16 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 15A81100002 for ; Thu, 22 Aug 2024 07:14:17 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EKJlXDEr; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724310841; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=toohyZrQNwk2kNUrhQFlaPWHYnggLi3YB3M65Yq8QzA=; b=GNYqPOuhHnfkk8Pe41lJrlTjY44uHgqBf4ShIaY4N++1B8BdFZDrHCMZBMghVyj+DRY+9R mmnGZWYrvgMJ+ZHNQvyw8KXvv1ww5DTHDYLQCV8DcIm/T+TkJ3ikriEyyPpnJH/y5I2QlB Jn/WRlvOfSQ+j++nFymwkKVZA4ly4WE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EKJlXDEr; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724310841; a=rsa-sha256; cv=none; b=jhhpmAOvAO2jNSySnNhx//a69xIrIqi6AYhD8Vac4vyIeAw5fjCWawNhlgWYYSi3jn2Tr3 iwGjlCj0pD81qm+l8vVYr4PdcZftP7C3ZC7PP0xHdatK6Tod4DLzEHvrDYby9gAmauMuPG DF2EjHZ/KU+lHI2rm1yDh+aa0K+C2mg= Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3db1d0fca58so279836b6e.3 for ; Thu, 22 Aug 2024 00:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1724310857; x=1724915657; darn=kvack.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=EKJlXDErYzpCd3L/lnlr34armL9lGqt7nLsi9D7hmb+vOsj1ZwShdZEeqQcarHY6sb MyQtnJ9HWoLVGUNPBLF2dxmXife2OeAQxvcaSE35U90M+XyfylesMogAfxiFJCKHkEvS sMzb1PuN782BPiEitiViWOzPgfqI+ANJPN6dmtwAWI7c42T2+AFQ+ONZJrvDowjx+TFy COiWixOQTWDgh5MaQLyb91qRbQALkRfuE3GCHlOxdSYCb1TEX6Xwh8TrIFy7luzKuEGO 3Hwg/HNabsUvh3OeWEr0ypSu3Ay61LgZFZQJ74q2oGGgH6jSehCv1RZUXsvdVMfyvOMm qKCw== 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=Qx4gypXLkIy65VuzvpsadtB9JnFAjtAodqNZZ3TuB3HIlr9FGXDNi95dDsFLlpty1k FIzHybYAY0tDrvtODdeuFiFWuCkpqso7lQPjdABhsiC6RkjQKoR1QYB/P1mo2LAtgM46 CKA/Wb5XvcFrCTRs4Nuc+jji1XgTY3+R9Yyo3TE3iAWLl1llwJN2/8iHsBwOxA1nGAKv btpOYGmCJB6q+AaviN5+2cLrHFHP4Tho1B5eSbO9B1pyE04wtecLWChydyVCmqCORxzs MQc6ZgPjjUVBhUt0+oF1kkCkBprITIv/5Yoj8rJRY3en+/JLafsoU4m+DQfXMyWU/bux 9V4g== X-Forwarded-Encrypted: i=1; AJvYcCUirZAGqLRpilfOToofWqlTv8jeVjnPbRrXDUqs2H9X1zMa/R0jbCF7oT2jSFka8vEoljmWjXew4w==@kvack.org X-Gm-Message-State: AOJu0Yy9J8MT2uVwFfGjBH+IDbVqd4AsDATfdBGeEqU9a7KruqUBZ6rt Y3DXsVNA/6kjS7HtwPPyXRzRESkG5uJu7pdXwQaI/2PQR1bkButgnV69DLsdcJs= 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-Rspam-User: X-Stat-Signature: 1s3nrsfzqwdb1iouuup9kxpa8p1xd8u3 X-Rspamd-Queue-Id: 15A81100002 X-Rspamd-Server: rspam11 X-HE-Tag: 1724310857-220935 X-HE-Meta: U2FsdGVkX19nDgcMwDndnFAQbEnyxgJRTsrl2MZS3KiUzrlc1cEwut1F7XLdzYEUXA2UCfSfMtdnBjNv0OJ5dGpFEBL3cWH7kypnqiMaIbWGL9AV/2cXREDme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4OFaWMOCMK4ccPCC7jxJZbRdKRi0Ly4oIRMhlp2KCo/sHyCDb/7jxJsVcllOE0We25juSbYRRDZcNY2vJiwH++58wuh/DE7Hxp6YgXoXfh7Em1Po2rvVkRe0fL+qTR2klAOcq8K/pAY8GuA21OMk0F/NY6/hA2uGWV3FvFCA+eeHnRr+TgxudOv8T8GlLnhK6NzKmLMoF16s5QysfcGXewS6D8LLGQ7EHHf3PN00SVj3m+ZwCdztWPaKuS X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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;