2020-02-15 11:51:01

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 1/3] riscv: Add support for mem=

From: Jan Kiszka <[email protected]>

This sets a memory limit provided via mem= on the command line,
analogously to many other architectures.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/riscv/mm/init.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 965a8cf4829c..aec39a56d6cf 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -118,6 +118,23 @@ static void __init setup_initrd(void)
}
#endif /* CONFIG_BLK_DEV_INITRD */

+static phys_addr_t memory_limit = PHYS_ADDR_MAX;
+
+/*
+ * Limit the memory size that was specified via FDT.
+ */
+static int __init early_mem(char *p)
+{
+ if (!p)
+ return 1;
+
+ memory_limit = memparse(p, &p) & PAGE_MASK;
+ pr_notice("Memory limited to %lldMB\n", memory_limit >> 20);
+
+ return 0;
+}
+early_param("mem", early_mem);
+
static phys_addr_t dtb_early_pa __initdata;

void __init setup_bootmem(void)
@@ -127,6 +144,8 @@ void __init setup_bootmem(void)
phys_addr_t vmlinux_end = __pa_symbol(&_end);
phys_addr_t vmlinux_start = __pa_symbol(&_start);

+ memblock_enforce_memory_limit(memory_limit);
+
/* Find the memory region containing the kernel */
for_each_memblock(memory, reg) {
phys_addr_t end = reg->base + reg->size;
--
2.16.4


2020-02-15 13:41:33

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] riscv: Add support for mem=

On Sat, Feb 15, 2020 at 5:20 PM Jan Kiszka <[email protected]> wrote:
>
> From: Jan Kiszka <[email protected]>
>
> This sets a memory limit provided via mem= on the command line,
> analogously to many other architectures.
>
> Signed-off-by: Jan Kiszka <[email protected]>
> ---
> arch/riscv/mm/init.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 965a8cf4829c..aec39a56d6cf 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -118,6 +118,23 @@ static void __init setup_initrd(void)
> }
> #endif /* CONFIG_BLK_DEV_INITRD */
>
> +static phys_addr_t memory_limit = PHYS_ADDR_MAX;
> +
> +/*
> + * Limit the memory size that was specified via FDT.
> + */
> +static int __init early_mem(char *p)
> +{
> + if (!p)
> + return 1;
> +
> + memory_limit = memparse(p, &p) & PAGE_MASK;
> + pr_notice("Memory limited to %lldMB\n", memory_limit >> 20);
> +
> + return 0;
> +}
> +early_param("mem", early_mem);
> +
> static phys_addr_t dtb_early_pa __initdata;
>
> void __init setup_bootmem(void)
> @@ -127,6 +144,8 @@ void __init setup_bootmem(void)
> phys_addr_t vmlinux_end = __pa_symbol(&_end);
> phys_addr_t vmlinux_start = __pa_symbol(&_start);
>
> + memblock_enforce_memory_limit(memory_limit);
> +
> /* Find the memory region containing the kernel */
> for_each_memblock(memory, reg) {
> phys_addr_t end = reg->base + reg->size;
> --
> 2.16.4
>
>

This is a good addition for Linux RISC-V.

Looks good to me.

Reviewed-by: Anup Patel <[email protected]>

Regards,
Anup

2020-02-15 13:45:04

by Nikolay Borisov

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] riscv: Add support for mem=



On 15.02.20 г. 13:49 ч., Jan Kiszka wrote:
> From: Jan Kiszka <[email protected]>
>
> This sets a memory limit provided via mem=3D on the command line,
> analogously to many other architectures.
>
> Signed-off-by: Jan Kiszka <[email protected]>
> =2D--
> arch/riscv/mm/init.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 965a8cf4829c..aec39a56d6cf 100644
> =2D-- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -118,6 +118,23 @@ static void __init setup_initrd(void)
> }
> #endif /* CONFIG_BLK_DEV_INITRD */
>
> +static phys_addr_t memory_limit =3D PHYS_ADDR_MAX;

3d is the ascii code for =, meaning your client is somehow br0ken?
> +
> +/*
> + * Limit the memory size that was specified via FDT.
> + */
> +static int __init early_mem(char *p)
> +{
> + if (!p)
> + return 1;
> +
> + memory_limit =3D memparse(p, &p) & PAGE_MASK;

ditto

> + pr_notice("Memory limited to %lldMB\n", memory_limit >> 20);
> +
> + return 0;
> +}
> +early_param("mem", early_mem);
> +
> static phys_addr_t dtb_early_pa __initdata;
>
> void __init setup_bootmem(void)
> @@ -127,6 +144,8 @@ void __init setup_bootmem(void)
> phys_addr_t vmlinux_end =3D __pa_symbol(&_end);
> phys_addr_t vmlinux_start =3D __pa_symbol(&_start);
>
> + memblock_enforce_memory_limit(memory_limit);
> +
> /* Find the memory region containing the kernel */
> for_each_memblock(memory, reg) {
> phys_addr_t end =3D reg->base + reg->size;
> =2D-
> 2.16.4
>
>

2020-02-15 14:29:35

by Jan Kiszka

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] riscv: Add support for mem=

On 15.02.20 14:44, Nikolay Borisov wrote:
>
>
> On 15.02.20 г. 13:49 ч., Jan Kiszka wrote:
>> From: Jan Kiszka <[email protected]>
>>
>> This sets a memory limit provided via mem=3D on the command line,
>> analogously to many other architectures.
>>
>> Signed-off-by: Jan Kiszka <[email protected]>
>> =2D--
>> arch/riscv/mm/init.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index 965a8cf4829c..aec39a56d6cf 100644
>> =2D-- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -118,6 +118,23 @@ static void __init setup_initrd(void)
>> }
>> #endif /* CONFIG_BLK_DEV_INITRD */
>>
>> +static phys_addr_t memory_limit =3D PHYS_ADDR_MAX;
>
> 3d is the ascii code for =, meaning your client is somehow br0ken?

The client is called git send-email, and I just checked what was passed
to it - all fine. It must be my beloved freemail provider that enables
quoted-printable encoding for this series (interestingly not for another
one I sent to a different community today). I've resent the same patch
files to both corporate and private providers, and only the latter shows
this behavior. Sigh.

IIRC, git am processes this correctly, but I can resent via the
corporate server as well, whatever is preferred.

Thanks,
Jan