Commit e05cfcd6 authored by Chengming Zhou's avatar Chengming Zhou Committed by Zheng Zengkai
Browse files

psi: Add PSI_CPU_FULL state

mainline inclusion
from mainline-v5.13-rc1
commit e7fcd762
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I562O9
CVE: NA
backport: openEuler-22.03-LTS

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e7fcd762282332f765af2035a9568fb126fa3c01



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

The FULL state doesn't exist for the CPU resource at the system level,
but exist at the cgroup level, means all non-idle tasks in a cgroup are
delayed on the CPU resource which used by others outside of the cgroup
or throttled by the cgroup cpu.max configuration.

Co-developed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Link: https://lkml.kernel.org/r/20210303034659.91735-2-zhouchengming@bytedance.com


Signed-off-by: default avatarChen Wandun <chenwandun@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent fce145ba
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -92,9 +92,10 @@ enum psi_states {
	PSI_MEM_SOME,
	PSI_MEM_FULL,
	PSI_CPU_SOME,
	PSI_CPU_FULL,
	/* Only per-CPU, to weigh the CPU in the global average: */
	PSI_NONIDLE,
	NR_PSI_STATES = 6,
	NR_PSI_STATES = 7,
};
#endif

+11 −3
Original line number Diff line number Diff line
@@ -34,7 +34,10 @@
 * delayed on that resource such that nobody is advancing and the CPU
 * goes idle. This leaves both workload and CPU unproductive.
 *
 * (Naturally, the FULL state doesn't exist for the CPU resource.)
 * Naturally, the FULL state doesn't exist for the CPU resource at the
 * system level, but exist at the cgroup level, means all non-idle tasks
 * in a cgroup are delayed on the CPU resource which used by others outside
 * of the cgroup or throttled by the cgroup cpu.max configuration.
 *
 *	SOME = nr_delayed_tasks != 0
 *	FULL = nr_delayed_tasks != 0 && nr_running_tasks == 0
@@ -232,6 +235,8 @@ static bool test_state(unsigned int *tasks, enum psi_states state)
		return tasks[NR_MEMSTALL] && !tasks[NR_RUNNING];
	case PSI_CPU_SOME:
		return tasks[NR_RUNNING] > tasks[NR_ONCPU];
	case PSI_CPU_FULL:
		return tasks[NR_RUNNING] && !tasks[NR_ONCPU];
	case PSI_NONIDLE:
		return tasks[NR_IOWAIT] || tasks[NR_MEMSTALL] ||
			tasks[NR_RUNNING];
@@ -685,8 +690,11 @@ static void record_times(struct psi_group_cpu *groupc, int cpu,
		}
	}

	if (groupc->state_mask & (1 << PSI_CPU_SOME))
	if (groupc->state_mask & (1 << PSI_CPU_SOME)) {
		groupc->times[PSI_CPU_SOME] += delta;
		if (groupc->state_mask & (1 << PSI_CPU_FULL))
			groupc->times[PSI_CPU_FULL] += delta;
	}

	if (groupc->state_mask & (1 << PSI_NONIDLE))
		groupc->times[PSI_NONIDLE] += delta;
@@ -1044,7 +1052,7 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
		group->avg_next_update = update_averages(group, now);
	mutex_unlock(&group->avgs_lock);

	for (full = 0; full < 2 - (res == PSI_CPU); full++) {
	for (full = 0; full < 2; full++) {
		unsigned long avg[3];
		u64 total;
		int w;