From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 3DDECC88E40 for ; Wed, 9 Sep 2026 16:43:18 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hg67S4LKLz2yyJ; Thu, 10 Sep 2026 02:43:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788972196; cv=none; b=g54j1VK8qpRb+8H40GqlggjZHbbkNba8ykG2ZltroxHWtAFZ/Ij3o7vj6tk6wAZ6ltmjXwGD3tgjhPIl0m7uif467TR0uJUjIOxfA4LOa4y5hbiYe9Wk9SWld4FZSQ24DBN5oHVW9DZTNJarA7HaYfWS608tXM4IMTBuycYjYXenievemTxBsEv3C2jH1sBm2us68Dwf34rDm+3X9rHq1Dwd7+O4rr7waifUmuwn4yBv2f/TpTwAUt07ntGq0RUWPTsX4yGzvX/mrEBxPYWEiIa00N/nWRqDaVu2qo/grnzD534hpx7k6/HRcFFviJoSDeOpfXhhoAFx5JsTlzcXyQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788972196; c=relaxed/relaxed; bh=+bb9T4qzNzmlycp9ThZUfYsXOaxsYgWc9M6tavwahvE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dKo5Vovk/E6gFglqeRG8r9WGXXbnhnAB3/HusUOrlOn8TU41hNotBPKlsM6Hokx6Lsxsv+vhbC1+6nmO+qol0xCpPVa9qVk+fU8c/HfCVGcWC74jP0xo0HEH/r/7QfDGiQqqjgcTdYs/FgebeLb+nlO4XJy0H5PKMIlVWTLRV5FipESTMALT5gtszuxlrvcUEyg5dLkgrZ7j8c7Aqy6+JIzieNwosaLiOqCqSj7F/vsUAOteQn2xFXYsUrTIpo8CT4tNetec2WI2XcFnJNkv8F3J0pdAwq3vwZ/hy4hXtE4A2Gl+pbzKYpS4laIfQUrhHHCFFnPJU4E7HJrF9irrNg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gIPVuofi; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=ljs@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gIPVuofi; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=ljs@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hg67R0Bcvz2xWV for ; Thu, 10 Sep 2026 02:43:14 +1000 (AEST) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 822CC439C2; Wed, 9 Sep 2026 16:43:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4721F000FF; Wed, 9 Sep 2026 16:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788972191; bh=+bb9T4qzNzmlycp9ThZUfYsXOaxsYgWc9M6tavwahvE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gIPVuofiiuXzwRKr3oimigWerGVK3163gi1cAcgzOdWIHvv7vHRHaOOm70oBmvuof gM+DrCV50r5q2fX37AG+T2Z9/95C3wKDpEICIKuj714cWc9kpK2a643U857hnxKrt6 F+VhD/Iigk9dREUeU4ysQJtISisTduJzSnmSk21qc6hooSphBl5H9CJ0/x7dZKu/Q6 u+L9ir5TwzY1RhFgoDiNZuSP0ijZXhIOTL8sytWHlzA6zcGHNHpORsIUOjNpgYzeac YkdgjhwiwM1Yl/vDXjEBIxQFkvn0uBOf3YaFLZFvbyOIKYs37Ib6WZ5TYOCA3N7iFE 8WN0ksIUU49KQ== Date: Wed, 9 Sep 2026 17:42:45 +0100 From: "Lorenzo Stoakes (ARM)" To: Kiryl Shutsemau Cc: Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH v2 12/12] mm: change the contract for free_pgtables(), update docs Message-ID: References: <20260908-rcu-pagetable-freeing-v2-0-1f60b64e878e@kernel.org> <20260908-rcu-pagetable-freeing-v2-12-1f60b64e878e@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Sep 09, 2026 at 10:24:21AM +0100, Kiryl Shutsemau wrote: > On Tue, Sep 08, 2026 at 01:32:21PM +0100, Lorenzo Stoakes (ARM) wrote: > > Now that page tables are freed after an RCU grace period, it is safe for > > read-only page table walkers to walk page table ranges that are being > > concurrently torn down, provided the mm is kept alive via mmgrab(). > > > > It is however unsafe for writers to do so, as they must obtain an > > appropriate lock to do so safely. > > > > Update the pte_offset_map_lock()'s comment block to reflect this. > > > > Similarly update the process addresses documentation. > > > > Signed-off-by: Lorenzo Stoakes (ARM) > > --- > > Documentation/mm/process_addrs.rst | 6 ++++++ > > mm/pgtable-generic.c | 15 +++++++++++---- > > 2 files changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/mm/process_addrs.rst b/Documentation/mm/process_addrs.rst > > index a7296f251799..1e65b139f355 100644 > > --- a/Documentation/mm/process_addrs.rst > > +++ b/Documentation/mm/process_addrs.rst > > @@ -537,6 +537,12 @@ We establish basic locking rules when interacting with page tables: > > * When changing a page table entry the page table lock for that page table > > **must** be held, except if you can safely assume nobody can access the page > > tables concurrently (such as on invocation of :c:func:`!free_pgtables`). > > +* Page tables may be *walked* under RCU alone, as page tables are freed only > > + after an RCU grace period has elapsed. However, any entry found must be > > + revalidated after the page table lock is taken (such as the > > + :c:func:`!pmd_same` recheck performed by :c:func:`!pte_offset_map_lock`) > > + before it is acted upon. Changing an entry always requires the page table > > + lock. > > This says the PTL plus a recheck is enough to act on the entry. It is > not: free_pte_range() clears the PMD without the PTL, so pmd_same() can > pass and the table is torn down right after. That is the case we settled > on for the pte_offset_map_lock() comment, and the two now disagree. > > Something like "Changing an entry requires the page table lock and one > of the locks that excludes teardown (mmap or VMA lock)" would match the > comment. Ack will change! -- Cheers, Lorenzo From mboxrd@z Thu Jan 1 00:00:00 1970 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 F4157C79FB7 for ; Wed, 9 Sep 2026 16:43:26 +0000 (UTC) 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-Owner; bh=8w9Hpn8NTMhkXAIus+42gWnqMaWZxyIaym+U0dJn4zY=; b=utYRPZZtugRtas SCEytQv3Z63WlkIR0LusrFJYIRXiHRWHzU/OCHdq4fhTJ7LuR2zlKVbB1d0674FsK8ILF6QYckk85 QJmN2GpjUcEPhqL7mF5VfwFIy9wVPzRnv5l2VeLnd2m0yfYgn67QGL1Jamy7SayJQHURSudW6Wa/L dTs4bPRiHxXdDFtd0ISjCWo4l1phU/Xe65VK/UwDHnpqLOhuYc8eRhmqKoUKbYn4Y5HMeZ4Ujjsb2 2ntycLkAoeDPkTY7M6U71g8P7xn026XNm/zO1ihllrz4jc/Kmx1AwbJapG/5MX/aP13k4Y9LB2T6F zFmuTNQ3xvXIEm5+4zbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4LOE-0000000CMTH-477f; Wed, 09 Sep 2026 16:43:14 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4LOC-0000000CMSt-1TBV; Wed, 09 Sep 2026 16:43:12 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 822CC439C2; Wed, 9 Sep 2026 16:43:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4721F000FF; Wed, 9 Sep 2026 16:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788972191; bh=+bb9T4qzNzmlycp9ThZUfYsXOaxsYgWc9M6tavwahvE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gIPVuofiiuXzwRKr3oimigWerGVK3163gi1cAcgzOdWIHvv7vHRHaOOm70oBmvuof gM+DrCV50r5q2fX37AG+T2Z9/95C3wKDpEICIKuj714cWc9kpK2a643U857hnxKrt6 F+VhD/Iigk9dREUeU4ysQJtISisTduJzSnmSk21qc6hooSphBl5H9CJ0/x7dZKu/Q6 u+L9ir5TwzY1RhFgoDiNZuSP0ijZXhIOTL8sytWHlzA6zcGHNHpORsIUOjNpgYzeac YkdgjhwiwM1Yl/vDXjEBIxQFkvn0uBOf3YaFLZFvbyOIKYs37Ib6WZ5TYOCA3N7iFE 8WN0ksIUU49KQ== Date: Wed, 9 Sep 2026 17:42:45 +0100 From: "Lorenzo Stoakes (ARM)" To: Kiryl Shutsemau Cc: Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH v2 12/12] mm: change the contract for free_pgtables(), update docs Message-ID: References: <20260908-rcu-pagetable-freeing-v2-0-1f60b64e878e@kernel.org> <20260908-rcu-pagetable-freeing-v2-12-1f60b64e878e@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Sep 09, 2026 at 10:24:21AM +0100, Kiryl Shutsemau wrote: > On Tue, Sep 08, 2026 at 01:32:21PM +0100, Lorenzo Stoakes (ARM) wrote: > > Now that page tables are freed after an RCU grace period, it is safe for > > read-only page table walkers to walk page table ranges that are being > > concurrently torn down, provided the mm is kept alive via mmgrab(). > > > > It is however unsafe for writers to do so, as they must obtain an > > appropriate lock to do so safely. > > > > Update the pte_offset_map_lock()'s comment block to reflect this. > > > > Similarly update the process addresses documentation. > > > > Signed-off-by: Lorenzo Stoakes (ARM) > > --- > > Documentation/mm/process_addrs.rst | 6 ++++++ > > mm/pgtable-generic.c | 15 +++++++++++---- > > 2 files changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/mm/process_addrs.rst b/Documentation/mm/process_addrs.rst > > index a7296f251799..1e65b139f355 100644 > > --- a/Documentation/mm/process_addrs.rst > > +++ b/Documentation/mm/process_addrs.rst > > @@ -537,6 +537,12 @@ We establish basic locking rules when interacting with page tables: > > * When changing a page table entry the page table lock for that page table > > **must** be held, except if you can safely assume nobody can access the page > > tables concurrently (such as on invocation of :c:func:`!free_pgtables`). > > +* Page tables may be *walked* under RCU alone, as page tables are freed only > > + after an RCU grace period has elapsed. However, any entry found must be > > + revalidated after the page table lock is taken (such as the > > + :c:func:`!pmd_same` recheck performed by :c:func:`!pte_offset_map_lock`) > > + before it is acted upon. Changing an entry always requires the page table > > + lock. > > This says the PTL plus a recheck is enough to act on the entry. It is > not: free_pte_range() clears the PMD without the PTL, so pmd_same() can > pass and the table is torn down right after. That is the case we settled > on for the pte_offset_map_lock() comment, and the two now disagree. > > Something like "Changing an entry requires the page table lock and one > of the locks that excludes teardown (mmap or VMA lock)" would match the > comment. Ack will change! -- Cheers, Lorenzo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 7DC4BC79FB6 for ; Wed, 9 Sep 2026 16:43:15 +0000 (UTC) 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-Owner; bh=+EzEKBvzUyUkad1hbuD3b6lBD9BJN2AWeT6iw2z20B8=; b=XSGI346m27JeEI hTXul9Jxz4Ff7jM7hR2Md2lb4meLGJceKmcux7hT2jzHGqFk7G6Kq7Pj+6PAOHYIVaoMN2pFTNs4m VXXPFZHXn7EGkvjzVpu4cHPcxfu9XVRViL0bWkd5EXjii6BdM7RUvdFkyYBPIuRgp8uFXd+YaG/fW ekJ6rd0GCJ+5dmBLHjKON2dCT9TdwlhAua5KZ0SOD0lye0iheHOWMP1cvAIA+yAU6h29SICRsnHMU 5tjXrmkqW1WKE90bcNbfNjfe8tIvukekZ6tQJaGlORlU1x2xrx/ONsK9tn+kolLnzLofTNazbIO3C LGIuYw5K2dlFLunijkNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4LOF-0000000CMTL-0DS2; Wed, 09 Sep 2026 16:43:15 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4LOC-0000000CMSt-1TBV; Wed, 09 Sep 2026 16:43:12 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 822CC439C2; Wed, 9 Sep 2026 16:43:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4721F000FF; Wed, 9 Sep 2026 16:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788972191; bh=+bb9T4qzNzmlycp9ThZUfYsXOaxsYgWc9M6tavwahvE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gIPVuofiiuXzwRKr3oimigWerGVK3163gi1cAcgzOdWIHvv7vHRHaOOm70oBmvuof gM+DrCV50r5q2fX37AG+T2Z9/95C3wKDpEICIKuj714cWc9kpK2a643U857hnxKrt6 F+VhD/Iigk9dREUeU4ysQJtISisTduJzSnmSk21qc6hooSphBl5H9CJ0/x7dZKu/Q6 u+L9ir5TwzY1RhFgoDiNZuSP0ijZXhIOTL8sytWHlzA6zcGHNHpORsIUOjNpgYzeac YkdgjhwiwM1Yl/vDXjEBIxQFkvn0uBOf3YaFLZFvbyOIKYs37Ib6WZ5TYOCA3N7iFE 8WN0ksIUU49KQ== Date: Wed, 9 Sep 2026 17:42:45 +0100 From: "Lorenzo Stoakes (ARM)" To: Kiryl Shutsemau Cc: Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH v2 12/12] mm: change the contract for free_pgtables(), update docs Message-ID: References: <20260908-rcu-pagetable-freeing-v2-0-1f60b64e878e@kernel.org> <20260908-rcu-pagetable-freeing-v2-12-1f60b64e878e@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org On Wed, Sep 09, 2026 at 10:24:21AM +0100, Kiryl Shutsemau wrote: > On Tue, Sep 08, 2026 at 01:32:21PM +0100, Lorenzo Stoakes (ARM) wrote: > > Now that page tables are freed after an RCU grace period, it is safe for > > read-only page table walkers to walk page table ranges that are being > > concurrently torn down, provided the mm is kept alive via mmgrab(). > > > > It is however unsafe for writers to do so, as they must obtain an > > appropriate lock to do so safely. > > > > Update the pte_offset_map_lock()'s comment block to reflect this. > > > > Similarly update the process addresses documentation. > > > > Signed-off-by: Lorenzo Stoakes (ARM) > > --- > > Documentation/mm/process_addrs.rst | 6 ++++++ > > mm/pgtable-generic.c | 15 +++++++++++---- > > 2 files changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/mm/process_addrs.rst b/Documentation/mm/process_addrs.rst > > index a7296f251799..1e65b139f355 100644 > > --- a/Documentation/mm/process_addrs.rst > > +++ b/Documentation/mm/process_addrs.rst > > @@ -537,6 +537,12 @@ We establish basic locking rules when interacting with page tables: > > * When changing a page table entry the page table lock for that page table > > **must** be held, except if you can safely assume nobody can access the page > > tables concurrently (such as on invocation of :c:func:`!free_pgtables`). > > +* Page tables may be *walked* under RCU alone, as page tables are freed only > > + after an RCU grace period has elapsed. However, any entry found must be > > + revalidated after the page table lock is taken (such as the > > + :c:func:`!pmd_same` recheck performed by :c:func:`!pte_offset_map_lock`) > > + before it is acted upon. Changing an entry always requires the page table > > + lock. > > This says the PTL plus a recheck is enough to act on the entry. It is > not: free_pte_range() clears the PMD without the PTL, so pmd_same() can > pass and the table is torn down right after. That is the case we settled > on for the pte_offset_map_lock() comment, and the two now disagree. > > Something like "Changing an entry requires the page table lock and one > of the locks that excludes teardown (mmap or VMA lock)" would match the > comment. Ack will change! -- Cheers, Lorenzo _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc