From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A51FD606A31D for ; Wed, 28 Oct 2026 12:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nprjpfR1; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gMw9vBWY DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=XDLGxetjOdWvM2BjmE/R/hMhrkoTmo6urtwGpBjQv74=; b=nprjpfR1q4sGt9eFAjECjVmU1p xGX0pYqPSzP9DugDUsaUMJZ7rSMOPJCYnk+68uuEP07KXt407JV1mm7JpL3ik3pzW9KYpmd7GhF13 SxX4t4U/yYIsBbl+6J0qBZQW5EQR1Jlt4gic0itb9Znnoefuq85HFEA+4s/r81f/uUQkPb/LzJSoO GG47r7I4+uKlf70lH4dArZChqrtaZY8BjCofwRdHKaDp6tlYU2pA61CQtrdrimeLgDQ3EGIssSotL 1PvF2hafpAi4+HCFw7S5N3X7z9s/7fbjiDRLofxyzrrH7UDrARWJGmuPO6RAooQUeZ0tPNnQ8Vukj u0iMxm7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xM3EV-00000006zpV-3D4K; Wed, 28 Oct 2026 12:58:23 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xM3EU-00000006zoK-1Jiw for linux-riscv@lists.infradead.org; Wed, 28 Oct 2026 12:58:22 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C5D8A4346B; Wed, 28 Oct 2026 12:58:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 256601F01828; Wed, 28 Oct 2026 12:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793192301; bh=iXP09owLdg7hATVHqSaJqY6i6epL8PW7s9/R3d4KX90=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gMw9vBWYeungNCPvsmM8I0lEpRDakT4R3OeAfcy2KhbQ2ePQpy0+u+MU0z1nPw2dp Z1rOKoS03rdLa8ZS9juT1EOjfldfguEgJj2VSAkA5WWsVNgnsx2owXZYcWHOnokx6E VBVBpNl84QwjwDL0wR8U/RSALkuOKSU6gmgz20QpCHZ72sfMXMACd6Flq02aGtQoaF lSwaqb1bcUk0PghM3/D+Aagkdlz3tswOsJVH+nYEjLx9RDl/1QiCxNozEezr+Ac8Cg SNc/clX7BFRxIap6Q6GkQTAypGZBr0XpeKP3WDzbLSMCIMeyGUi42RwZRKbMaNbKK2 Ari79aZH/M9zA== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.ams.internal (Postfix) with ESMTP id 12518198003A; Wed, 28 Oct 2026 08:58:13 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 28 Oct 2026 08:58:18 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEF1K52P+kaoE+JlHf2K3zEGis9UvTdecijTo2/OHf4X3NA2RLlSL8l/5NYHn4tY4 QD3mVKhRVCsogVVGnIRJQ8fh065hN6V7rh05cHd1D3T1Oo9p35G3spAqIogpqrAcWXGb2+ 4OjD2iFBYrk37D/8UhFOtrlL0EnAxrNmuh/eEPHf8B4sMC12AsOTAqn4aC81lF51glNO8i yQKytqn+ywGH1kzh7+JYq3/esC0d1GqO4AO3qemMBFJEPRBtvUY96xMCSiwFz7G9wusDfA opmuy4GESkD7OWq7IIaD2pYT4TsEnQrhQSb/VkqeZfR/tLHBwfWfS8ohfVSXue6cuq/Zmi jv1cOIxgVP1T9tBH4KypCqN4L2fHVypU2jct1/cAteq+LOOum4mt5YzJrj4LcyOJrAEaQq nn1SnjzAGu/R82NpBLBYVX44VPvoPpLgyblYX3+KBoZdds0WfExBACoLBTw6Jhg3VaSLCZ nMVqcNY47gAQk0oxuy21nOhoCEL1pEHjT1XRxtwhrJt0voPgZkF5WGAm+H+24WW4TKOKie C7UPf79Cq8Xwe4vMWfGCF9/szbNkGjhhHTIiTKl7t+RhZrb7Ujq8HxgLlV70Q8+8wF7wDW EV4B/ciE5dO79FS9Qw1JZzAlKFtX17zMOh43xKrqWFl9lQkN2Hr/S9II6KdA X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Oct 2026 08:58:12 -0400 (EDT) Date: Wed, 28 Oct 2026 12:58:11 +0000 From: Kiryl Shutsemau To: Peter Zijlstra Cc: Muchun Song , "David Hildenbrand (Arm)" , Andrew Morton , Matthew Wilcox , Usama Arif , Frank van der Linden , Oscar Salvador , Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Zi Yan , Baoquan He , Michal Hocko , Johannes Weiner , Jonathan Corbet , Huacai Chen , WANG Xuerui , Palmer Dabbelt , Paul Walmsley , Albert Ou , Alexandre Ghiti , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, Dave Hansen , Andy Lutomirski Subject: Re: [PATCHv7 13/18] mm: Drop fake head checks Message-ID: References: <20261027110028.GH2668564@noisy.programming.kicks-ass.net> <070DDE5C-2183-4A8B-AC2D-891CAE15E581@linux.dev> <4A32F5E6-977D-4720-8723-B19AFBC08FCF@linux.dev> <7cb3dd91-f518-49b6-b311-9ec807b3c63b@linux.dev> <20261028080635.GD2668804@noisy.programming.kicks-ass.net> X-Archived-By: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20261028080635.GD2668804@noisy.programming.kicks-ass.net> X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Oct 28, 2026 at 09:06:35AM +0100, Peter Zijlstra wrote: > On Wed, Oct 28, 2026 at 10:38:22AM +0800, Muchun Song wrote: > > > > > > On 2026/10/28 01:51, Kiryl Shutsemau wrote: > > > On Tue, Oct 27, 2026 at 10:03:54PM +0800, Muchun Song wrote: > > > > Therefore, I am kind of leaning towards removing the RO protection > > > > and restoring RW permissions to solve the race. > > > Okay, what about this: > > > > > > From e23ab850837b53cc79d57d58f1cfb4266e745c3d Mon Sep 17 00:00:00 2001 > > > From: "Kiryl Shutsemau (Meta)" > > > Date: Tue, 27 Oct 2026 17:23:47 +0000 > > > Subject: [PATCH] mm/hugetlb_vmemmap: map the shared tail page writable > > > > > > page_ref_add_unless_zero() reads the refcount and then updates it with > > > a cmpxchg. A lockless get, such as a page cache lookup or a PFN > > > scanner, can read a non-zero refcount from a page that is then freed > > > and reused as a hugetlb tail page. If HVO remaps its struct page to > > > the shared tail page in between, the cmpxchg writes to read-only > > > vmemmap: > > > > > > CPU0 (lockless get) CPU1 > > > c = atomic_read(&page->_refcount) > > > page freed > > > page allocated as a hugetlb tail > > > HVO remaps the struct page RO > > > try_cmpxchg(&page->_refcount, &c, c + 1) > > > -> write fault on read-only vmemmap > > > > > > The refcount is zero by then and the compare fails, but LOCK CMPXCHG on > > > x86 writes anyway. The kernel oopses when hugetlb pages are allocated > > > > Is this an X86-specific issue? If not, I suggest a more generic > > description. > > AFAICT most architectures that implement single compare-and-swap > instructions are affected, with the possible exception of s390. > > That is, sparc, arm64-lse, riscv-Zacas, loonarch-amocas, openrisc (and > ia64 for those people keeping the out-of-tree port alive) all require > write protection to begin cmpxchg. > > All the LL/SC architectures should be fine, they'll never get to the SC > part. Only architectures with HVO matter here: x86-64, riscv and loongarch. arm64 has had it disabled since 060a2c92d1b6. riscv and loongarch implement atomic_fetch_add_unless() with LL/SC only, no CAS variant, so they see the zero at the load. That leaves x86. I will make the commit message arch-agnostic anyway. -- Kiryl Shutsemau / Kirill A. Shutemov _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv