hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDA3VP ----------------------------------------- Track the number of throttle events and the total throttled time for each xsched group by recording nr_throttled, throttled_time and the start time of each throttling interval. The throttling start time is recorded when the group is dequeued due to quota enforcement and the duration is accumulated when the group is unthrottled, providing better observability of quota behavior. Fixes: aafde051ac61 ("xsched: Add support for CFS quota for cgroups") Signed-off-by: Zicheng Qu <quzicheng@huawei.com> --- include/linux/xsched.h | 1 + kernel/xsched/cfs_quota.c | 8 ++++++++ kernel/xsched/core.c | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/xsched.h b/include/linux/xsched.h index d4dc321bb216..a277c70b605b 100644 --- a/include/linux/xsched.h +++ b/include/linux/xsched.h @@ -248,6 +248,7 @@ struct xsched_group_xcu_priv { /* Statistics */ int nr_throttled; u64 throttled_time; + ktime_t start_throttled_time; }; enum xcu_file_type { diff --git a/kernel/xsched/cfs_quota.c b/kernel/xsched/cfs_quota.c index 11aca4dc711c..2e17a48c071b 100644 --- a/kernel/xsched/cfs_quota.c +++ b/kernel/xsched/cfs_quota.c @@ -29,6 +29,14 @@ static void xsched_group_unthrottle(struct xsched_group *xg) if (!READ_ONCE(xg->perxcu_priv[id].xse.on_rq)) { enqueue_ctx(&xg->perxcu_priv[id].xse, xcu); wake_up_interruptible(&xcu->wq_xcu_idle); + + if (xg->perxcu_priv[id].start_throttled_time != 0) { + xg->perxcu_priv[id].throttled_time += + ktime_to_ns(ktime_sub(ktime_get(), + xg->perxcu_priv[id].start_throttled_time)); + + xg->perxcu_priv[id].start_throttled_time = 0; + } } mutex_unlock(&xcu->xcu_lock); } diff --git a/kernel/xsched/core.c b/kernel/xsched/core.c index b23f2ca7820b..57479fe800c9 100644 --- a/kernel/xsched/core.c +++ b/kernel/xsched/core.c @@ -411,8 +411,12 @@ int xsched_schedule(void *input_xcu) dequeue_ctx(curr_xse, xcu); #ifdef CONFIG_CGROUP_XCU - if (xsched_quota_exceed(curr_xse->parent_grp)) + if (xsched_quota_exceed(curr_xse->parent_grp)) { dequeue_ctx(&curr_xse->parent_grp->perxcu_priv[xcu->id].xse, xcu); + curr_xse->parent_grp->perxcu_priv[xcu->id].nr_throttled++; + curr_xse->parent_grp->perxcu_priv[xcu->id].start_throttled_time = + ktime_get(); + } #endif xcu->xrq.curr_xse = NULL; -- 2.34.1