diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-01-16 17:18:39 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-02-05 18:07:34 +0100 |
commit | 06b23f92af87a84d70881b2ecaa72e00f7838264 (patch) | |
tree | bf23c4626e3b3c5ab01d0661e0d1b6644d10c8bf /block | |
parent | block: cache current nsec time in struct blk_plug (diff) | |
download | linux-06b23f92af87a84d70881b2ecaa72e00f7838264.tar.xz linux-06b23f92af87a84d70881b2ecaa72e00f7838264.zip |
block: update cached timestamp post schedule/preemption
Mark the task as having a cached timestamp when set assign it, so we
can efficiently check if it needs updating post being scheduled back in.
This covers both the actual schedule out case, which would've flushed
the plug, and the preemption case which doesn't touch the plugged
requests (for many reasons, one of them being then we'd need to have
preemption disabled around plug state manipulation).
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 2 | ||||
-rw-r--r-- | block/blk.h | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 13b449df5ba0..314c3065891a 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1183,6 +1183,8 @@ void __blk_flush_plug(struct blk_plug *plug, bool from_schedule) */ if (unlikely(!rq_list_empty(plug->cached_rq))) blk_mq_free_plug_rqs(plug); + + current->flags &= ~PF_BLOCK_TS; } /** diff --git a/block/blk.h b/block/blk.h index 14bbc4b780f2..913c93838a01 100644 --- a/block/blk.h +++ b/block/blk.h @@ -529,8 +529,10 @@ static inline u64 blk_time_get_ns(void) * a valid timestamp" separately, just accept that we'll do an extra * ktime_get_ns() if we just happen to get 0 as the current time. */ - if (!plug->cur_ktime) + if (!plug->cur_ktime) { plug->cur_ktime = ktime_get_ns(); + current->flags |= PF_BLOCK_TS; + } return plug->cur_ktime; } |