aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-01-16 09:18:39 -0700
committerJens Axboe <axboe@kernel.dk>2024-02-05 10:07:34 -0700
commit06b23f92af87a84d70881b2ecaa72e00f7838264 (patch)
treebf23c4626e3b3c5ab01d0661e0d1b6644d10c8bf /block
parentda4c8c3d0975f031ef82d39927102e39fa6ddfac (diff)
downloadlinux-06b23f92af87a84d70881b2ecaa72e00f7838264.tar.gz
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.c2
-rw-r--r--block/blk.h4
2 files changed, 5 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 13b449df5ba02b..314c3065891a51 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 14bbc4b780f275..913c93838a01bf 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;
}