linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Paul Mackerras <paulus@samba.org>,
	"sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Will Deacon <will@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [PATCH V2] mm: Merge pte_mkhuge() call into arch_make_huge_pte()
Date: Wed, 1 Mar 2023 06:56:53 +0000	[thread overview]
Message-ID: <1ea45095-0926-a56a-a273-816709e9075e@csgroup.eu> (raw)
In-Reply-To: <1643860669-26307-1-git-send-email-anshuman.khandual@arm.com>

Hi,

Le 03/02/2022 à 04:57, Anshuman Khandual a écrit :
> Each call into pte_mkhuge() is invariably followed by arch_make_huge_pte().
> Instead arch_make_huge_pte() can accommodate pte_mkhuge() at the beginning.
> This updates generic fallback stub for arch_make_huge_pte() and available
> platforms definitions. This makes huge pte creation much cleaner and easier
> to follow.

I can't remember, what was the reason for not doing it in 
remove_migration_pte() as well ?
Looking at it, I have the feeling that we now have a redundant 
pte_mkhuge() there.

Also, could we get rid of the one in mm/debug_vm_pgtable.c ?

Also, shouldn't arch_make_huge_pte() be documented in 
Documentation/vm/arch_pgtable_helpers.rst instead of pte_mkhuge() ?

Christophe

> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: sparclinux@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This applies on v5.17-rc2
> 
> Changes in V2:
> 
> - Direct PTE encode in arch_make_huge_pte() on powerpc platform per Christophe
> 
> Changes in V1:
> 
> https://lore.kernel.org/all/1643780286-18798-1-git-send-email-anshuman.khandual@arm.com/
> 
>   arch/arm64/mm/hugetlbpage.c                      | 1 +
>   arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 4 ++--
>   arch/sparc/mm/hugetlbpage.c                      | 1 +
>   include/linux/hugetlb.h                          | 2 +-
>   mm/hugetlb.c                                     | 3 +--
>   mm/vmalloc.c                                     | 1 -
>   6 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index ffb9c229610a..228226c5fa80 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -347,6 +347,7 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
>   {
>   	size_t pagesize = 1UL << shift;
>   
> +	entry = pte_mkhuge(entry);
>   	if (pagesize == CONT_PTE_SIZE) {
>   		entry = pte_mkcont(entry);
>   	} else if (pagesize == CONT_PMD_SIZE) {
> diff --git a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> index 64b6c608eca4..de092b04ee1a 100644
> --- a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> +++ b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> @@ -71,9 +71,9 @@ static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags
>   	size_t size = 1UL << shift;
>   
>   	if (size == SZ_16K)
> -		return __pte(pte_val(entry) & ~_PAGE_HUGE);
> +		return __pte(pte_val(entry) | _PAGE_SPS);
>   	else
> -		return entry;
> +		return __pte(pte_val(entry) | _PAGE_SPS | _PAGE_HUGE);
>   }
>   #define arch_make_huge_pte arch_make_huge_pte
>   #endif
> diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
> index 0f49fada2093..d8e0e3c7038d 100644
> --- a/arch/sparc/mm/hugetlbpage.c
> +++ b/arch/sparc/mm/hugetlbpage.c
> @@ -181,6 +181,7 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
>   {
>   	pte_t pte;
>   
> +	entry = pte_mkhuge(entry);
>   	pte = hugepage_shift_to_tte(entry, shift);
>   
>   #ifdef CONFIG_SPARC64
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index d1897a69c540..52c462390aee 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -754,7 +754,7 @@ static inline void arch_clear_hugepage_flags(struct page *page) { }
>   static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift,
>   				       vm_flags_t flags)
>   {
> -	return entry;
> +	return pte_mkhuge(entry);
>   }
>   #endif
>   
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 61895cc01d09..5ca253c1b4e4 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4637,7 +4637,6 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
>   					   vma->vm_page_prot));
>   	}
>   	entry = pte_mkyoung(entry);
> -	entry = pte_mkhuge(entry);
>   	entry = arch_make_huge_pte(entry, shift, vma->vm_flags);
>   
>   	return entry;
> @@ -6172,7 +6171,7 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
>   			unsigned int shift = huge_page_shift(hstate_vma(vma));
>   
>   			old_pte = huge_ptep_modify_prot_start(vma, address, ptep);
> -			pte = pte_mkhuge(huge_pte_modify(old_pte, newprot));
> +			pte = huge_pte_modify(old_pte, newprot);
>   			pte = arch_make_huge_pte(pte, shift, vma->vm_flags);
>   			huge_ptep_modify_prot_commit(vma, address, ptep, old_pte, pte);
>   			pages++;
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 4165304d3547..d0b14dd73adc 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -118,7 +118,6 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
>   		if (size != PAGE_SIZE) {
>   			pte_t entry = pfn_pte(pfn, prot);
>   
> -			entry = pte_mkhuge(entry);
>   			entry = arch_make_huge_pte(entry, ilog2(size), 0);
>   			set_huge_pte_at(&init_mm, addr, pte, entry);
>   			pfn += PFN_DOWN(size);

  parent reply	other threads:[~2023-03-01  6:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03  3:57 [PATCH V2] mm: Merge pte_mkhuge() call into arch_make_huge_pte() Anshuman Khandual
2022-02-03 17:54 ` Catalin Marinas
2023-03-01  6:56 ` Christophe Leroy [this message]
2023-03-01  8:32   ` Anshuman Khandual

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=1ea45095-0926-a56a-a273-816709e9075e@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mike.kravetz@oracle.com \
    --cc=paulus@samba.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).