linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH 2/4] arm64: Add option to force mapping with PAGE_SIZE pages
Date: Tue, 26 Jan 2016 11:14:39 +0000	[thread overview]
Message-ID: <20160126111438.GA5059@leverpostej> (raw)
In-Reply-To: <1453740735-17898-3-git-send-email-labbott@fedoraproject.org>

Hi,

On Mon, Jan 25, 2016 at 08:52:13AM -0800, Laura Abbott wrote:
> Under some circumstances (e.g. debugging) it may be useful to have all
> kernel memory mapped using PAGE_SIZE pages. Add an option for this.
> 
> Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
> ---
>  arch/arm64/Kconfig  | 11 +++++++++++
>  arch/arm64/mm/mmu.c | 10 +++++++---
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index ffa3c54..faf7eac 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -504,6 +504,17 @@ config HOTPLUG_CPU
>  	  Say Y here to experiment with turning CPUs off and on.  CPUs
>  	  can be controlled through /sys/devices/system/cpu.
>  
> +config FORCE_PAGES
> +	bool "Force all memory mappings to be PAGE_SIZE"
> +	help
> +	  For performance reasons, kernel memory may be mapped with
> +	  page table entries larger than the expected PAGE_SIZE. This results
> +	  in better TLB performance but prevents adjustment of page table
> +	  attributes at runtime. Say Y here to have all kernel memory mapped
> +	  with PAGE_SIZE entries.
> +
> +	  If unsure, say N.
> +

I think we can make this a boot-time option, given that we're simply
flipping a boolean that only directly affects a small amount of boot
code. I doubt there would be a noticeable overhead, and it makes it more
likely that we can use this to debug production kernels.

Is there a usecase other than DEBUG_PAGEALLOC that you have in mind? If
not, we could just hang this off of debug_pagealloc_enabled(), as we
parse the early params before we create the usual page tables.

Thanks,
Mark.

>  source kernel/Kconfig.preempt
>  source kernel/Kconfig.hz
>  
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 2d6e7cf..450d38a 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -181,7 +181,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
>  	do {
>  		next = pmd_addr_end(addr, end);
>  		/* try section mapping first */
> -		if (((addr | next | phys) & ~SECTION_MASK) == 0) {
> +		if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
> +		      (!IS_ENABLED(CONFIG_FORCE_PAGES) || !pgtable_alloc)) {
>  			pmd_t old_pmd =*pmd;
>  			set_pmd(pmd, __pmd(phys |
>  					   pgprot_val(mk_sect_prot(prot))));
> @@ -208,8 +209,11 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
>  }
>  
>  static inline bool use_1G_block(unsigned long addr, unsigned long next,
> -			unsigned long phys)
> +			unsigned long phys, phys_addr_t (*pgtable_alloc)(void))
>  {
> +	if (pgtable_alloc && IS_ENABLED(CONFIG_FORCE_PAGES))
> +		return false;
> +
>  	if (PAGE_SHIFT != 12)
>  		return false;
>  
> @@ -241,7 +245,7 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
>  		/*
>  		 * For 4K granule only, attempt to put down a 1GB block
>  		 */
> -		if (use_1G_block(addr, next, phys)) {
> +		if (use_1G_block(addr, next, phys, pgtable_alloc)) {
>  			pud_t old_pud = *pud;
>  			set_pud(pud, __pud(phys |
>  					   pgprot_val(mk_sect_prot(prot))));
> -- 
> 2.5.0
> 

  reply	other threads:[~2016-01-26 11:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 16:52 [RFC][PATCH 0/4] ARCH_SUPPORTS_DEBUG_PAGEALLOC for arm64 Laura Abbott
2016-01-25 16:52 ` [RFC][PATCH 1/4] arm64: Drop alloc function from create_mapping Laura Abbott
2016-01-26 11:22   ` Mark Rutland
2016-01-26 21:26     ` Laura Abbott
2016-01-25 16:52 ` [RFC][PATCH 2/4] arm64: Add option to force mapping with PAGE_SIZE pages Laura Abbott
2016-01-26 11:14   ` Mark Rutland [this message]
2016-01-26 21:51     ` Laura Abbott
2016-01-25 16:52 ` [RFC][PATCH 3/4] arm64: Add support for ARCH_SUPPORTS_DEBUG_PAGEALLOC Laura Abbott
2016-01-25 16:52 ` [RFC][PATCH 4/4] arm64: ptdump: Indicate whether memory should be faulting Laura Abbott

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=20160126111438.GA5059@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).