hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDA3VP ----------------------------------------- When the quota is set to -1 or 0 (disabled), the group may remain throttled after a previous enforcement because no timer is armed and no explicit unthrottle is performed. This can cause tasks, including AI workloads, to stall indefinitely. Explicitly unthrottle the xsched group when the quota is disabled so that tasks are properly resumed. Fixes: aafde051ac61 ("xsched: Add support for CFS quota for cgroups") Signed-off-by: Zicheng Qu <quzicheng@huawei.com> --- kernel/xsched/cfs_quota.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/kernel/xsched/cfs_quota.c b/kernel/xsched/cfs_quota.c index 2b516ab5592f..11aca4dc711c 100644 --- a/kernel/xsched/cfs_quota.c +++ b/kernel/xsched/cfs_quota.c @@ -19,10 +19,23 @@ static struct workqueue_struct *quota_workqueue; -void xsched_quota_refill(struct work_struct *work) +static void xsched_group_unthrottle(struct xsched_group *xg) { uint32_t id; struct xsched_cu *xcu; + + for_each_active_xcu(xcu, id) { + mutex_lock(&xcu->xcu_lock); + 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); + } + mutex_unlock(&xcu->xcu_lock); + } +} + +void xsched_quota_refill(struct work_struct *work) +{ struct xsched_group *xg; xg = container_of(work, struct xsched_group, refill_work); @@ -38,14 +51,7 @@ void xsched_quota_refill(struct work_struct *work) return; } - for_each_active_xcu(xcu, id) { - mutex_lock(&xcu->xcu_lock); - 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); - } - mutex_unlock(&xcu->xcu_lock); - } + xsched_group_unthrottle(xg); } static enum hrtimer_restart quota_timer_cb(struct hrtimer *hrtimer) @@ -95,4 +101,6 @@ void xsched_quota_timeout_update(struct xsched_group *xg) if (xg->quota > 0 && xg->period > 0) hrtimer_start(t, ns_to_ktime(xg->period), HRTIMER_MODE_REL_SOFT); + else + xsched_group_unthrottle(xg); } -- 2.34.1