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

!795 sched/fair: Introduce multiple qos level

Merge Pull Request from: @zhaowenhui8 
 
Expand qos_level from {-1,0} to [-2, 2], to distinguish the tasks expected
to be with extremely high or low priority level. Using qos_level_weight
to reweight the shares when calculating group's weight. Meanwhile,
set offline task's schedule policy to SCHED_IDLE so that it can be
preempted at check_preempt_wakeup.

kernel option:
CONFIG_QOS_SCHED_MULTILEVEL 
 
Link:https://gitee.com/openeuler/kernel/pulls/795

 

Reviewed-by: default avatarZucheng Zheng <zhengzucheng@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 623763f1 c51ad919
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_V1_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_QOS_SCHED=y
CONFIG_QOS_SCHED_MULTILEVEL=y
CONFIG_QOS_SCHED_DYNAMIC_AFFINITY=y
CONFIG_QOS_SCHED_SMT_EXPELLER=y
CONFIG_FAIR_GROUP_SCHED=y
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_V1_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_QOS_SCHED=y
CONFIG_QOS_SCHED_MULTILEVEL=y
CONFIG_QOS_SCHED_DYNAMIC_AFFINITY=y
CONFIG_QOS_SCHED_SMT_EXPELLER=y
CONFIG_FAIR_GROUP_SCHED=y
+4 −0
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ extern unsigned int sysctl_overload_detect_period;
extern unsigned int sysctl_offline_wait_interval;
#endif

#ifdef CONFIG_QOS_SCHED_MULTILEVEL
extern unsigned int sysctl_qos_level_weights[];
#endif

#ifdef CONFIG_QOS_SCHED_PRIO_LB
extern unsigned int sysctl_sched_prio_load_balance_enabled;
#endif
+9 −0
Original line number Diff line number Diff line
@@ -977,6 +977,15 @@ config QOS_SCHED

    default n

config QOS_SCHED_MULTILEVEL
	bool "Multiple qos level task scheduling"
	depends on QOS_SCHED
	default n
	help
	  This feature enable multiple qos level on task scheduling.
	  Expand the qos_level to [-2,2] to distinguish the tasks expected
	  to be with extremely high or low priority level.

config QOS_SCHED_SMT_EXPELLER
	bool "Qos smt expeller"
	depends on SCHED_SMT
+14 −6
Original line number Diff line number Diff line
@@ -6437,7 +6437,7 @@ static int __sched_setscheduler(struct task_struct *p,
	 * other than SCHED_IDLE, the online task preemption and cpu resource
	 * isolation will be invalid, so return -EINVAL in this case.
	 */
	if (unlikely(task_group(p)->qos_level == -1 && !idle_policy(policy))) {
	if (unlikely(is_offline_level(task_group(p)->qos_level) && !idle_policy(policy))) {
		retval = -EINVAL;
		goto unlock;
	}
@@ -8562,7 +8562,7 @@ static void sched_change_qos_group(struct task_struct *tsk, struct task_group *t
	 */
	if (!(tsk->flags & PF_EXITING) &&
	    !task_group_is_autogroup(tg) &&
	    (tg->qos_level == -1)) {
	    (is_offline_level(tg->qos_level))) {
		attr.sched_priority = 0;
		attr.sched_policy = SCHED_IDLE;
		__setscheduler_params(tsk, &attr);
@@ -8590,7 +8590,7 @@ void sched_move_offline_task(struct task_struct *p)
{
	struct offline_args *args;

	if (unlikely(task_group(p)->qos_level != -1))
	if (unlikely(!is_offline_level(task_group(p)->qos_level)))
		return;

	args = kmalloc(sizeof(struct offline_args), GFP_ATOMIC);
@@ -9463,7 +9463,7 @@ static int tg_change_scheduler(struct task_group *tg, void *data)
	struct cgroup_subsys_state *css = &tg->css;

	tg->qos_level = qos_level;
	if (qos_level == -1)
	if (is_offline_level(qos_level))
		policy = SCHED_IDLE;
	else
		policy = SCHED_NORMAL;
@@ -9485,19 +9485,27 @@ static int cpu_qos_write(struct cgroup_subsys_state *css,
	if (!tg->se[0])
		return -EINVAL;

#ifdef CONFIG_QOS_SCHED_MULTILEVEL
	if (qos_level > QOS_LEVEL_HIGH_EX || qos_level < QOS_LEVEL_OFFLINE_EX)
#else
	if (qos_level != -1 && qos_level != 0)
#endif
		return -EINVAL;

	if (tg->qos_level == qos_level)
		goto done;

#ifdef CONFIG_QOS_SCHED_MULTILEVEL
	if (!is_normal_level(tg->qos_level))
#else
	if (tg->qos_level == -1 && qos_level == 0)
#endif
		return -EINVAL;

	cpus_read_lock();
	if (qos_level == -1)
	if (is_offline_level(qos_level))
		cfs_bandwidth_usage_inc();
	else
	else if (is_offline_level(tg->qos_level) && !is_offline_level(qos_level))
		cfs_bandwidth_usage_dec();
	cpus_read_unlock();

Loading