public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com,
	suzuki.poulose@arm.com, Will Deacon <will@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64/mm: Add pud_sect_supported()
Date: Thu, 16 Sep 2021 17:16:29 +0100	[thread overview]
Message-ID: <YUNt3btNlYVGDTkX@arm.com> (raw)
In-Reply-To: <1631677459-28383-1-git-send-email-anshuman.khandual@arm.com>

On Wed, Sep 15, 2021 at 09:14:19AM +0530, Anshuman Khandual wrote:
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index 23505fc35324..641854f0e8ee 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -40,11 +40,10 @@ void __init arm64_hugetlb_cma_reserve(void)
>  {
>  	int order;
>  
> -#ifdef CONFIG_ARM64_4K_PAGES
> -	order = PUD_SHIFT - PAGE_SHIFT;
> -#else
> -	order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
> -#endif
> +	if (pud_sect_supported())
> +		order = PUD_SHIFT - PAGE_SHIFT;
> +	else
> +		order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
>  	/*
>  	 * HugeTLB CMA reservation is required for gigantic
>  	 * huge pages which could not be allocated via the
> @@ -62,8 +61,9 @@ bool arch_hugetlb_migration_supported(struct hstate *h)
>  	size_t pagesize = huge_page_size(h);
>  
>  	switch (pagesize) {
> -#ifdef CONFIG_ARM64_4K_PAGES
> +#ifndef __PAGETABLE_PUD_FOLDED
>  	case PUD_SIZE:
> +		return pud_sect_supported();
>  #endif
>  	case PMD_SIZE:
>  	case CONT_PMD_SIZE:

Is this the same thing? With 4K pages and 3-levels (39-bit VA), the PUD
is folded but we do have a valid PUD_SIZE == PGDIR_SIZE and different
from PMD_SIZE. Do we disallow section mappings at the top level in this
case? If not, we should have check for __PAGETABLE_PMD_FOLDED instead.

> @@ -126,8 +126,11 @@ static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
>  	*pgsize = size;
>  
>  	switch (size) {
> -#ifdef CONFIG_ARM64_4K_PAGES
> +#ifndef __PAGETABLE_PUD_FOLDED
>  	case PUD_SIZE:
> +		if (pud_sect_supported())
> +			contig_ptes = 1;
> +		break;
>  #endif
>  	case PMD_SIZE:
>  		contig_ptes = 1;

Same here.

> @@ -489,9 +492,9 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma,
>  
>  static int __init hugetlbpage_init(void)
>  {
> -#ifdef CONFIG_ARM64_4K_PAGES
> -	hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
> -#endif
> +	if (pud_sect_supported())
> +		hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
> +
>  	hugetlb_add_hstate(CONT_PMD_SHIFT - PAGE_SHIFT);
>  	hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
>  	hugetlb_add_hstate(CONT_PTE_SHIFT - PAGE_SHIFT);
> @@ -503,8 +506,9 @@ arch_initcall(hugetlbpage_init);
>  bool __init arch_hugetlb_valid_size(unsigned long size)
>  {
>  	switch (size) {
> -#ifdef CONFIG_ARM64_4K_PAGES
> +#ifndef __PAGETABLE_PUD_FOLDED
>  	case PUD_SIZE:
> +		return pud_sect_supported();
>  #endif
>  	case CONT_PMD_SIZE:
>  	case PMD_SIZE:

And here.

-- 
Catalin

  reply	other threads:[~2021-09-16 16:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  3:44 [PATCH] arm64/mm: Add pud_sect_supported() Anshuman Khandual
2021-09-16 16:16 ` Catalin Marinas [this message]
2021-09-17  5:12   ` 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=YUNt3btNlYVGDTkX@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=suzuki.poulose@arm.com \
    --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