[PATCH] sched/deadline: Skip overflow check if 0 capacity

From: Waiman Long
Date: Thu Nov 07 2024 - 23:29:54 EST


By properly setting up a 1-cpu sched domain (partition) with no
task, it was found that offlining that particular CPU failed because
dl_bw_check_overflow() in cpuset_cpu_inactive() returned -EBUSY. This
is due to the fact that dl_bw_capacity() return 0 as the sched domain
has no active CPU causing a false positive in the overflow check.

Fix this corner case by skipping the __dl_overflow() check in
dl_bw_manage() when the returned capacity is 0.

Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
kernel/sched/deadline.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index be1b917dc8ce..0195f350d6d3 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3479,7 +3479,13 @@ static int dl_bw_manage(enum dl_bw_request req, int cpu, u64 dl_bw)
} else {
unsigned long cap = dl_bw_capacity(cpu);

- overflow = __dl_overflow(dl_b, cap, 0, dl_bw);
+ /*
+ * In the unlikely case of 0 capacity (e.g. a sched domain
+ * with no active CPUs), skip the overflow check as it will
+ * always return a false positive.
+ */
+ if (likely(cap))
+ overflow = __dl_overflow(dl_b, cap, 0, dl_bw);

if (req == dl_bw_req_alloc && !overflow) {
/*
--
2.47.0