[PATCH] sched/rt: Add borrowing time condition

From: qiang.zhang
Date: Wed May 20 2020 - 04:01:36 EST


From: Zhang Qiang <qiang.zhang@xxxxxxxxxxxxx>

Add priority judgment to determine whether to borrow time from neighbors,
ensure that the rt_runntime of rt_rq with higher priority tasks is not
reduced

Signed-off-by: Zhang Qiang <qiang.zhang@xxxxxxxxxxxxx>
---
kernel/sched/rt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 4043abe45459..d2a1acad6687 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -711,8 +711,10 @@ static void do_balance_runtime(struct rt_rq *rt_rq)
diff = div_u64((u64)diff, weight);
if (rt_rq->rt_runtime + diff > rt_period)
diff = rt_period - rt_rq->rt_runtime;
- iter->rt_runtime -= diff;
- rt_rq->rt_runtime += diff;
+ if (rt_rq->highest_prio.curr < iter->highest_prio.curr) {
+ iter->rt_runtime -= diff;
+ rt_rq->rt_runtime += diff;
+ }
if (rt_rq->rt_runtime == rt_period) {
raw_spin_unlock(&iter->rt_runtime_lock);
break;
--
2.17.0