Currently, decrease_time_jif is initialized to 0 and will be updated in function bfq_reset_inject_limit and bfq_update_inject_limit while these two functions are called when jiffies pasts decrease_time_jif with some extra time or think-time state changes. If jiffies is slightly larger than MAX_JIFFY_OFFSET, it will take a long time to meet the first condition. The second condition is heavily relies on process behavior. To be more specific: Function bfq_update_inject_limit maybe triggered when jiffies pasts decrease_time_jif + msecs_to_jiffies(10) in bfq_add_request by setting bfqd->wait_dispatch to true. Function bfq_reset_inject_limit are called in two conditions: 1. jiffies pasts bfqq->decrease_time_jif + msecs_to_jiffies(1000) in function bfq_add_request. 2. jiffies pasts bfqq->decrease_time_jif + msecs_to_jiffies(100) or bfq think-time state change from short to long. In worst case that jiffies is slightly larger than MAX_JIFFY_OFFSET and think-time state never changes, the service injection may be not triggered for a long time. Fix this by initializing bfqq->decrease_time_jif to current jiffies to trigger service injection soon when service injection conditions are met. Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxx> --- block/bfq-iosched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index fc71181a7e5d..01fa16047eb5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5557,6 +5557,8 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, /* first request is almost certainly seeky */ bfqq->seek_history = 1; + + bfqq->decrease_time_jif = jiffies; } static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, -- 2.30.0