All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Barry Song <song.bao.hua@hisilicon.com>
Cc: catalin.marinas@arm.com, will@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	anshuman.khandual@arm.com, linuxarm@huawei.com
Subject: Re: [PATCH] arm64: mm: add support for memmap kernel parameters
Date: Wed, 18 Nov 2020 19:38:54 +0200	[thread overview]
Message-ID: <20201118173854.GA8537@kernel.org> (raw)
In-Reply-To: <20201118063314.22940-1-song.bao.hua@hisilicon.com>

Hi Barry,

On Wed, Nov 18, 2020 at 07:33:14PM +1300, Barry Song wrote:
> memmap should be an useful kernel parameter which has been supported by
> x86, mips and xtensa.

Why is this parameter should be useful for ARM64? 
My understanding is that it is required only to work around really
broken bootloaders, isn't it?

> This patch adds support for ARM64. At this stage,
> the below two modes are supported only:
> memmap=nn[KMG]@ss[KMG]
> Force usage of a specific region of memory
> 
> memmap=nn[KMG]$ss[KMG]
> Region of memory to be reserved is from ss to ss+nn
> 
> If users set memmap=exactmap before memmap=nn[KMG]@ss[KMG], they will
> get the exact memory specified by memmap=nn[KMG]@ss[KMG]. For example,
> on one machine with 4GB memory, "memmap=exactmap memmap=1G@1G" will
> make kernel use the memory from 1GB to 2GB only.
> 
> Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
> ---
>  arch/arm64/mm/init.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 095540667f0f..f1c6bfdbc953 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -235,6 +235,65 @@ static int __init early_mem(char *p)
>  }
>  early_param("mem", early_mem);
>  
> +static int need_remove_real_memblock __initdata;
> +
> +static void __init parse_memmap_one(char *p)
> +{
> +	char *oldp;
> +	unsigned long start_at, mem_size;
> +
> +	if (!p)
> +		return;
> +
> +	if (!strncmp(p, "exactmap", 8)) {
> +		need_remove_real_memblock = 1;
> +		return;
> +	}
> +
> +	oldp = p;
> +	mem_size = memparse(p, &p);
> +	if (p == oldp)
> +		return;
> +
> +	switch (*p) {
> +	case '@':
> +		start_at = memparse(p + 1, &p);
> +		/*
> +		 * use the exactmap defined by nn[KMG]@ss[KMG], remove
> +		 * memblock populated by DT etc.
> +		 */
> +		if (need_remove_real_memblock) {
> +			need_remove_real_memblock = 0;
> +			memblock_remove(0, ULLONG_MAX);
> +		}
> +		memblock_add(start_at, mem_size);
> +		break;
> +	case '$':
> +		start_at = memparse(p + 1, &p);
> +		memblock_reserve(start_at, mem_size);
> +		break;
> +	default:
> +		pr_warn("Unrecognized memmap syntax: %s\n", p);
> +		break;
> +	}
> +}
> +
> +static int __init parse_memmap_opt(char *str)
> +{
> +	while (str) {
> +		char *k = strchr(str, ',');
> +
> +		if (k)
> +			*k++ = 0;
> +
> +		parse_memmap_one(str);
> +		str = k;
> +	}
> +
> +	return 0;
> +}
> +early_param("memmap", parse_memmap_opt);
> +
>  static int __init early_init_dt_scan_usablemem(unsigned long node,
>  		const char *uname, int depth, void *data)
>  {
> -- 
> 2.25.1
> 

-- 
Sincerely yours,
Mike.

WARNING: multiple messages have this Message-ID (diff)
From: Mike Rapoport <rppt@kernel.org>
To: Barry Song <song.bao.hua@hisilicon.com>
Cc: anshuman.khandual@arm.com, catalin.marinas@arm.com,
	linux-kernel@vger.kernel.org, linuxarm@huawei.com,
	akpm@linux-foundation.org, will@kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: mm: add support for memmap kernel parameters
Date: Wed, 18 Nov 2020 19:38:54 +0200	[thread overview]
Message-ID: <20201118173854.GA8537@kernel.org> (raw)
In-Reply-To: <20201118063314.22940-1-song.bao.hua@hisilicon.com>

Hi Barry,

On Wed, Nov 18, 2020 at 07:33:14PM +1300, Barry Song wrote:
> memmap should be an useful kernel parameter which has been supported by
> x86, mips and xtensa.

Why is this parameter should be useful for ARM64? 
My understanding is that it is required only to work around really
broken bootloaders, isn't it?

> This patch adds support for ARM64. At this stage,
> the below two modes are supported only:
> memmap=nn[KMG]@ss[KMG]
> Force usage of a specific region of memory
> 
> memmap=nn[KMG]$ss[KMG]
> Region of memory to be reserved is from ss to ss+nn
> 
> If users set memmap=exactmap before memmap=nn[KMG]@ss[KMG], they will
> get the exact memory specified by memmap=nn[KMG]@ss[KMG]. For example,
> on one machine with 4GB memory, "memmap=exactmap memmap=1G@1G" will
> make kernel use the memory from 1GB to 2GB only.
> 
> Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
> ---
>  arch/arm64/mm/init.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 095540667f0f..f1c6bfdbc953 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -235,6 +235,65 @@ static int __init early_mem(char *p)
>  }
>  early_param("mem", early_mem);
>  
> +static int need_remove_real_memblock __initdata;
> +
> +static void __init parse_memmap_one(char *p)
> +{
> +	char *oldp;
> +	unsigned long start_at, mem_size;
> +
> +	if (!p)
> +		return;
> +
> +	if (!strncmp(p, "exactmap", 8)) {
> +		need_remove_real_memblock = 1;
> +		return;
> +	}
> +
> +	oldp = p;
> +	mem_size = memparse(p, &p);
> +	if (p == oldp)
> +		return;
> +
> +	switch (*p) {
> +	case '@':
> +		start_at = memparse(p + 1, &p);
> +		/*
> +		 * use the exactmap defined by nn[KMG]@ss[KMG], remove
> +		 * memblock populated by DT etc.
> +		 */
> +		if (need_remove_real_memblock) {
> +			need_remove_real_memblock = 0;
> +			memblock_remove(0, ULLONG_MAX);
> +		}
> +		memblock_add(start_at, mem_size);
> +		break;
> +	case '$':
> +		start_at = memparse(p + 1, &p);
> +		memblock_reserve(start_at, mem_size);
> +		break;
> +	default:
> +		pr_warn("Unrecognized memmap syntax: %s\n", p);
> +		break;
> +	}
> +}
> +
> +static int __init parse_memmap_opt(char *str)
> +{
> +	while (str) {
> +		char *k = strchr(str, ',');
> +
> +		if (k)
> +			*k++ = 0;
> +
> +		parse_memmap_one(str);
> +		str = k;
> +	}
> +
> +	return 0;
> +}
> +early_param("memmap", parse_memmap_opt);
> +
>  static int __init early_init_dt_scan_usablemem(unsigned long node,
>  		const char *uname, int depth, void *data)
>  {
> -- 
> 2.25.1
> 

-- 
Sincerely yours,
Mike.

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

  reply	other threads:[~2020-11-18 17:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18  6:33 [PATCH] arm64: mm: add support for memmap kernel parameters Barry Song
2020-11-18  6:33 ` Barry Song
2020-11-18 17:38 ` Mike Rapoport [this message]
2020-11-18 17:38   ` Mike Rapoport
2020-11-18 19:15   ` Will Deacon
2020-11-18 19:15     ` Will Deacon
2020-11-18 20:25     ` Song Bao Hua (Barry Song)
2020-11-18 20:25       ` Song Bao Hua (Barry Song)
2020-11-18 22:38       ` Ard Biesheuvel
2020-11-18 22:38         ` Ard Biesheuvel
2020-11-18 23:55         ` Song Bao Hua (Barry Song)
2020-11-18 23:55           ` Song Bao Hua (Barry Song)
2020-11-19  7:57           ` Mike Rapoport
2020-11-19  7:57             ` Mike Rapoport
2020-11-19  8:37             ` Song Bao Hua (Barry Song)
2020-11-19  8:37               ` Song Bao Hua (Barry Song)

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=20201118173854.GA8537@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=song.bao.hua@hisilicon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.