
From: Tengda Wu <wutengda2@huawei.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICAOAT -------------------------------- Reuse the 'run_delay' in /proc/<pid>/schedstat to accounting 'rundelay' interference, which indicates how much time the cgroup tasks are in runnable state and wait for running. Signed-off-by: Tengda Wu <wutengda2@huawei.com> Signed-off-by: Pu Lehui <pulehui@huawei.com> --- include/linux/cgroup.h | 17 +++++++++++++++++ kernel/cgroup/ifs.c | 3 +++ kernel/sched/stats.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 256d04d28ea2..522f775e5139 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -864,6 +864,7 @@ void cgroup_move_task_to_root(struct task_struct *tsk); enum ifs_types { IFS_SMT, + IFS_RUNDELAY, NR_IFS_TYPES, }; @@ -918,11 +919,27 @@ void cgroup_ifs_account_smttime(struct task_struct *prev, struct task_struct *idle); void cgroup_ifs_set_smt(cpumask_t *sibling); +static inline void cgroup_ifs_account_rundelay(struct task_struct *task, + u64 delta) +{ + struct cgroup_ifs *ifs; + + if (!cgroup_ifs_enabled()) + return; + + ifs = task_ifs(task); + if (!ifs) + return; + + cgroup_ifs_account_delta(this_cpu_ptr(ifs->pcpu), IFS_RUNDELAY, delta); +} + #else /* !CONFIG_CGROUP_IFS */ static inline void cgroup_ifs_account_smttime(struct task_struct *prev, struct task_struct *next, struct task_struct *idle) {} static inline void cgroup_ifs_set_smt(cpumask_t *sibling) {} +static inline void cgroup_ifs_account_rundelay(struct task_struct *task, u64 delta) {} #endif /* CONFIG_CGROUP_IFS */ #endif /* _LINUX_CGROUP_H */ diff --git a/kernel/cgroup/ifs.c b/kernel/cgroup/ifs.c index 634ce18e0773..7bc11c82fce4 100644 --- a/kernel/cgroup/ifs.c +++ b/kernel/cgroup/ifs.c @@ -155,6 +155,9 @@ static const char *ifs_type_name(int type) case IFS_SMT: name = "smt"; break; + case IFS_RUNDELAY: + name = "rundelay"; + break; default: break; } diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index a6d7206d969d..6d40d4d55b27 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h @@ -241,6 +241,7 @@ static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t) t->sched_info.last_queued = 0; t->sched_info.run_delay += delta; + cgroup_ifs_account_rundelay(t, delta); rq_sched_info_dequeue(rq, delta); } @@ -263,6 +264,7 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t) t->sched_info.last_arrival = now; t->sched_info.pcount++; + cgroup_ifs_account_rundelay(t, delta); rq_sched_info_arrive(rq, delta); } -- 2.34.1