1 |
From 6c5171592e7ead19ded39d326a6f3b135178d5c5 Mon Sep 17 00:00:00 2001 |
2 |
From: Paolo Valente <paolo.valente@linaro.org> |
3 |
Date: Fri, 14 Sep 2018 16:23:07 +0200 |
4 |
Subject: [PATCH 057/145] block, bfq: correctly charge and reset entity service |
5 |
in all cases |
6 |
|
7 |
[ Upstream commit cbeb869a3d1110450186b738199963c5e68c2a71 ] |
8 |
|
9 |
BFQ schedules entities (which represent either per-process queues or |
10 |
groups of queues) as a function of their timestamps. In particular, as |
11 |
a function of their (virtual) finish times. The finish time of an |
12 |
entity is computed as a function of the budget assigned to the entity, |
13 |
assuming, tentatively, that the entity, once in service, will receive |
14 |
an amount of service equal to its budget. Then, when the entity is |
15 |
expired because it finishes to be served, this finish time is updated |
16 |
as a function of the actual service received by the entity. This |
17 |
allows the entity to be correctly charged with only the service |
18 |
received, and then to be correctly re-scheduled. |
19 |
|
20 |
Yet an entity may receive service also while not being the entity in |
21 |
service (in the scheduling environment of its parent entity), for |
22 |
several reasons. If the entity remains with no backlog while receiving |
23 |
this 'unofficial' service, then it is expired. Also on such an |
24 |
expiration, the finish time of the entity should be updated to account |
25 |
for only the service actually received by the entity. Unfortunately, |
26 |
such an update is not performed for an entity expiring without being |
27 |
the entity in service. |
28 |
|
29 |
In a similar vein, the service counter of the entity in service is |
30 |
reset when the entity is expired, to be ready to be used for next |
31 |
service cycle. This reset too should be performed also in case an |
32 |
entity is expired because it remains empty after receiving service |
33 |
while not being the entity in service. But in this case the reset is |
34 |
not performed. |
35 |
|
36 |
This commit performs the above update of the finish time and reset of |
37 |
the service received, also for an entity expiring while not being the |
38 |
entity in service. |
39 |
|
40 |
Signed-off-by: Paolo Valente <paolo.valente@linaro.org> |
41 |
Signed-off-by: Jens Axboe <axboe@kernel.dk> |
42 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
43 |
--- |
44 |
block/bfq-wf2q.c | 13 ++++++++++--- |
45 |
1 file changed, 10 insertions(+), 3 deletions(-) |
46 |
|
47 |
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c |
48 |
index ae52bff43ce4..ff7c2d470bb8 100644 |
49 |
--- a/block/bfq-wf2q.c |
50 |
+++ b/block/bfq-wf2q.c |
51 |
@@ -1181,10 +1181,17 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) |
52 |
st = bfq_entity_service_tree(entity); |
53 |
is_in_service = entity == sd->in_service_entity; |
54 |
|
55 |
- if (is_in_service) { |
56 |
- bfq_calc_finish(entity, entity->service); |
57 |
+ bfq_calc_finish(entity, entity->service); |
58 |
+ |
59 |
+ if (is_in_service) |
60 |
sd->in_service_entity = NULL; |
61 |
- } |
62 |
+ else |
63 |
+ /* |
64 |
+ * Non in-service entity: nobody will take care of |
65 |
+ * resetting its service counter on expiration. Do it |
66 |
+ * now. |
67 |
+ */ |
68 |
+ entity->service = 0; |
69 |
|
70 |
if (entity->tree == &st->active) |
71 |
bfq_active_extract(st, entity); |
72 |
-- |
73 |
2.19.1 |
74 |
|