From: Chengming Zhou <zhouchengming@bytedance.com>
To: hannes@cmpxchg.org, mingo@redhat.com, peterz@infradead.org,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org, songmuchun@bytedance.com,
zhouchengming@bytedance.com
Subject: [PATCH v2 1/4] psi: Add PSI_CPU_FULL state
Date: Wed, 3 Mar 2021 11:46:56 +0800 [thread overview]
Message-ID: <20210303034659.91735-2-zhouchengming@bytedance.com> (raw)
In-Reply-To: <20210303034659.91735-1-zhouchengming@bytedance.com>
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: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
---
include/linux/psi_types.h | 3 ++-
kernel/sched/psi.c | 14 +++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h
index b95f3211566a..0a23300d49af 100644
--- a/include/linux/psi_types.h
+++ b/include/linux/psi_types.h
@@ -50,9 +50,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,
};
enum psi_aggregators {
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 967732c0766c..2293c45d289d 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -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
@@ -225,6 +228,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];
@@ -678,8 +683,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;
@@ -1018,7 +1026,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;
--
2.11.0
next prev parent reply other threads:[~2021-03-03 11:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 3:46 [PATCH v2 0/4] psi: Add PSI_CPU_FULL state and some code optimization Chengming Zhou
2021-03-03 3:46 ` Chengming Zhou [this message]
2021-03-04 9:09 ` [tip: sched/core] psi: Add PSI_CPU_FULL state tip-bot2 for Chengming Zhou
2021-03-06 11:42 ` tip-bot2 for Chengming Zhou
2021-03-03 3:46 ` [PATCH v2 2/4] psi: Use ONCPU state tracking machinery to detect reclaim Chengming Zhou
2021-03-03 14:56 ` Johannes Weiner
2021-03-03 15:52 ` Peter Zijlstra
2021-03-04 9:09 ` [tip: sched/core] " tip-bot2 for Chengming Zhou
2021-03-06 11:42 ` tip-bot2 for Chengming Zhou
2021-03-03 3:46 ` [PATCH v2 3/4] psi: pressure states are unlikely Chengming Zhou
2021-03-04 9:09 ` [tip: sched/core] psi: Pressure " tip-bot2 for Johannes Weiner
2021-03-06 11:42 ` tip-bot2 for Johannes Weiner
2021-03-03 3:46 ` [PATCH v2 4/4] psi: Optimize task switch inside shared cgroups Chengming Zhou
2021-03-03 14:57 ` Johannes Weiner
2021-03-03 15:53 ` Peter Zijlstra
2021-03-03 16:01 ` [External] " Muchun Song
2021-03-04 9:09 ` [tip: sched/core] " tip-bot2 for Chengming Zhou
2021-03-06 11:42 ` tip-bot2 for Chengming Zhou
2021-03-03 14:59 ` [PATCH v2 0/4] psi: Add PSI_CPU_FULL state and some code optimization Johannes Weiner
2021-03-03 15:32 ` Peter Zijlstra
2021-03-03 16:05 ` Peter Zijlstra
2021-03-03 19:38 ` Johannes Weiner
2021-03-04 0:14 ` [External] " Chengming Zhou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210303034659.91735-2-zhouchengming@bytedance.com \
--to=zhouchengming@bytedance.com \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=songmuchun@bytedance.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).