[Devel] [PATCH vz9 12/27] sched/stat: account forks per task group
Nikita Yushchenko
nikita.yushchenko at virtuozzo.com
Wed Oct 6 11:57:28 MSK 2021
From: Vladimir Davydov <vdavydov at parallels.com>
This is a backport of diff-sched-account-forks-per-task-group:
Subject: sched: account forks per task group
Date: Fri, 28 Dec 2012 15:09:46 +0400
* [sched] the number of processes should be reported correctly
inside a CT in /proc/stat (PSBM-18113)
For /proc/stat:processes to be correct inside containers.
https://jira.sw.ru/browse/PSBM-18113
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
(cherry picked from vz7 commit 0a927bf02fd873f4e9bad7c4df0c201bf9b48274)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
(cherry-picked from vz8 commit 39a333ce60a2 ("sched/stat: account forks
per task group"))
Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
kernel/sched/cpuacct.c | 4 +++-
kernel/sched/fair.c | 1 +
kernel/sched/sched.h | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 9e7da99bb9d3..5d7b02253e2b 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -654,6 +654,7 @@ int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
unsigned long tg_nr_running = 0;
unsigned long tg_nr_iowait = 0;
unsigned long long tg_nr_switches = 0;
+ unsigned long tg_nr_forks = 0;
time_ns = ve_get_time_ns(get_exec_env());
if (time_ns) {
@@ -678,6 +679,7 @@ int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
tg_nr_running += tg->cfs_rq[i]->h_nr_running;
tg_nr_iowait += tg->cfs_rq[i]->nr_iowait;
tg_nr_switches += tg->cfs_rq[i]->nr_switches;
+ tg_nr_forks += tg->cfs_rq[i]->nr_forks;
#endif
#ifdef CONFIG_RT_GROUP_SCHED
tg_nr_running += tg->rt_rq[i]->rt_nr_running;
@@ -753,7 +755,7 @@ int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
"procs_blocked %lu\n",
tg_nr_switches,
(unsigned long long)boottime.tv_sec,
- total_forks,
+ tg_nr_forks,
tg_nr_running,
tg_nr_iowait);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b8de26a5629d..db7eb593e9db 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11461,6 +11461,7 @@ static void task_fork_fair(struct task_struct *p)
}
se->vruntime -= cfs_rq->min_vruntime;
+ cfs_rq->nr_forks++;
rq_unlock(rq, &rf);
}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 5042f45bf887..22f3475f82c9 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -582,6 +582,7 @@ struct cfs_rq {
struct sched_entity *prev;
u64 nr_switches;
+ unsigned long nr_forks;
#ifdef CONFIG_SCHED_DEBUG
unsigned int nr_spread_over;
--
2.30.2
More information about the Devel
mailing list