This patchset allow arch adjust node_relaim_distance, as follow:
Hui Tang (2): arm64/numa: Support node_reclaim_distance adjust for arch config: enable COBFIG_ARCH_CUSTOM_NUMA_DISTANCE for arm64
arch/arm64/Kconfig | 13 +++++ arch/arm64/configs/openeuler_defconfig | 1 + drivers/base/arch_numa.c | 79 ++++++++++++++++++++++++++ 3 files changed, 93 insertions(+)
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
--------------------------------
'node_reclaim_distance' affects scheduling behavior and memory reclamation, but the value is currently the default value and can not be set.
Now introduce the way to adjust 'node_reclaim_distance' depending on the cpu model.
Signed-off-by: Hui Tang tanghui20@huawei.com --- arch/arm64/Kconfig | 13 +++++++ drivers/base/arch_numa.c | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2712d3c73719..6de3e70f8362 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2443,6 +2443,19 @@ config STACKPROTECTOR_PER_TASK def_bool y depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_SYSREG
+config ARCH_CUSTOM_NUMA_DISTANCE + bool "Support custom node relaim distance" + depends on ARM64 && ARCH_HISI && NUMA + default n + help + Allow arch to adjust node_reclaim_distance. + + Some machines may have a specific node distance to achieve optimal + system performance. You can set a specific node_reclaim_distance based + on the system topology. + + If unsure, say N. + config UNWIND_PATCH_PAC_INTO_SCS bool "Enable shadow call stack dynamically using code patching" # needs Clang with https://reviews.llvm.org/D111780 incorporated diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 5b59d133b6af..af8b76e4f9fa 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -189,6 +189,83 @@ void __init setup_per_cpu_areas(void) } #endif
+#ifdef CONFIG_ARCH_CUSTOM_NUMA_DISTANCE +#define DISTANCE_MAX (1 << DISTANCE_BITS) +static void get_numa_distance_info(int *numa_levels, int *max_distance) +{ + DECLARE_BITMAP(distance_map, DISTANCE_MAX); + int max = 0; + int i, j; + + bitmap_zero(distance_map, DISTANCE_MAX); + for (i = 0; i < nr_node_ids; i++) { + for (j = 0; j < nr_node_ids; j++) { + int distance = node_distance(i, j); + + if (distance < LOCAL_DISTANCE || + distance >= DISTANCE_MAX) { + return; + } + + if (distance > max) + max = distance; + + bitmap_set(distance_map, distance, 1); + } + } + + if (numa_levels) + *numa_levels = bitmap_weight(distance_map, DISTANCE_MAX); + + if (max_distance) + *max_distance = max; +} + +static int __init node_reclaim_distance_setup(char *str) +{ + int val; + + if (kstrtoint(str, 0, &val)) + return 0; + + if (val < LOCAL_DISTANCE || val >= DISTANCE_MAX) + return 0; + + if (val != RECLAIM_DISTANCE) { + node_reclaim_distance = val; + pr_info("Force set node_reclaim_distance to %d\n", val); + } + + return 0; +} +early_param("node_reclaim_distance", node_reclaim_distance_setup); + +static void __init node_reclaim_distance_adjust(void) +{ + unsigned int model = read_cpuid_id() & MIDR_CPU_MODEL_MASK; + int max_distance = 0; + int numa_levels = 0; + + switch (model) { + case MIDR_HISI_LINXICORE9100: + get_numa_distance_info(&numa_levels, &max_distance); + if (nr_node_ids != 4 || numa_levels <= 3 || + node_reclaim_distance != RECLAIM_DISTANCE || + max_distance <= RECLAIM_DISTANCE) + break; + + node_reclaim_distance = max_distance; + pr_info("Force adjust node_reclaim_distance to %d\n", + node_reclaim_distance); + break; + default: + break; + } +} +#else +static inline void __init node_reclaim_distance_adjust(void) {} +#endif + /** * numa_add_memblk() - Set node id to memblk * @nid: NUMA node ID of the new memblk @@ -401,6 +478,8 @@ static int __init numa_init(int (*init_func)(void))
setup_node_to_cpumask_map();
+ node_reclaim_distance_adjust(); + return 0; out_free_distance: numa_free_distance();
On 2024/4/30 10:17, Hui Tang wrote:
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
'node_reclaim_distance' affects scheduling behavior and memory reclamation, but the value is currently the default value and can not be set.
Now introduce the way to adjust 'node_reclaim_distance' depending on the cpu model.
Signed-off-by: Hui Tang tanghui20@huawei.com
arch/arm64/Kconfig | 13 +++++++ drivers/base/arch_numa.c | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2712d3c73719..6de3e70f8362 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2443,6 +2443,19 @@ config STACKPROTECTOR_PER_TASK def_bool y depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_SYSREG
+config ARCH_CUSTOM_NUMA_DISTANCE
- bool "Support custom node relaim distance"
- depends on ARM64 && ARCH_HISI && NUMA
No ARM64
- default n
- help
Allow arch to adjust node_reclaim_distance.
Some machines may have a specific node distance to achieve optimal
system performance. You can set a specific node_reclaim_distance based
on the system topology.
If unsure, say N.
and this config should under 'Common NUMA Features'
- config UNWIND_PATCH_PAC_INTO_SCS bool "Enable shadow call stack dynamically using code patching" # needs Clang with https://reviews.llvm.org/D111780 incorporated
diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 5b59d133b6af..af8b76e4f9fa 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -189,6 +189,83 @@ void __init setup_per_cpu_areas(void) } #endif
+#ifdef CONFIG_ARCH_CUSTOM_NUMA_DISTANCE +#define DISTANCE_MAX (1 << DISTANCE_BITS) +static void get_numa_distance_info(int *numa_levels, int *max_distance) +{
- DECLARE_BITMAP(distance_map, DISTANCE_MAX);
- int max = 0;
- int i, j;
- bitmap_zero(distance_map, DISTANCE_MAX);
- for (i = 0; i < nr_node_ids; i++) {
for (j = 0; j < nr_node_ids; j++) {
int distance = node_distance(i, j);
if (distance < LOCAL_DISTANCE ||
distance >= DISTANCE_MAX) {
return;
}
if (distance > max)
max = distance;
bitmap_set(distance_map, distance, 1);
}
- }
- if (numa_levels)
*numa_levels = bitmap_weight(distance_map, DISTANCE_MAX);
- if (max_distance)
*max_distance = max;
+}
+static int __init node_reclaim_distance_setup(char *str) +{
- int val;
- if (kstrtoint(str, 0, &val))
return 0;
-EINVAL?
- if (val < LOCAL_DISTANCE || val >= DISTANCE_MAX)
return 0;
-EINVAL?
- if (val != RECLAIM_DISTANCE) {
node_reclaim_distance = val;
pr_info("Force set node_reclaim_distance to %d\n", val);
- }
- return 0;
+} +early_param("node_reclaim_distance", node_reclaim_distance_setup);
+static void __init node_reclaim_distance_adjust(void) +{
- unsigned int model = read_cpuid_id() & MIDR_CPU_MODEL_MASK;
- int max_distance = 0;
- int numa_levels = 0;
- switch (model) {
- case MIDR_HISI_LINXICORE9100:
get_numa_distance_info(&numa_levels, &max_distance);
if (nr_node_ids != 4 || numa_levels <= 3 ||
Why 4/3, no comment, also no details in changelog
node_reclaim_distance != RECLAIM_DISTANCE ||
max_distance <= RECLAIM_DISTANCE)
break;
node_reclaim_distance = max_distance;
pr_info("Force adjust node_reclaim_distance to %d\n",
node_reclaim_distance);
break;
- default:
break;
- }
+} +#else +static inline void __init node_reclaim_distance_adjust(void) {} +#endif
- /**
- numa_add_memblk() - Set node id to memblk
- @nid: NUMA node ID of the new memblk
@@ -401,6 +478,8 @@ static int __init numa_init(int (*init_func)(void))
setup_node_to_cpumask_map();
- node_reclaim_distance_adjust();
- return 0; out_free_distance: numa_free_distance();
-----邮件原件----- 发件人: Wangkefeng (OS Kernel Lab) 发送时间: 2024年5月5日 10:21 收件人: tanghui (C) tanghui20@huawei.com; kernel@openeuler.org 主题: Re: [PATCH OLK-6.6 1/2] arm64/numa: Support node_reclaim_distance adjust for arch
On 2024/4/30 10:17, Hui Tang wrote:
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
'node_reclaim_distance' affects scheduling behavior and memory reclamation, but the value is currently the default value and can not be set.
Now introduce the way to adjust 'node_reclaim_distance' depending on the cpu model.
Signed-off-by: Hui Tang tanghui20@huawei.com
arch/arm64/Kconfig | 13 +++++++ drivers/base/arch_numa.c | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2712d3c73719..6de3e70f8362 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2443,6 +2443,19 @@ config STACKPROTECTOR_PER_TASK def_bool y depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_SYSREG
+config ARCH_CUSTOM_NUMA_DISTANCE
- bool "Support custom node relaim distance"
- depends on ARM64 && ARCH_HISI && NUMA
No ARM64
Thanks
- default n
- help
Allow arch to adjust node_reclaim_distance.
Some machines may have a specific node distance to achieve optimal
system performance. You can set a specific node_reclaim_distance based
on the system topology.
If unsure, say N.
and this config should under 'Common NUMA Features'
Thanks
- config UNWIND_PATCH_PAC_INTO_SCS bool "Enable shadow call stack dynamically using code patching" # needs Clang with https://reviews.llvm.org/D111780 incorporated
diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 5b59d133b6af..af8b76e4f9fa 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -189,6 +189,83 @@ void __init setup_per_cpu_areas(void) } #endif
+#ifdef CONFIG_ARCH_CUSTOM_NUMA_DISTANCE +#define DISTANCE_MAX (1 << DISTANCE_BITS) +static void get_numa_distance_info(int *numa_levels, int +*max_distance) {
- DECLARE_BITMAP(distance_map, DISTANCE_MAX);
- int max = 0;
- int i, j;
- bitmap_zero(distance_map, DISTANCE_MAX);
- for (i = 0; i < nr_node_ids; i++) {
for (j = 0; j < nr_node_ids; j++) {
int distance = node_distance(i, j);
if (distance < LOCAL_DISTANCE ||
distance >= DISTANCE_MAX) {
return;
}
if (distance > max)
max = distance;
bitmap_set(distance_map, distance, 1);
}
- }
- if (numa_levels)
*numa_levels = bitmap_weight(distance_map, DISTANCE_MAX);
- if (max_distance)
*max_distance = max;
+}
+static int __init node_reclaim_distance_setup(char *str) {
- int val;
- if (kstrtoint(str, 0, &val))
return 0;
-EINVAL?
Thanks
- if (val < LOCAL_DISTANCE || val >= DISTANCE_MAX)
return 0;
-EINVAL?
Thanks
- if (val != RECLAIM_DISTANCE) {
node_reclaim_distance = val;
pr_info("Force set node_reclaim_distance to %d\n", val);
- }
- return 0;
+} +early_param("node_reclaim_distance", node_reclaim_distance_setup);
+static void __init node_reclaim_distance_adjust(void) +{
- unsigned int model = read_cpuid_id() & MIDR_CPU_MODEL_MASK;
- int max_distance = 0;
- int numa_levels = 0;
- switch (model) {
- case MIDR_HISI_LINXICORE9100:
get_numa_distance_info(&numa_levels, &max_distance);
if (nr_node_ids != 4 || numa_levels <= 3 ||
Why 4/3, no comment, also no details in changelog
node_reclaim_distance != RECLAIM_DISTANCE ||
max_distance <= RECLAIM_DISTANCE)
break;
node_reclaim_distance = max_distance;
pr_info("Force adjust node_reclaim_distance to %d\n",
node_reclaim_distance);
break;
- default:
break;
- }
+} +#else +static inline void __init node_reclaim_distance_adjust(void) {} +#endif
- /**
- numa_add_memblk() - Set node id to memblk
- @nid: NUMA node ID of the new memblk @@ -401,6 +478,8 @@ static
int __init numa_init(int (*init_func)(void))
setup_node_to_cpumask_map();
- node_reclaim_distance_adjust();
- return 0; out_free_distance: numa_free_distance();
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
--------------------------------
The COBFIG_ARCH_CUSTOM_NUMA_DISTANCE depend on ARM64 && ARCH_HISI && NUMA.
Allow arch to adjust the node_reclaim_distance.
Signed-off-by: Hui Tang tanghui20@huawei.com --- arch/arm64/configs/openeuler_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d551e8537e9b..3be3f61f3eb8 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -1194,6 +1194,7 @@ CONFIG_ETMEM_SCAN=m CONFIG_ETMEM_SWAP=m CONFIG_ETMEM=y # CONFIG_BPF_READAHEAD is not set +CONFIG_ARCH_CUSTOM_NUMA_DISTANCE=y
# # Data Access Monitoring
On 2024/4/30 10:17, Hui Tang wrote:
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
The COBFIG_ARCH_CUSTOM_NUMA_DISTANCE depend on ARM64 && ARCH_HISI && NUMA.
refresh the changelog please, since patch1 need to changed.
Allow arch to adjust the node_reclaim_distance.
Signed-off-by: Hui Tang tanghui20@huawei.com
arch/arm64/configs/openeuler_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d551e8537e9b..3be3f61f3eb8 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -1194,6 +1194,7 @@ CONFIG_ETMEM_SCAN=m CONFIG_ETMEM_SWAP=m CONFIG_ETMEM=y # CONFIG_BPF_READAHEAD is not set +CONFIG_ARCH_CUSTOM_NUMA_DISTANCE=y
Put it into the correct place, try to use menuconfig to find a better position.
# # Data Access Monitoring
-----邮件原件----- 发件人: Wangkefeng (OS Kernel Lab) 发送时间: 2024年5月5日 10:23 收件人: tanghui (C) tanghui20@huawei.com; kernel@openeuler.org 主题: Re: [PATCH OLK-6.6 2/2] config: enable COBFIG_ARCH_CUSTOM_NUMA_DISTANCE for arm64
On 2024/4/30 10:17, Hui Tang wrote:
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8PG0C CVE: NA
The COBFIG_ARCH_CUSTOM_NUMA_DISTANCE depend on ARM64 && ARCH_HISI && NUMA.
refresh the changelog please, since patch1 need to changed.
Thanks
Allow arch to adjust the node_reclaim_distance.
Signed-off-by: Hui Tang tanghui20@huawei.com
arch/arm64/configs/openeuler_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d551e8537e9b..3be3f61f3eb8 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -1194,6 +1194,7 @@ CONFIG_ETMEM_SCAN=m CONFIG_ETMEM_SWAP=m CONFIG_ETMEM=y # CONFIG_BPF_READAHEAD is not set +CONFIG_ARCH_CUSTOM_NUMA_DISTANCE=y
Put it into the correct place, try to use menuconfig to find a better position.
Thanks
# # Data Access Monitoring
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/6771 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/E...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/6771 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/E...