linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: linux-mm@kvack.org, Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
	Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Subject: Re: [RFC v1 05/10] powerpc/64s: Move serialize_against_pte_lookup() to hash_pgtable.c
Date: Wed, 4 Mar 2026 10:00:03 +0100	[thread overview]
Message-ID: <e1eabcbf-40da-4899-9db6-828a7b697328@kernel.org> (raw)
In-Reply-To: <dd9b5abdcc56d935681f7f95fa018bd886d59ba0.1772013273.git.ritesh.list@gmail.com>



Le 25/02/2026 à 12:04, Ritesh Harjani (IBM) a écrit :
> Originally,
> commit fa4531f753f1 ("powerpc/mm: Don't send IPI to all cpus on THP updates")
> introduced serialize_against_pte_lookup() call for both Radix and Hash.
> 
> However below commit fixed the race with Radix
> commit 70cbc3cc78a9 ("mm: gup: fix the fast GUP race against THP collapse")
> 
> And therefore following commit removed the
> serialize_against_pte_lookup() call from radix_pgtable.c
> commit bedf03416913
> ("powerpc/64s/radix: don't need to broadcast IPI for radix pmd collapse flush")
> 
> Now since serialize_against_pte_lookup() only gets called from
> hash__pmdp_collapse_flush(), thus move the related functions to
> hash_pgtable.c
> 
> Hence this patch:
> - moves serialize_against_pte_lookup() from radix_pgtable.c to hash_pgtable.c
> - removes the radix specific calls from do_serialize()
> - renames do_serialize() to do_nothing().
> 
> There should not be any functionality change in this patch.
> 
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   arch/powerpc/include/asm/book3s/64/pgtable.h |  1 -
>   arch/powerpc/mm/book3s64/hash_pgtable.c      | 21 ++++++++++++++++
>   arch/powerpc/mm/book3s64/pgtable.c           | 25 --------------------
>   3 files changed, 21 insertions(+), 26 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index 1a91762b455d..ff264d930fe8 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1400,7 +1400,6 @@ static inline bool arch_needs_pgtable_deposit(void)
>   		return false;
>   	return true;
>   }
> -extern void serialize_against_pte_lookup(struct mm_struct *mm);
>   
>   #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>   
> diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book3s64/hash_pgtable.c
> index ac2a24d15d2e..d9b5b751d7b7 100644
> --- a/arch/powerpc/mm/book3s64/hash_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c
> @@ -221,6 +221,27 @@ unsigned long hash__pmd_hugepage_update(struct mm_struct *mm, unsigned long addr
>   	return old;
>   }
>   
> +static void do_nothing(void *arg)
> +{
> +
> +}
> +
> +/*
> + * Serialize against __find_linux_pte() which does lock-less
> + * lookup in page tables with local interrupts disabled. For huge pages
> + * it casts pmd_t to pte_t. Since format of pte_t is different from
> + * pmd_t we want to prevent transit from pmd pointing to page table
> + * to pmd pointing to huge page (and back) while interrupts are disabled.
> + * We clear pmd to possibly replace it with page table pointer in
> + * different code paths. So make sure we wait for the parallel
> + * __find_linux_pte() to finish.
> + */
> +static void serialize_against_pte_lookup(struct mm_struct *mm)
> +{
> +	smp_mb();
> +	smp_call_function_many(mm_cpumask(mm), do_nothing, mm, 1);
> +}
> +
>   pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address,
>   			    pmd_t *pmdp)
>   {
> diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c
> index 359092001670..84284dff650a 100644
> --- a/arch/powerpc/mm/book3s64/pgtable.c
> +++ b/arch/powerpc/mm/book3s64/pgtable.c
> @@ -150,31 +150,6 @@ void set_pud_at(struct mm_struct *mm, unsigned long addr,
>   	return set_pte_at_unchecked(mm, addr, pudp_ptep(pudp), pud_pte(pud));
>   }
>   
> -static void do_serialize(void *arg)
> -{
> -	/* We've taken the IPI, so try to trim the mask while here */
> -	if (radix_enabled()) {
> -		struct mm_struct *mm = arg;
> -		exit_lazy_flush_tlb(mm, false);
> -	}
> -}
> -
> -/*
> - * Serialize against __find_linux_pte() which does lock-less
> - * lookup in page tables with local interrupts disabled. For huge pages
> - * it casts pmd_t to pte_t. Since format of pte_t is different from
> - * pmd_t we want to prevent transit from pmd pointing to page table
> - * to pmd pointing to huge page (and back) while interrupts are disabled.
> - * We clear pmd to possibly replace it with page table pointer in
> - * different code paths. So make sure we wait for the parallel
> - * __find_linux_pte() to finish.
> - */
> -void serialize_against_pte_lookup(struct mm_struct *mm)
> -{
> -	smp_mb();
> -	smp_call_function_many(mm_cpumask(mm), do_serialize, mm, 1);
> -}
> -
>   /*
>    * We use this to invalidate a pmdp entry before switching from a
>    * hugepte to regular pmd entry.



  reply	other threads:[~2026-03-04  9:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 11:04 [RFC v1 00/10] Misc powerpc fixes and refactoring Ritesh Harjani (IBM)
2026-02-25 11:04 ` [RFC v1 02/10] powerpc: book3s64: Fix unmap race with PMD THP migration entry Ritesh Harjani (IBM)
2026-03-04  8:54   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 03/10] mm/debug_vm_pgtable.c: Add test to zap " Ritesh Harjani (IBM)
2026-02-25 11:04 ` [RFC v1 04/10] powerpc/64s/tlbflush-radix: Remove unused radix__flush_tlb_pwc() Ritesh Harjani (IBM)
2026-03-04  8:55   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 05/10] powerpc/64s: Move serialize_against_pte_lookup() to hash_pgtable.c Ritesh Harjani (IBM)
2026-03-04  9:00   ` Christophe Leroy (CS GROUP) [this message]
2026-02-25 11:04 ` [RFC v1 06/10] powerpc/64s: Kill the unused argument of exit_lazy_flush_tlb Ritesh Harjani (IBM)
2026-03-04  9:02   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 07/10] powerpc: book3s64: Rename tlbie_va_lpid to tlbie_va_pid_lpid Ritesh Harjani (IBM)
2026-03-04  9:04   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 08/10] powerpc: book3s64: Rename tlbie_lpid_va to tlbie_va_lpid Ritesh Harjani (IBM)
2026-03-04  9:06   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 09/10] powerpc: book3s64: Make use of H_RPTI_TYPE_ALL macro Ritesh Harjani (IBM)
2026-03-04  9:07   ` Christophe Leroy (CS GROUP)
2026-02-25 11:04 ` [RFC v1 10/10] powerpc: Add MMU_FTRS_POSSIBLE & MMU_FTRS_ALWAYS Ritesh Harjani (IBM)
2026-03-04  9:09   ` Christophe Leroy (CS GROUP)
2026-03-04  9:23     ` Ritesh Harjani
2026-02-25 11:42 ` [RFC v1 01/10] powerpc/pgtable-frag: Fix bad page state in pte_frag_destroy Ritesh Harjani
2026-02-25 11:04   ` Ritesh Harjani (IBM)
2026-03-04  8:53   ` Christophe Leroy (CS GROUP)

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=e1eabcbf-40da-4899-9db6-828a7b697328@kernel.org \
    --to=chleroy@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=venkat88@linux.ibm.com \
    /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