Skip to content

Commit a02195c

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: remove direct switch to an entity in higher class
If the function bfq_update_next_in_service is invoked as a consequence of the activation or requeueing of an entity, say E, and finds out that E belongs to a higher-priority class than that of the current next-in-service entity, then it sets next_in_service directly to E. But this may lead to anomalous schedules, because E may happen not be eligible for service, because its virtual start time is higher than the system virtual time for its service tree. This commit addresses this issue by simply removing this direct switch. Signed-off-by: Paolo Valente <[email protected]> Tested-by: Lee Tibbert <[email protected]> Tested-by: Oleksandr Natalenko <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 80294c3 commit a02195c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

block/bfq-wf2q.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd,
8686
* or repositiong of an entity that does not coincide with
8787
* sd->next_in_service, then a full lookup in the active tree
8888
* can be avoided. In fact, it is enough to check whether the
89-
* just-modified entity has a higher priority than
90-
* sd->next_in_service, or, even if it has the same priority
91-
* as sd->next_in_service, is eligible and has a lower virtual
89+
* just-modified entity has the same priority as
90+
* sd->next_in_service, is eligible and has a lower virtual
9291
* finish time than sd->next_in_service. If this compound
9392
* condition holds, then the new entity becomes the new
9493
* next_in_service. Otherwise no change is needed.
@@ -104,31 +103,23 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd,
104103

105104
/*
106105
* If there is already a next_in_service candidate
107-
* entity, then compare class priorities or timestamps
108-
* to decide whether to replace sd->service_tree with
109-
* new_entity.
106+
* entity, then compare timestamps to decide whether
107+
* to replace sd->service_tree with new_entity.
110108
*/
111109
if (next_in_service) {
112110
unsigned int new_entity_class_idx =
113111
bfq_class_idx(new_entity);
114112
struct bfq_service_tree *st =
115113
sd->service_tree + new_entity_class_idx;
116114

117-
/*
118-
* For efficiency, evaluate the most likely
119-
* sub-condition first.
120-
*/
121115
replace_next =
122116
(new_entity_class_idx ==
123117
bfq_class_idx(next_in_service)
124118
&&
125119
!bfq_gt(new_entity->start, st->vtime)
126120
&&
127121
bfq_gt(next_in_service->finish,
128-
new_entity->finish))
129-
||
130-
new_entity_class_idx <
131-
bfq_class_idx(next_in_service);
122+
new_entity->finish));
132123
}
133124

134125
if (replace_next)

0 commit comments

Comments
 (0)