2021-04-19 10:53:51

by Youling Tang

[permalink] [raw]
Subject: [PATCH] MIPS: Fix cmdline "mem=" parameter parsing

This problem may only occur on NUMA platforms. When machine start with the
"mem=" parameter on Loongson64, it cannot boot. When parsing the "mem="
parameter, first remove all RAM, and then add memory through memblock_add(),
which causes the newly added memory to be located on MAX_NUMNODES.

The solution is to add the current "mem=" parameter range to the memory area
of the corresponding node, instead of adding all of it to the MAX_NUMNODES
node area. Get the node number corresponding to the "mem=" parameter range
through pa_to_nid(), and then add it to the corresponding node through
memblock_add_node().

Signed-off-by: Jinyang He <[email protected]>
Signed-off-by: Youling Tang <[email protected]>
---
arch/mips/kernel/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 279be01..b86e241 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -359,7 +359,7 @@ static int __init early_parse_mem(char *p)
if (*p == '@')
start = memparse(p + 1, &p);

- memblock_add(start, size);
+ memblock_add_node(start, size, pa_to_nid(start));

return 0;
}
--
2.1.0


2021-04-19 16:15:21

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Fix cmdline "mem=" parameter parsing

Hi Youling,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.12-rc8 next-20210419]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Youling-Tang/MIPS-Fix-cmdline-mem-parameter-parsing/20210419-185311
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bf05bf16c76bb44ab5156223e1e58e26dfe30a88
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c9cec6a7cf36ea04b1d8aca273a27e92007085e2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Youling-Tang/MIPS-Fix-cmdline-mem-parameter-parsing/20210419-185311
git checkout c9cec6a7cf36ea04b1d8aca273a27e92007085e2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

arch/mips/kernel/setup.c: In function 'early_parse_mem':
>> arch/mips/kernel/setup.c:362:33: error: implicit declaration of function 'pa_to_nid'; did you mean 'page_to_nid'? [-Werror=implicit-function-declaration]
362 | memblock_add_node(start, size, pa_to_nid(start));
| ^~~~~~~~~
| page_to_nid
cc1: some warnings being treated as errors


vim +362 arch/mips/kernel/setup.c

342
343 static int __init early_parse_mem(char *p)
344 {
345 phys_addr_t start, size;
346
347 /*
348 * If a user specifies memory size, we
349 * blow away any automatically generated
350 * size.
351 */
352 if (usermem == 0) {
353 usermem = 1;
354 memblock_remove(memblock_start_of_DRAM(),
355 memblock_end_of_DRAM() - memblock_start_of_DRAM());
356 }
357 start = 0;
358 size = memparse(p, &p);
359 if (*p == '@')
360 start = memparse(p + 1, &p);
361
> 362 memblock_add_node(start, size, pa_to_nid(start));
363
364 return 0;
365 }
366 early_param("mem", early_parse_mem);
367

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.73 kB)
.config.gz (68.60 kB)
Download all attachments

2021-04-20 01:06:41

by Jiaxun Yang

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Fix cmdline "mem=" parameter parsing


在 2021/4/19 18:50, Youling Tang 写道:
> This problem may only occur on NUMA platforms. When machine start with the
> "mem=" parameter on Loongson64, it cannot boot. When parsing the "mem="
> parameter, first remove all RAM, and then add memory through memblock_add(),
> which causes the newly added memory to be located on MAX_NUMNODES.
>
> The solution is to add the current "mem=" parameter range to the memory area
> of the corresponding node, instead of adding all of it to the MAX_NUMNODES
> node area. Get the node number corresponding to the "mem=" parameter range
> through pa_to_nid(), and then add it to the corresponding node through
> memblock_add_node().
>
> Signed-off-by: Jinyang He <[email protected]>
> Signed-off-by: Youling Tang <[email protected]>
> ---
> arch/mips/kernel/setup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index 279be01..b86e241 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -359,7 +359,7 @@ static int __init early_parse_mem(char *p)
> if (*p == '@')
> start = memparse(p + 1, &p);
>
> - memblock_add(start, size);
> + memblock_add_node(start, size, pa_to_nid(start));

pa_to_nid is not available for all platforms.


Thanks.

- Jiaxun

>
> return 0;
> }

2021-04-20 02:17:42

by Youling Tang

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Fix cmdline "mem=" parameter parsing

Hi, Jiaxun

On 04/20/2021 09:05 AM, Jiaxun Yang wrote:
>
> 在 2021/4/19 18:50, Youling Tang 写道:
>> This problem may only occur on NUMA platforms. When machine start
>> with the
>> "mem=" parameter on Loongson64, it cannot boot. When parsing the "mem="
>> parameter, first remove all RAM, and then add memory through
>> memblock_add(),
>> which causes the newly added memory to be located on MAX_NUMNODES.
>>
>> The solution is to add the current "mem=" parameter range to the
>> memory area
>> of the corresponding node, instead of adding all of it to the
>> MAX_NUMNODES
>> node area. Get the node number corresponding to the "mem=" parameter
>> range
>> through pa_to_nid(), and then add it to the corresponding node through
>> memblock_add_node().
>>
>> Signed-off-by: Jinyang He <[email protected]>
>> Signed-off-by: Youling Tang <[email protected]>
>> ---
>> arch/mips/kernel/setup.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
>> index 279be01..b86e241 100644
>> --- a/arch/mips/kernel/setup.c
>> +++ b/arch/mips/kernel/setup.c
>> @@ -359,7 +359,7 @@ static int __init early_parse_mem(char *p)
>> if (*p == '@')
>> start = memparse(p + 1, &p);
>> - memblock_add(start, size);
>> + memblock_add_node(start, size, pa_to_nid(start));
>
> pa_to_nid is not available for all platforms.
>
Thanks for your correction.

pa_to_nid() only has actual definitions in mach-ip27 and mach-loongson64
(only
for NUMA platform).

In arch/mips/include/asm/mmzone.h:
#ifndef pa_to_nid
#define pa_to_nid(addr) 0
#endif

So only need #include <asm/mmzone.h> to solve the "error: implicit
declaration
of function'pa_to_nid'" compilation error.

Thanks,
Youling
>
> Thanks.
>
> - Jiaxun
>
>> return 0;
>> }