From: David Hildenbrand <david@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>
Cc: linux-mm@kvack.org, sparclinux@vger.kernel.org,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/4] sparc/mm: Disable preemption in lazy mmu mode
Date: Mon, 3 Mar 2025 09:51:34 +0100 [thread overview]
Message-ID: <4af46304-cf25-4c4a-8e4a-3a566193ca62@redhat.com> (raw)
In-Reply-To: <20250302145555.3236789-3-ryan.roberts@arm.com>
On 02.03.25 15:55, Ryan Roberts wrote:
> Since commit 38e0edb15bd0 ("mm/apply_to_range: call pte function with
> lazy updates") it's been possible for arch_[enter|leave]_lazy_mmu_mode()
> to be called without holding a page table lock (for the kernel mappings
> case), and therefore it is possible that preemption may occur while in
> the lazy mmu mode. The Sparc lazy mmu implementation is not robust to
> preemption since it stores the lazy mode state in a per-cpu structure
> and does not attempt to manage that state on task switch.
>
> Powerpc had the same issue and fixed it by explicitly disabling
> preemption in arch_enter_lazy_mmu_mode() and re-enabling in
> arch_leave_lazy_mmu_mode(). See commit b9ef323ea168 ("powerpc/64s:
> Disable preemption in hash lazy mmu mode").
>
> Given Sparc's lazy mmu mode is based on powerpc's, let's fix it in the
> same way here.
>
> Fixes: 38e0edb15bd0 ("mm/apply_to_range: call pte function with lazy updates")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
> arch/sparc/mm/tlb.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
> index 8648a50afe88..a35ddcca5e76 100644
> --- a/arch/sparc/mm/tlb.c
> +++ b/arch/sparc/mm/tlb.c
> @@ -52,8 +52,10 @@ void flush_tlb_pending(void)
>
> void arch_enter_lazy_mmu_mode(void)
> {
> - struct tlb_batch *tb = this_cpu_ptr(&tlb_batch);
> + struct tlb_batch *tb;
>
> + preempt_disable();
> + tb = this_cpu_ptr(&tlb_batch);
> tb->active = 1;
> }
>
> @@ -64,6 +66,7 @@ void arch_leave_lazy_mmu_mode(void)
> if (tb->tlb_nr)
> flush_tlb_pending();
> tb->active = 0;
> + preempt_enable();
> }
>
> static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-03-03 8:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-02 14:55 [PATCH v1 0/4] Fix " Ryan Roberts
2025-03-02 14:55 ` [PATCH v1 1/4] mm: Fix lazy mmu docs and usage Ryan Roberts
2025-03-03 8:49 ` David Hildenbrand
2025-03-03 8:52 ` David Hildenbrand
2025-03-03 10:22 ` Ryan Roberts
2025-03-03 10:30 ` David Hildenbrand
2025-03-03 12:49 ` Andreas Larsson
2025-03-02 14:55 ` [PATCH v1 2/4] sparc/mm: Disable preemption in lazy mmu mode Ryan Roberts
2025-03-03 8:51 ` David Hildenbrand [this message]
2025-03-03 13:39 ` Andreas Larsson
2025-03-02 14:55 ` [PATCH v1 3/4] sparc/mm: Avoid calling arch_enter/leave_lazy_mmu() in set_ptes Ryan Roberts
2025-03-03 8:52 ` David Hildenbrand
2025-03-03 13:39 ` Andreas Larsson
2025-03-02 14:55 ` [PATCH v1 4/4] Revert "x86/xen: allow nesting of same lazy mode" Ryan Roberts
2025-03-03 11:52 ` David Hildenbrand
2025-03-03 12:33 ` Ryan Roberts
2025-03-03 12:57 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4af46304-cf25-4c4a-8e4a-3a566193ca62@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=willy@infradead.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox