Use memblock_add_node to add new memblock region within a NUMA node
in early_parse_mem() under CONFIG_NUMA, otherwise the mem parameter
can not work well.
Signed-off-by: Tiezhu Yang <[email protected]>
---
arch/mips/kernel/setup.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c8c8f60..50cdc08 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -37,6 +37,7 @@
#include <asm/cdmm.h>
#include <asm/cpu.h>
#include <asm/debug.h>
+#include <asm/mmzone.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/smp-ops.h>
@@ -378,7 +379,10 @@ static int __init early_parse_mem(char *p)
memblock_end_of_DRAM() - memblock_start_of_DRAM());
}
- memblock_add(start, size);
+ if (IS_ENABLED(CONFIG_NUMA))
+ memblock_add_node(start, size, pa_to_nid(start), MEMBLOCK_NONE);
+ else
+ memblock_add(start, size);
return 0;
}
--
2.1.0
在 2022/3/18 15:05, Tiezhu Yang 写道:
> Use memblock_add_node to add new memblock region within a NUMA node
> in early_parse_mem() under CONFIG_NUMA, otherwise the mem parameter
> can not work well.
Hi Tiezhu,
pa_to_nid doesn't exist when CONFIG_NUME is disabled.
So probably you want #ifdef macro instead ?
Thanks.
- Jiaxun
>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> arch/mips/kernel/setup.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index c8c8f60..50cdc08 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -37,6 +37,7 @@
> #include <asm/cdmm.h>
> #include <asm/cpu.h>
> #include <asm/debug.h>
> +#include <asm/mmzone.h>
> #include <asm/sections.h>
> #include <asm/setup.h>
> #include <asm/smp-ops.h>
> @@ -378,7 +379,10 @@ static int __init early_parse_mem(char *p)
> memblock_end_of_DRAM() - memblock_start_of_DRAM());
> }
>
> - memblock_add(start, size);
> + if (IS_ENABLED(CONFIG_NUMA))
> + memblock_add_node(start, size, pa_to_nid(start), MEMBLOCK_NONE);
> + else
> + memblock_add(start, size);
>
> return 0;
> }
On 03/22/2022 09:19 PM, Jiaxun Yang wrote:
>
>
> 在 2022/3/18 15:05, Tiezhu Yang 写道:
>> Use memblock_add_node to add new memblock region within a NUMA node
>> in early_parse_mem() under CONFIG_NUMA, otherwise the mem parameter
>> can not work well.
>
> Hi Tiezhu,
>
> pa_to_nid doesn't exist when CONFIG_NUME is disabled.
> So probably you want #ifdef macro instead ?
Hi Jiaxun,
Thank you for your reply.
As far as I can tell, if CONFIG_NUMA is set, IS_ENABLED(CONFIG_NUMA)
is 1, pa_to_nid() is defined in the platform dependent header file:
arch/mips/include/asm/mach-ip27/mmzone.h
arch/mips/include/asm/mach-loongson64/mmzone.h
if CONFIG_NUMA is not set, IS_ENABLED(CONFIG_NUMA) is 0, pa_to_nid()
is always 0 which is defined in arch/mips/include/asm/mmzone.h:
#ifdef CONFIG_NUMA
# include <mmzone.h>
#endif
#ifndef pa_to_nid
#define pa_to_nid(addr) 0
#endif
So pa_to_nid() is defined under both CONFIG_NUMA and !CONFIG_NUMA,
there is no build error.
Additionally, use #ifdef CONFIG_NUMA is also OK, but I prefer to
use IS_ENABLED(CONFIG_NUMA).
If I am missing something, please let me know, thank you.
Thanks,
Tiezhu
>
> Thanks.
> - Jiaxun
>
>>
>> Signed-off-by: Tiezhu Yang <[email protected]>
>> ---
>> arch/mips/kernel/setup.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
>> index c8c8f60..50cdc08 100644
>> --- a/arch/mips/kernel/setup.c
>> +++ b/arch/mips/kernel/setup.c
>> @@ -37,6 +37,7 @@
>> #include <asm/cdmm.h>
>> #include <asm/cpu.h>
>> #include <asm/debug.h>
>> +#include <asm/mmzone.h>
>> #include <asm/sections.h>
>> #include <asm/setup.h>
>> #include <asm/smp-ops.h>
>> @@ -378,7 +379,10 @@ static int __init early_parse_mem(char *p)
>> memblock_end_of_DRAM() - memblock_start_of_DRAM());
>> }
>> - memblock_add(start, size);
>> + if (IS_ENABLED(CONFIG_NUMA))
>> + memblock_add_node(start, size, pa_to_nid(start), MEMBLOCK_NONE);
>> + else
>> + memblock_add(start, size);
>> return 0;
>> }
在2022年3月23日三月 上午2:42,Tiezhu Yang写道:
> On 03/22/2022 09:19 PM, Jiaxun Yang wrote:
>>
>>
>> 在 2022/3/18 15:05, Tiezhu Yang 写道:
>>> Use memblock_add_node to add new memblock region within a NUMA node
>>> in early_parse_mem() under CONFIG_NUMA, otherwise the mem parameter
>>> can not work well.
>>
>> Hi Tiezhu,
>>
>> pa_to_nid doesn't exist when CONFIG_NUME is disabled.
>> So probably you want #ifdef macro instead ?
>
> Hi Jiaxun,
>
> Thank you for your reply.
>
> As far as I can tell, if CONFIG_NUMA is set, IS_ENABLED(CONFIG_NUMA)
> is 1, pa_to_nid() is defined in the platform dependent header file:
Yep you're right.
Apologies for the noise.
For the whole series:
Reviewed-by: Jiaxun Yang <[email protected]>
Tested-by: Jiaxun Yang <[email protected]>
Thanks.
>
> arch/mips/include/asm/mach-ip27/mmzone.h
> arch/mips/include/asm/mach-loongson64/mmzone.h
>
> if CONFIG_NUMA is not set, IS_ENABLED(CONFIG_NUMA) is 0, pa_to_nid()
> is always 0 which is defined in arch/mips/include/asm/mmzone.h:
>
> #ifdef CONFIG_NUMA
> # include <mmzone.h>
> #endif
>
> #ifndef pa_to_nid
> #define pa_to_nid(addr) 0
> #endif
>
> So pa_to_nid() is defined under both CONFIG_NUMA and !CONFIG_NUMA,
> there is no build error.
>
> Additionally, use #ifdef CONFIG_NUMA is also OK, but I prefer to
> use IS_ENABLED(CONFIG_NUMA).
>
> If I am missing something, please let me know, thank you.
>
> Thanks,
> Tiezhu
>
>>
>> Thanks.
>> - Jiaxun
>>
>>>
>>> Signed-off-by: Tiezhu Yang <[email protected]>
>>> ---
>>> arch/mips/kernel/setup.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
>>> index c8c8f60..50cdc08 100644
>>> --- a/arch/mips/kernel/setup.c
>>> +++ b/arch/mips/kernel/setup.c
>>> @@ -37,6 +37,7 @@
>>> #include <asm/cdmm.h>
>>> #include <asm/cpu.h>
>>> #include <asm/debug.h>
>>> +#include <asm/mmzone.h>
>>> #include <asm/sections.h>
>>> #include <asm/setup.h>
>>> #include <asm/smp-ops.h>
>>> @@ -378,7 +379,10 @@ static int __init early_parse_mem(char *p)
>>> memblock_end_of_DRAM() - memblock_start_of_DRAM());
>>> }
>>> - memblock_add(start, size);
>>> + if (IS_ENABLED(CONFIG_NUMA))
>>> + memblock_add_node(start, size, pa_to_nid(start), MEMBLOCK_NONE);
>>> + else
>>> + memblock_add(start, size);
>>> return 0;
>>> }
--
- Jiaxun