[Devel] [PATCH RHEL8 COMMIT] sched/stat: account forks per task group

Konstantin Khorenko khorenko at virtuozzo.com
Wed Nov 11 15:52:14 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.17
------>
commit 372ecbe6241acf33e718ad826670d5a03ed6efaa
Author: Vladimir Davydov <vdavydov.dev at gmail.com>
Date:   Thu Mar 14 21:00:53 2013 +0400

    sched/stat: account forks per task group
    
    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>
---
 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 646bbd257110..df5fe01c8f24 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -652,6 +652,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;
 
 	getboottime64(&boottime);
 
@@ -671,6 +672,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;
@@ -746,7 +748,7 @@ int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
 		   "procs_blocked %lu\n",
 		   tg_nr_switches,
 		   (unsigned long long)boot_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 0b9bb108625a..892329471df1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10300,6 +10300,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 3d55b45f1ea6..ccd8ad478a08 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -545,6 +545,7 @@ struct cfs_rq {
 	struct sched_entity	*prev;
 
 	u64 nr_switches;
+	unsigned long nr_forks;
 
 #ifdef	CONFIG_SCHED_DEBUG
 	unsigned int		nr_spread_over;


More information about the Devel mailing list