Unverified Commit 590f4f13 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!6824 Introduce CONFIG_ARCH_CUSTOM_NUMA_DISTANCE

Merge Pull Request from: @ci-robot 
 
PR sync from: Hui Tang <tanghui20@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/3C4T3FTBUBR5UYOXQV53W2RA6EG2NCQB/ 
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


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/I8PG0C 
 
Link:https://gitee.com/openeuler/kernel/pulls/6824

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
parents 1b2e5bdd 799eb28f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1582,6 +1582,19 @@ config NUMA_AWARE_SPINLOCKS

	  Say N if you want absolute first come first serve fairness.

config ARCH_CUSTOM_NUMA_DISTANCE
	bool "Support custom node relaim distance"
	depends on 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.

source "kernel/Kconfig.hz"

config ARCH_SPARSEMEM_ENABLE
+1 −0
Original line number Diff line number Diff line
@@ -464,6 +464,7 @@ CONFIG_HOTPLUG_CPU=y
CONFIG_NUMA=y
CONFIG_NODES_SHIFT=8
CONFIG_NUMA_AWARE_SPINLOCKS=y
CONFIG_ARCH_CUSTOM_NUMA_DISTANCE=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y
# CONFIG_HZ_300 is not set
+85 −0
Original line number Diff line number Diff line
@@ -189,6 +189,89 @@ 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 -EINVAL;

	if (val < LOCAL_DISTANCE || val >= DISTANCE_MAX)
		return -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);

		/*
		 * When numa_level more than three, sched domain may be
		 * asymmetrical, the number of CPUs of sched group is different
		 * from the brother in sched domain.
		 */
		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 +484,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();