
From: Tengda Wu <wutengda2@huawei.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICAOAT -------------------------------- Collect the duration of bandwidth throttling when the cgroup is throttled. Signed-off-by: Tengda Wu <wutengda2@huawei.com> Signed-off-by: Pu Lehui <pulehui@huawei.com> --- include/linux/cgroup.h | 19 +++++++++++++++++++ kernel/cgroup/ifs.c | 3 +++ kernel/sched/fair.c | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 84273989b573..8fc762b3841c 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -865,6 +865,7 @@ void cgroup_move_task_to_root(struct task_struct *tsk); enum ifs_types { IFS_SMT, IFS_RUNDELAY, + IFS_THROTTLE, #ifdef CONFIG_SCHEDSTATS IFS_SLEEP, #endif @@ -937,6 +938,23 @@ static inline void cgroup_ifs_account_rundelay(struct task_struct *task, cgroup_ifs_account_delta(this_cpu_ptr(ifs->pcpu), IFS_RUNDELAY, delta); } +static inline void cgroup_ifs_account_throttle(struct cgroup *cgrp, int cpu, + u64 delta) +{ + struct cgroup_ifs *ifs; + struct cgroup_ifs_cpu *ifsc; + + if (!cgroup_ifs_enabled()) + return; + + ifs = cgroup_ifs(cgrp); + if (!ifs) + return; + + ifsc = per_cpu_ptr(ifs->pcpu, cpu); /* XXX: set another cpu data ? */ + cgroup_ifs_account_delta(ifsc, IFS_THROTTLE, delta); +} + #ifdef CONFIG_SCHEDSTATS static inline void cgroup_ifs_account_sleep(struct task_struct *task, u64 delta) @@ -962,6 +980,7 @@ static inline void cgroup_ifs_account_smttime(struct task_struct *prev, 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) {} +static inline void cgroup_ifs_account_throttle(struct cgroup *cgrp, int cpu, u64 delta) {} #ifdef CONFIG_SCHEDSTATS static inline void cgroup_ifs_account_sleep(struct task_struct *task, u64 delta) {} static inline void cgroup_ifs_enable_sleep_account(void) {} diff --git a/kernel/cgroup/ifs.c b/kernel/cgroup/ifs.c index c2de386315c2..dad42b38d16e 100644 --- a/kernel/cgroup/ifs.c +++ b/kernel/cgroup/ifs.c @@ -162,6 +162,9 @@ static const char *ifs_type_name(int type) case IFS_RUNDELAY: name = "rundelay"; break; + case IFS_THROTTLE: + name = "throttle"; + break; #ifdef CONFIG_SCHEDSTATS case IFS_SLEEP: name = "sleep"; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ddaa8dd71c3e..be95fd6394bc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6053,8 +6053,12 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) raw_spin_lock(&cfs_b->lock); if (cfs_rq->throttled_clock) { - cfs_b->throttled_time += rq_clock(rq) - cfs_rq->throttled_clock; + u64 delta = rq_clock(rq) - cfs_rq->throttled_clock; + + cfs_b->throttled_time += delta; cfs_rq->throttled_clock = 0; + cgroup_ifs_account_throttle(cfs_rq->tg->css.cgroup, + cpu_of(rq), delta); } list_del_rcu(&cfs_rq->throttled_list); raw_spin_unlock(&cfs_b->lock); -- 2.34.1