-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0001-Prevent-CFS-from-ignoring-boost-requests-from-KVM.patch
58 lines (51 loc) · 1.81 KB
/
0001-Prevent-CFS-from-ignoring-boost-requests-from-KVM.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From a3c64f59e6fdc0975e480eced26144a6d0bc7182 Mon Sep 17 00:00:00 2001
From: Kenta Ishiguro <[email protected]>
Date: Wed, 14 Jul 2021 01:52:13 +0900
Subject: [PATCH 1/2] Prevent CFS from ignoring boost requests from KVM
This commit increases the vruntime of yielded vCPU to boost a vCPU
instead of the yielded vCPU when two vCPUs are in the same VM. This
change avoids the situation where scheduling the boosted vCPU is too
unfair.
---
kernel/sched/fair.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c1217bfe5e81..a12c802e2322 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6878,10 +6878,26 @@ static void yield_task_fair(struct rq *rq)
set_skip_buddy(se);
}
+static void deboost_yield_task_vruntime(struct sched_entity *next_se, struct sched_entity *yield_se)
+{
+ if (wakeup_preempt_entity(next_se, yield_se) >= 1)
+ yield_se->vruntime = next_se->vruntime - wakeup_gran(next_se);
+}
+
+static void deboost_yield_task(struct sched_entity *next_se, struct sched_entity *yield_se)
+{
+ if (cfs_rq_of(yield_se) != cfs_rq_of(next_se))
+ return;
+ deboost_yield_task_vruntime(next_se, yield_se);
+}
+
static bool yield_to_task_fair(struct rq *rq, struct task_struct *p, bool preempt)
{
struct sched_entity *se = &p->se;
+ struct task_struct *curr;
+ struct sched_entity *yield_se;
+
/* throttled hierarchies are not runnable */
if (!se->on_rq || throttled_hierarchy(cfs_rq_of(se)))
return false;
@@ -6889,6 +6905,10 @@ static bool yield_to_task_fair(struct rq *rq, struct task_struct *p, bool preemp
/* Tell the scheduler that we'd really like pse to run next. */
set_next_buddy(se);
+ curr = rq->curr;
+ yield_se = &curr->se;
+ deboost_yield_task(se, yield_se);
+
yield_task_fair(rq);
return true;
--
2.20.1