Commit 15839de1 authored by Hui Tang's avatar Hui Tang
Browse files

sched: Introduce CONFIG_QOS_SCHED_NUMA_ICON

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9GZAQ


CVE: NA

--------------------------------

Introduce NUMA isolation and consolidation. If enabled,
scheduler will identify relationship between tasks,
and track NUMA resource usage.

With 'numa_icon=enable/disable' to control the feature.

Signed-off-by: default avatarHui Tang <tanghui20@huawei.com>
parent c923cbe8
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -2360,6 +2360,21 @@ struct bpf_sched_cpu_stats {
	KABI_RESERVE(4)
};

struct bpf_node_stats {
	unsigned long util;
	unsigned long compute_capacity;
	unsigned int weight;

	KABI_RESERVE(1)
	KABI_RESERVE(2)
	KABI_RESERVE(3)
	KABI_RESERVE(4)
	KABI_RESERVE(5)
	KABI_RESERVE(6)
	KABI_RESERVE(7)
	KABI_RESERVE(8)
};

struct cpumask_op_args {
	unsigned int op_type;
	void *arg1;
+7 −0
Original line number Diff line number Diff line
@@ -3914,6 +3914,12 @@ union bpf_attr {
 *		set current task preferred node.
 *	Return
 *		0 on success, or a negative error in case of failure.
 *
 * int bpf_get_node_stats(int nid, struct bpf_node_stats *ctx, int len)
 *	Description
 *		get resource statistics of *nid* and store in *ctx*.
 *	Return
 *		0 on success, or a negative error in case of failure.
 */
#define __BPF_FUNC_MAPPER(FN)		\
	FN(unspec),			\
@@ -4089,6 +4095,7 @@ union bpf_attr {
	FN(nodemask_op),		\
	FN(get_task_relationship_stats),\
	FN(sched_set_curr_preferred_node),\
	FN(get_node_stats),		\
	/* */

/* integer value in 'imm' field of BPF_CALL instruction selects which helper
+13 −0
Original line number Diff line number Diff line
@@ -1091,6 +1091,19 @@ config SCHED_TASK_RELATIONSHIP

	 If in doubt, say N.

config QOS_SCHED_NUMA_ICON
	bool "numa aware schedule"
	depends on BPF_SCHED
	depends on SCHED_TASK_RELATIONSHIP
	default n
	help
	 This feature provides the NUMA Isolation and Consolidationthe
	 Mechanisms based on ebpf and task relationship. If enabled, scheduler
	 places related tasks on same numa node when the node has spare
	 resource.

	 If in doubt, say N.

config UCLAMP_TASK_GROUP
	bool "Utilization clamping per group of tasks"
	depends on CGROUP_SCHED
+1 −0
Original line number Diff line number Diff line
@@ -41,3 +41,4 @@ obj-$(CONFIG_BPF_SCHED) += bpf_sched.o
obj-$(CONFIG_BPF_SCHED) += bpf_topology.o
obj-$(CONFIG_QOS_SCHED_SMART_GRID) += grid/
obj-$(CONFIG_SCHED_TASK_RELATIONSHIP) += relationship.o relationship_ioctl.o
obj-$(CONFIG_QOS_SCHED_NUMA_ICON) += numa_icon.o
+29 −0
Original line number Diff line number Diff line
@@ -346,6 +346,31 @@ static const struct bpf_func_proto bpf_cpus_share_cache_proto = {
	.arg2_type	= ARG_ANYTHING,
};

#ifdef CONFIG_QOS_SCHED_NUMA_ICON
BPF_CALL_3(bpf_get_node_stats, int, nid,
	   struct bpf_node_stats *, ctx,
	   int, len)
{
	if (len != sizeof(*ctx))
		return -EINVAL;

	if ((unsigned int)nid >= nr_node_ids)
		return -EINVAL;

	sched_get_node_load(nid, ctx);
	return 0;
}

const struct bpf_func_proto bpf_get_node_stats_proto = {
	.func		= bpf_get_node_stats,
	.gpl_only	= false,
	.ret_type	= RET_INTEGER,
	.arg1_type	= ARG_ANYTHING,
	.arg2_type	= ARG_PTR_TO_UNINIT_MEM,
	.arg3_type	= ARG_CONST_SIZE,
};
#endif

#ifdef CONFIG_SCHED_TASK_RELATIONSHIP
BPF_CALL_3(bpf_get_task_relationship_stats, struct task_struct *, tsk,
	   struct bpf_map *, map, struct bpf_relationship_get_args *, args)
@@ -413,6 +438,10 @@ bpf_sched_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
		return &bpf_cpus_share_cache_proto;
	case BPF_FUNC_nodemask_op:
		return &bpf_nodemask_op_proto;
#ifdef CONFIG_QOS_SCHED_NUMA_ICON
	case BPF_FUNC_get_node_stats:
		return &bpf_get_node_stats_proto;
#endif
#ifdef CONFIG_SCHED_TASK_RELATIONSHIP
	case BPF_FUNC_get_task_relationship_stats:
		return &bpf_get_task_relationship_stats_proto;
Loading