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: 13812860 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 4927BCCFA07 for ; Thu, 26 Sep 2024 06:47:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAFE66B00A2; Thu, 26 Sep 2024 02:47:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5FBA6B00A3; Thu, 26 Sep 2024 02:47:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C27E66B00A4; Thu, 26 Sep 2024 02:47:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A423E6B00A2 for ; Thu, 26 Sep 2024 02:47:21 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 66222ACC75 for ; Thu, 26 Sep 2024 06:47:21 +0000 (UTC) X-FDA: 82605957882.23.737E442 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) by imf11.hostedemail.com (Postfix) with ESMTP id 9A57440006 for ; Thu, 26 Sep 2024 06:47:19 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="AbAcDGf/"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf11.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.217.52 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727333150; a=rsa-sha256; cv=none; b=e9GVuGLHq2cjQTWHEDjevY3zb1ro0fqa56J4R6p72q7uf6oWQUHekhhCBEmplxEzS3IXfA 3ag+NEQ7K1hLOccUQY/UVlj81RLv5S/ox9j10XWtdS327x4SHSHxKS/c+3qVoFbekJAxL+ ppRoLWkzuWprukF8efPhQ/inspWibAM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="AbAcDGf/"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf11.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.217.52 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727333150; 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=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=nsDW413I2TjzHPmDod75TPpB0ur2CDf9l9QaFP+mqw93x23QfUmg9t+Bmqncvm8bWL6HLy 0vCFeMs/jrhYDfb+nHgC+8XCGqm9CN+Q6ElXqyZW2uIhKkbs97W9gMYDd+yY9SZ22F4VmF OxHGgbvKI9nZjns0YJfMYqWbW3leVFM= Received: by mail-vs1-f52.google.com with SMTP id ada2fe7eead31-49bd3bf3b4cso324011137.3 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=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=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=AbAcDGf/KQdpRRkZIvFV8+DyBw3o8pYXau4BSXfsg+PcFQniLJQR4WjDCw5WuN8ZzR 2e9GRKOeDQqu7B+1CepXTLsLSUwGXlyVSaXTZsOBvd9jNgZIvqSOcbzzJjIy39UYeipF bPRcoFBdfFtZzbyKHzI3io0p5mZN2JSbMiiPILmMkNGqSI6QRKoqeIkcz3EF3u3VSDW1 /SHMnGAk9XrCT4teSs0Lb/c1nAxViCKCIZWPjA7ebIqKjSZLZzYqpBNAvhqeXDTJfRbo WXcTtOHMAaU7sX9y/MLbxKMWLvI6pZA77vLsfnYt7TMs92xZFyPm2rcI6XcX5SddyHdR noTw== 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=qSqyNSdjfo0xdzvsZbcXkuD05w4E3CnXSDWFD5Pld9+y38uDZEEOCDtDKOYy6re2oN 0Gj7Smbz0NUN0dWwvWCbeZSjecrloJhHTVEusLxB23mwFC/CvvoJd5znKUIe0rtTRFcC qUVSnZWweQknyfksWSk3ciYQaVnbmtJ0FGfjv9OqpNobz2haF3no3SKl8Znpm4w3skfo p6Thl3O/O1uglzDiDNVEQalN1kiBa/P0iHXnOoeKezkeRdmOrfgHc266Ef1HzDwT95mK tZDr0ntRQksOj3noLKrMZp+MipRJ7IhC6z6K7KBhHj8yaVD+XlFNT37j+loTzi0QGM80 6cYg== X-Forwarded-Encrypted: i=1; AJvYcCWYs9p0FFEYk4qkgpgYuQmx4eEfnJ5amWgD3IKNFbdiVWra0QzDq9M/Efcg0P86fNeJqdIk1rD3Kw==@kvack.org X-Gm-Message-State: AOJu0Yw+tCrvqlv7259W6RCQEF/jVlAHyphLwFJ3ODH66Af9Sr/qAOVw xiHqeeepL+NqSOFBoEi0orWSZYKWXY3tlmQiPF9BmQa206sfXqG0PL3J6xmHI7o= 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-Rspamd-Queue-Id: 9A57440006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: omhu3dggai5bg8tedbx4edwcc5rtxntm X-HE-Tag: 1727333239-518054 X-HE-Meta: U2FsdGVkX18PBTlgmOd30juuYADWyHxSdjzEIKvBdeNaLcpsy3Y6azv3oVVKCnW2ba5UiW3cPMg/+1/+AN5e/ItD5WJ5vHiVn3M+Bi905Og76hkmKNVfnzbKnasmXyA2EVSB7vr/FV1k6u2IMEoIuk4hrqX8B1hFWPFoXlXuo3v1re4I3Lq6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xc5o6tU08xAmdTkPH/wpDeC0NMLbZuqOAP3X5TC7narc26/fxzbGVZJhvhSk1uLb8npyMce3T4SL0ph0Sow3Z7QyhSrbBGeVQ+2wMylJLecUAJqQ2WWWRIXW6BrKsT59TWAEa5SYRYl82TdxaJFrNE6kx1salEfulwOdyFBRe7UqKq1cY1QazAEJNyLq3ByRUkSspq0LE= 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 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;