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 70FD2CA0FED for ; Fri, 5 Sep 2025 14:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vSe61z5BayeoSR86wiQVMBpcSVw9JUSiFDv132hHJEw=; b=KTTqZP9Ayrmqjy4p8EGs0+ZjMB L+KL6olFx72oOGuxH7l5nHD2aXXkrjmHjbdPJq3BaHsOB646b4znW1UKnHi0qfHRZDwWSp50FEa5p KheEcIW+MFEy0JKaLDLKaTRumqeGzX6ACo9btnBAC9iOYf+HKlmsUIlLnCZABjio1SgdjHx5Kyzhk YrOgUCAoLB3D2eYk92C3u6LjWRLUzEXSdoEdpJvzn5z5Sz82dMzah8nvyL20v0qf3Gb9HBzJmIAsu ZvQoprR4oog9F7cPTwCNHF9wyfqijjTcMyqpiizyWqQVR1wjz//KQbRRSCNkWdnTQsq0RMav/Z8uc h3EdF8vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uuXZV-00000002PlX-0sRs; Fri, 05 Sep 2025 14:37:49 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uuUTV-00000001L05-0aOs for linux-arm-kernel@lists.infradead.org; Fri, 05 Sep 2025 11:19:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 89B416027B; Fri, 5 Sep 2025 11:19:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4C27C4CEF1; Fri, 5 Sep 2025 11:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757071164; bh=RHLqjtmoQ09sM+x+rrDllENxQeIkKdioDv+JW9P+Aos=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A/QIh2ddmPQW9GbhkGscvwZJAOdlvRvh05eTseLWqDi0NqX5VoUz3c+rFGi5te6gs FeVf6cxesM0g4NssvOVujDWyj9mrdK8LpKlTGDp/6FZss2dq4STW6zOMrER9uue5m7 gYM0YJqrGGelTJTg/Wae0ezZ+Ln5Z9a7rQdsrtvsC5aJMkzJDUejnZeo9niA5S9ZsO rAiiZhiID4hhFyLR0EPR+sXVy1LHpEREWSJ9XWSwcd0WYCKy66BICmsJmvPOks/99s KUtvAv0iw5WXUoAptM66b1336WnWvdA8iRqYrawyqjKazn3DqpgdPmx5ld20pIZHkT 94jShf4NQqhcQ== Date: Fri, 5 Sep 2025 14:19:11 +0300 From: Mike Rapoport To: Kevin Brodsky Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Gordeev , Andreas Larsson , Andrew Morton , Boris Ostrovsky , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , David Hildenbrand , "David S. Miller" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Juergen Gross , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Michael Ellerman , Michal Hocko , Nicholas Piggin , Peter Zijlstra , Ryan Roberts , Suren Baghdasaryan , Thomas Gleixner , Vlastimil Babka , Will Deacon , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH 2/7] mm: introduce local state for lazy_mmu sections Message-ID: References: <20250904125736.3918646-1-kevin.brodsky@arm.com> <20250904125736.3918646-3-kevin.brodsky@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250904125736.3918646-3-kevin.brodsky@arm.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 04, 2025 at 01:57:31PM +0100, Kevin Brodsky wrote: > arch_{enter,leave}_lazy_mmu_mode() currently have a stateless API > (taking and returning no value). This is proving problematic in > situations where leave() needs to restore some context back to its > original state (before enter() was called). In particular, this > makes it difficult to support the nesting of lazy_mmu sections - > leave() does not know whether the matching enter() call occurred > while lazy_mmu was already enabled, and whether to disable it or > not. > > This patch gives all architectures the chance to store local state > while inside a lazy_mmu section by making enter() return some value, > storing it in a local variable, and having leave() take that value. > That value is typed lazy_mmu_state_t - each architecture defining > __HAVE_ARCH_ENTER_LAZY_MMU_MODE is free to define it as it sees fit. > For now we define it as int everywhere, which is sufficient to > support nesting. > > The diff is unfortunately rather large as all the API changes need > to be done atomically. Main parts: > > * Changing the prototypes of arch_{enter,leave}_lazy_mmu_mode() > in generic and arch code, and introducing lazy_mmu_state_t. > > * Introducing LAZY_MMU_{DEFAULT,NESTED} for future support of > nesting. enter() always returns LAZY_MMU_DEFAULT for now. > (linux/mm_types.h is not the most natural location for defining > those constants, but there is no other obvious header that is > accessible where arch's implement the helpers.) > > * Changing all lazy_mmu sections to introduce a lazy_mmu_state > local variable, having enter() set it and leave() take it. Most of > these changes were generated using the Coccinelle script below. > > @@ > @@ > { > + lazy_mmu_state_t lazy_mmu_state; > ... > - arch_enter_lazy_mmu_mode(); > + lazy_mmu_state = arch_enter_lazy_mmu_mode(); > ... > - arch_leave_lazy_mmu_mode(); > + arch_leave_lazy_mmu_mode(lazy_mmu_state); > ... > } > > Note: it is difficult to provide a default definition of > lazy_mmu_state_t for architectures implementing lazy_mmu, because > that definition would need to be available in > arch/x86/include/asm/paravirt_types.h and adding a new generic > #include there is very tricky due to the existing header soup. > > Signed-off-by: Kevin Brodsky Acked-by: Mike Rapoport (Microsoft) -- Sincerely yours, Mike.