Skip to content

Commit

Permalink
blk-throttle: Avoid getting the current time if tg->last_finish_time …
Browse files Browse the repository at this point in the history
…is 0

We only update the tg->last_finish_time when the low limitaion is
enabled, so we can move the tg->last_finish_time validation a little
forward to avoid getting the unnecessary current time stamp if the
the low limitation is not enabled.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Baolin Wang authored and axboe committed Oct 8, 2020
1 parent 4247d9c commit 7901601
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,10 +2077,14 @@ static void throtl_downgrade_check(struct throtl_grp *tg)

static void blk_throtl_update_idletime(struct throtl_grp *tg)
{
unsigned long now = ktime_get_ns() >> 10;
unsigned long now;
unsigned long last_finish_time = tg->last_finish_time;

if (now <= last_finish_time || last_finish_time == 0 ||
if (last_finish_time == 0)
return;

now = ktime_get_ns() >> 10;
if (now <= last_finish_time ||
last_finish_time == tg->checked_last_finish_time)
return;

Expand Down

0 comments on commit 7901601

Please sign in to comment.