Message ID | 1bdb1ec4a30acf6b3a376f746c96236328904768.1724226076.git.zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 0EA88C52D6F for <linux-mm@archiver.kernel.org>; Wed, 21 Aug 2024 08:20:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 905956B00D5; Wed, 21 Aug 2024 04:20:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B57D6B00D6; Wed, 21 Aug 2024 04:20:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 756ED6B00D7; Wed, 21 Aug 2024 04:20:51 -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 5455D6B00D5 for <linux-mm@kvack.org>; Wed, 21 Aug 2024 04:20:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1581E120BAB for <linux-mm@kvack.org>; Wed, 21 Aug 2024 08:20:51 +0000 (UTC) X-FDA: 82475556702.27.19C33DF Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf05.hostedemail.com (Postfix) with ESMTP id 3FBDC10000A for <linux-mm@kvack.org>; Wed, 21 Aug 2024 08:20:49 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=JFsIGKtW; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.174 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=1724228409; 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=y8nsSUZs0Rgdiv42AW7Io4vKbgKEW01jAKVQTF6mEcw=; b=eg7hFC1jsV36V5XMgjG7AqgF3drRu8bhd0ptOuQyJGzUBCp/45DjZUxlpmsqgcu3JDYk+Y meZLLsdZqx6MJb8feic4+MSie/4sZ67P4EZ21b8cUO9BsqZibgPTXArHhoIDW0MvNkAh/g xNa/1zuaqOfNbU7X25DJMe0cQtcMtXc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=JFsIGKtW; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.174 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=1724228409; a=rsa-sha256; cv=none; b=UvU2KUCV/FUm5fCSrR2w9oQe6M9xxSKB5uGqgyAJ9+D818+FgbbAyQVAFByCcIY6eZIYBR HqcWdej0YiLIwcHF1vMhMTdiMtcEYvO5qSNsOwqguvN0sb86Ej3hFK8SHOOMulxOFqcVUL vaR5quT5OQyqG61U/zFzY+BPPnLOqmA= Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7cd8afc9ff3so221502a12.0 for <linux-mm@kvack.org>; Wed, 21 Aug 2024 01:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1724228448; x=1724833248; 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=y8nsSUZs0Rgdiv42AW7Io4vKbgKEW01jAKVQTF6mEcw=; b=JFsIGKtWXEdIxquj/1dpz+hdBmTV+9juyi3sCTJe7zdfoDQ5aHTobIfKf1S1zbjbti B3ccDIDN3BeiSAGZGTFq2nDbfkoJUzSuuaXTvJexq5VsquqtdQkAaQt1ktTU4GJcv8LA 6/3X7Z41wjgjXnCnUNUxW06ot1PYxnLP/FV+VC6UmM4VVFT1V5f/F6glA4TejJ/Ob5ks JANWYZGaTc6yVNp5Ljgjs4mK3phQ2Zs/gWpEABaZkdtfwVRFtKs6AFdM0CnJLB3WSysU qLWazWn6TJFJVXL2MfEpMpWnpExfnoCLpIBrVAOUkyDg+1hI1YMQJ1tcAascvkFQ0cIv +G5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724228448; x=1724833248; 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=y8nsSUZs0Rgdiv42AW7Io4vKbgKEW01jAKVQTF6mEcw=; b=CRu6LnNftHC8xlsngNk+fb9+QET51R4ljO6RjN/r8boj8XjeJhDRR/QGM+wBGjisJ+ 2dfj5M80HK2yHYML9IDfXfmAlnvDYOyWibWrIpXKnoMJVdyFcS0DZ5FNlb6QDIO0id4C xAowC7YbGoq4ehMiw0a/ADRqvtrPn92iUqfCXtyNn3+zfA9KWzRnBzAJCVeDpVHpMCyk pp2b4bCeqKikO53jfG6LNV5/Izzt7uDTLalS/pW/SNxE/VTvppjGmNVYhm3IiTWtV+JS YiHFTpt257tXcfoo84olU6d/uCVt14HIvNrK4TnQL/B+YJHkZiyiAOrqguE9/AlFnGIT Bsnw== X-Forwarded-Encrypted: i=1; AJvYcCU9Z0b2Ge+ta26MaNeZ5pH/iT6O3O554TRprbqAPgybRKfU92ieMmY5kUWZUB+ATdlsut/UY617Dg==@kvack.org X-Gm-Message-State: AOJu0Yz8SJIOSaQVhSorJHuzqGlME/ioSD80F/vm4mehfaiLvpXAJq4a lpkoEPsw8tWLBk4jAvrYE3tjCztsNsjtoac0pr1J1vbtDntz8WnDavCvbuQ2rHw= X-Google-Smtp-Source: AGHT+IFBw9G+gRGiVw886HN5nxLIybNKSDx7re7KNY7nJCh1bBtNFP6GTlUB4MiVeFJVy0IWyCdYMw== X-Received: by 2002:a17:90a:d987:b0:2cf:fd50:a2d8 with SMTP id 98e67ed59e1d1-2d5e997c3demr2593063a91.7.1724228447873; Wed, 21 Aug 2024 01:20:47 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d5eb9049b0sm1091453a91.17.2024.08.21.01.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 01:20:47 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> 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 Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH 12/14] mm: multi-gen LRU: walk_pte_range() use pte_offset_map_maywrite_nolock() Date: Wed, 21 Aug 2024 16:18:55 +0800 Message-Id: <1bdb1ec4a30acf6b3a376f746c96236328904768.1724226076.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <cover.1724226076.git.zhengqi.arch@bytedance.com> References: <cover.1724226076.git.zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 3FBDC10000A X-Stat-Signature: 5aakwiktd9zib3nm8rhp98rx4wqr11ny X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8JVsOR12afqxDqPBvAezjFnvOMLUAjgFvBBDKtkpzNizuShwVVfdoyQZ3WevPmVzH/8FTVEL2ewIVyUarGo53I70CgvuECCzx70F14JpEa58h7lM87gM7UOgDY/KoqgUAWmekuoEYMJxlzIR1zndS2aEyfnoaAbL3uS7XYMg2QlLIqdG+WYYpBEiJQedT7xR7FUUcqtwwouSJGUyvLVMsEcu7iaXNTguV0Wi1D//LpS3klMopoxsMyElknUPi67k9evBiqlBzM/nB5wGq7VZMq1vP5zwg8v4adr2vkKFk5vpqChE3baqRYvBsyAfAvlEaguf0+rZtFciAqS4F5D4PBfOKhjVKCCtEVium9fdDDWk6AIpjioU1QurKu4ldrnLH0BNQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
introduce pte_offset_map_{readonly|maywrite}_nolock()
|
expand
|
diff --git a/mm/vmscan.c b/mm/vmscan.c index 5dc96a843466a..a6620211f138a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3396,8 +3396,10 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, struct pglist_data *pgdat = lruvec_pgdat(walk->lruvec); DEFINE_MAX_SEQ(walk->lruvec); int old_gen, new_gen = lru_gen_from_seq(max_seq); + pmd_t pmdval; - pte = pte_offset_map_nolock(args->mm, pmd, start & PMD_MASK, &ptl); + pte = pte_offset_map_maywrite_nolock(args->mm, pmd, start & PMD_MASK, + &pmdval, &ptl); if (!pte) return false; if (!spin_trylock(ptl)) { @@ -3405,6 +3407,11 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, return false; } + if (unlikely(!pmd_same(pmdval, pmdp_get_lockless(pmd)))) { + pte_unmap_unlock(pte, ptl); + return false; + } + arch_enter_lazy_mmu_mode(); restart: for (i = pte_index(start), addr = start; addr != end; i++, addr += PAGE_SIZE) {
In walk_pte_range(), we may modify the pte entry after holding the ptl, so convert it to using pte_offset_map_maywrite_nolock(). At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the ptl held, so we should get pmdval and do pmd_same() check to ensure the stability of pmd entry. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/vmscan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)