Commit 4ff53cf9 authored by Cheng Yu's avatar Cheng Yu
Browse files

sched/fair: Set the maximum number of steal attempts

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



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

When there are a large number of cfs tasks on rq, but only a few
steal_task tasks, steal_from may often fail to pull tasks. To avoid
multiple pull task failures, we can set the maximum number of steal
tasks through sysctl_sched_max_steal_count. The default value is 32 and
the maximum value is 1024.

Signed-off-by: default avatarCheng Yu <serein.chengyu@huawei.com>
parent 433c0b72
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ extern int sysctl_sched_util_low_pct;
extern int sysctl_sched_util_ratio;
#endif

#ifdef CONFIG_SCHED_STEAL
extern int sysctl_sched_max_steal_count;
#endif

#ifdef CONFIG_QOS_SCHED_SMART_GRID
extern unsigned int sysctl_smart_grid_strategy_ctrl;
extern int sysctl_affinity_adjust_delay_ms;
+7 −0
Original line number Diff line number Diff line
@@ -13183,6 +13183,7 @@ void trigger_load_balance(struct rq *rq)
}

#ifdef CONFIG_SCHED_STEAL
int sysctl_sched_max_steal_count = 32;
/*
 * Search the runnable tasks in @cfs_rq in order of next to run, and find
 * the first one that can be migrated to @dst_rq.  @cfs_rq is locked on entry.
@@ -13194,14 +13195,20 @@ detach_next_task(struct cfs_rq *cfs_rq, struct rq *dst_rq)
	int dst_cpu = dst_rq->cpu;
	struct task_struct *p;
	struct rq *rq = rq_of(cfs_rq);
	int count = 1;

	lockdep_assert_rq_held(rq_of(cfs_rq));

	list_for_each_entry_reverse(p, &rq->cfs_tasks, se.group_node) {
		if (count > sysctl_sched_max_steal_count)
			break;

		if (can_migrate_task_llc(p, rq, dst_rq)) {
			detach_task(p, rq, dst_cpu);
			return p;
		}

		count++;
	}
	return NULL;
}
+14 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ static int hundred_thousand = 100000;
#ifdef CONFIG_PERF_EVENTS
static int six_hundred_forty_kb = 640 * 1024;
#endif
#ifdef CONFIG_SCHED_STEAL
static int max_steal_count = 1024;
#endif

/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
@@ -2827,6 +2830,17 @@ static struct ctl_table kern_table[] = {
		.extra1         = SYSCTL_ZERO,
	},
#endif
#ifdef CONFIG_SCHED_STEAL
	{
		.procname       = "sched_max_steal_count",
		.data           = &sysctl_sched_max_steal_count,
		.maxlen         = sizeof(sysctl_sched_max_steal_count),
		.mode           = 0644,
		.proc_handler   = proc_dointvec_minmax,
		.extra1         = SYSCTL_ONE,
		.extra2         = &max_steal_count,
	},
#endif
#ifdef CONFIG_QOS_SCHED_SMART_GRID
	{
		.procname	= "smart_grid_strategy_ctrl",