linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gshan@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com, will@kernel.org,
	linux-kernel@vger.kernel.org, shan.gavin@gmail.com
Subject: Re: [PATCH 2/2] arm64/mm: Use CONT_SHIFT to define CONT_PTE_SHIFT
Date: Thu, 10 Sep 2020 19:56:35 +1000	[thread overview]
Message-ID: <b253e307-eec4-3cd9-b921-2c6672120e9b@redhat.com> (raw)
In-Reply-To: <966505a6-16f6-8129-804b-fcf890429fb8@arm.com>

Hi Anshuman,

On 9/10/20 7:28 PM, Anshuman Khandual wrote:
> On 09/10/2020 02:01 PM, Gavin Shan wrote:
>> On 9/10/20 4:17 PM, Anshuman Khandual wrote:
>>> On 09/08/2020 12:49 PM, Gavin Shan wrote:
>>>> The macro CONT_PTE_SHIFT actually depends on CONT_SHIFT, which has
>>>> been defined in page-def.h, based on CONFIG_ARM64_CONT_SHIFT. Lets
>>>> reflect the dependency.
>>>>
>>>> Signed-off-by: Gavin Shan <gshan@redhat.com>
>>>> ---
>>>>    arch/arm64/include/asm/pgtable-hwdef.h | 4 +---
>>>>    1 file changed, 1 insertion(+), 3 deletions(-)
>>>>
>>>> diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
>>>> index 8a399e666837..0bd9469f4323 100644
>>>> --- a/arch/arm64/include/asm/pgtable-hwdef.h
>>>> +++ b/arch/arm64/include/asm/pgtable-hwdef.h
>>>> @@ -81,14 +81,12 @@
>>>>    /*
>>>>     * Contiguous page definitions.
>>>>     */
>>>> +#define CONT_PTE_SHIFT        (CONT_SHIFT + PAGE_SHIFT)
>>>>    #ifdef CONFIG_ARM64_64K_PAGES
>>>> -#define CONT_PTE_SHIFT        (5 + PAGE_SHIFT)
>>>>    #define CONT_PMD_SHIFT        (5 + PMD_SHIFT)
>>>>    #elif defined(CONFIG_ARM64_16K_PAGES)
>>>> -#define CONT_PTE_SHIFT        (7 + PAGE_SHIFT)
>>>>    #define CONT_PMD_SHIFT        (5 + PMD_SHIFT)
>>>>    #else
>>>> -#define CONT_PTE_SHIFT        (4 + PAGE_SHIFT)
>>>>    #define CONT_PMD_SHIFT        (4 + PMD_SHIFT)
>>>>    #endif
>>> Could not a similar CONT_PMD be created from a new CONFIG_ARM64_CONT_PMD
>>> config option, which would help unify CONT_PMD_SHIFT here as well ?
>>>
>>
>> I was thinking of it, to have CONFIG_ARM64_CONT_PMD and defined the
>> following macros in arch/arm64/include/asm/page-def.h:
>>
>>     #define CONT_PMD_SHIFT    CONFIG_ARM64_CONT_PMD_SHIFT
>>     #define CONT_PMD_SIZE        (_AC(1, UL) << (CONT_PMD_SHIFT + PMD_SHIFT)
>>     #define CONT_PMD_MASK        (~(CONT_PMD_SIZE - 1))
>>
>> PMD_SHIFT is variable because PMD could be folded into PUD or PGD,
>> depending on the kernel configuration. PMD_SHIFT is declared
> 
> Even CONT_PMD_SHIFT via the new CONFIG_ARM64_CONT_PMD_SHIFT will
> be a variable as well depending on page size.
> 

Yes, it depends on the variable PMD_SHIFT.

>> in arch/arm64/include/asm/pgtable-types.h, which isn't supposed
>> to be included in "page-def.h".
> 
> Are there build failures if <pgtable-types.h> is included from <page-def.h> ?
> 

Yes, something like this:

   AS      arch/arm64/kernel/head.o
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8,
                  from ./arch/arm64/include/asm/page-def.h:12,
                  from ./arch/arm64/include/asm/page.h:11,
                  from ./arch/arm64/include/asm/proc-fns.h:14,
                  from ./arch/arm64/include/asm/pgtable.h:9,
                  from ./include/linux/pgtable.h:6,
                  from ./arch/arm64/include/asm/io.h:12,
                  from ./include/linux/io.h:13,
                  from drivers/bus/vexpress-config.c:9:
./arch/arm64/include/asm/memory.h:91:55: warning: "PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
  #if defined(CONFIG_VMAP_STACK) && (MIN_THREAD_SHIFT < PAGE_SHIFT)
                                                        ^~~~~~~~~~
./arch/arm64/include/asm/memory.h:97:21: warning: "PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
  #if THREAD_SHIFT >= PAGE_SHIFT
                      ^~~~~~~~~~


>>
>> So the peroper way to handle this might be drop the continuous page
>> macros in page-def.h and introduce the following ones into pgtable-hwdef.h.
>> I will post v2 to do this if it sounds good to you.
> 
> Sure, go ahead if that builds. But unifying both these macros seems cleaner.
> 

Thanks for your confirmation. v2 is on the way :)

>>
>>     #define CONT_PTE_SHIFT         (CONFIG_ARM64_CONT_PTE_SHIFT + PAGE_SHIFT)
>>     #define CONT_PMD_SHIFT         (CONFIG_ARM64_CONT_PMD_SHIFT + PMD_SHIFT)
>>

Thanks,
Gavin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-09-10  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  7:19 [PATCH 1/2] arm64/mm: Remove CONT_RANGE_OFFSET Gavin Shan
2020-09-08  7:19 ` [PATCH 2/2] arm64/mm: Use CONT_SHIFT to define CONT_PTE_SHIFT Gavin Shan
2020-09-10  6:17   ` Anshuman Khandual
2020-09-10  8:31     ` Gavin Shan
2020-09-10  9:28       ` Anshuman Khandual
2020-09-10  9:56         ` Gavin Shan [this message]
2020-09-10  5:59 ` [PATCH 1/2] arm64/mm: Remove CONT_RANGE_OFFSET 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=b253e307-eec4-3cd9-b921-2c6672120e9b@redhat.com \
    --to=gshan@redhat.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shan.gavin@gmail.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;
as well as URLs for NNTP newsgroup(s).