Usama Arif and Jens Axboe
fad156c2af
block: invalidate cached plug timestamp after task switch
...
blk_time_get_ns() caches ktime_get_ns() in current->plug->cur_ktime
and marks the task with PF_BLOCK_TS. That cache is only valid while the
task keeps running; if the task is switched out, wall-clock time
advances and the cached value must not be reused when the task runs again.
The existing invalidation covers explicit plug flushes through
__blk_flush_plug(), and the schedule() / rtmutex paths through
sched_update_worker(). It does not cover in-kernel preemption paths such
as preempt_schedule(), preempt_schedule_notrace(), and
preempt_schedule_irq(), which enter __schedule(SM_PREEMPT) directly and
return without calling sched_update_worker().
As a result, a task preempted while holding a plug with PF_BLOCK_TS set
can reuse a stale plug->cur_ktime after it is scheduled back in. blk-iocost
then consumes that stale timestamp through ioc_now(), producing stale vnow
values for throttle decisions, and through ioc_rqos_done(), inflating
on-queue time and feeding false missed-QoS samples into vrate
adjustment.
Move the schedule-side invalidation to finish_task_switch(), which runs
for the scheduled-in task after every actual context switch regardless
of which schedule entry point was used. Keep __blk_flush_plug() as the
explicit flush/finish-plug invalidation path, and remove only the
PF_BLOCK_TS handling from sched_update_worker().
Fixes: 06b23f92af ("block: update cached timestamp post schedule/preemption")
Cc: stable@vger.kernel.org
Signed-off-by: Usama Arif <usama.arif@linux.dev >
Link: https://patch.msgid.link/20260616141604.328820-3-usama.arif@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2026-06-16 10:07:36 -06:00
..
2026-05-30 22:25:23 +02:00
2026-05-30 22:25:32 +02:00
2026-05-30 22:25:50 +02:00
2026-05-26 13:24:32 +02:00
2026-06-15 04:15:31 +05:30
2026-06-11 10:26:40 +02:00
2026-05-11 15:07:23 +02:00
2026-05-26 11:01:48 +03:00
2026-04-20 11:31:01 -07:00
2026-06-08 18:56:18 -07:00
2026-06-12 14:00:51 +01:00
2026-05-22 12:28:46 +02:00
2026-05-08 01:30:16 +02:00
2026-05-08 01:30:16 +02:00
2026-05-08 01:30:16 +02:00
2026-06-16 09:01:23 +05:30
2026-06-08 10:03:43 +02:00
2026-05-20 17:17:04 +01:00
2026-06-15 14:50:18 +05:30
2026-05-19 19:05:20 -07:00
2026-06-12 14:10:22 +01:00
2026-04-24 14:20:03 -07:00
2026-04-19 08:47:40 -07:00
2026-05-01 21:36:14 +02:00
2026-04-18 00:10:50 -07:00
2026-05-06 17:08:39 +01:00
2026-05-11 15:26:12 +02:00
2026-06-04 10:16:51 +02:00
2026-05-26 11:02:02 +02:00
2026-06-16 13:02:47 +05:30
2026-05-28 09:35:38 -06:00
2026-06-16 10:07:36 -06:00
2026-05-12 09:44:31 +09:00
2026-05-17 11:15:05 -07:00
2026-06-15 03:54:54 +05:30
2026-06-04 10:28:11 +02:00
2026-05-29 05:34:25 -06:00
2026-05-18 21:33:15 +02:00
2026-04-27 15:52:51 -06:00
2026-06-06 15:08:36 -07:00
2026-05-04 08:52:26 -10:00
2026-05-22 16:28:47 -07:00
2026-06-05 14:46:51 +02:00
2026-06-15 13:51:27 +05:30
2026-05-28 06:51:30 -07:00
2026-06-15 14:21:14 +05:30
2026-06-15 14:21:14 +05:30
2026-06-15 05:01:15 +05:30
2026-05-28 12:20:19 +02:00
2026-05-20 20:23:32 +02:00
2026-05-26 11:02:01 +02:00
2026-06-08 23:28:24 +02:00
2026-05-22 18:41:24 +02:00
2026-06-04 10:55:27 +02:00
2026-04-18 00:10:51 -07:00
2026-04-21 14:12:01 -07:00
2026-06-05 00:34:55 -04:00
2026-05-14 14:10:39 +02:00
2026-05-22 13:36:52 +02:00
2026-05-18 11:16:29 +02:00
2026-04-27 10:26:49 +02:00
2026-04-26 23:43:58 +02:00
2026-04-26 23:38:57 +02:00
2026-05-28 14:05:29 +02:00
2026-05-29 08:34:12 -07:00
2026-05-19 17:26:07 +02:00
2026-05-15 17:41:05 +02:00
2026-05-11 11:11:48 +02:00
2026-05-11 11:11:48 +02:00
2026-06-09 16:00:11 +02:00
2026-05-21 15:33:47 +02:00
2026-05-11 16:50:27 +02:00
2026-06-15 03:59:45 +05:30
2026-05-11 08:27:02 -07:00
2026-05-11 19:04:46 +09:00
2026-06-15 04:07:58 +05:30
2026-06-15 02:50:44 +05:30
2026-05-15 19:24:33 +02:00
2026-06-05 13:36:22 +02:00
2026-06-03 11:38:51 +02:00
2026-06-03 11:38:52 +02:00
2026-05-22 13:33:58 +02:00
2026-05-13 17:40:02 -07:00
2026-05-04 09:59:19 +02:00
2026-04-27 15:27:41 -07:00
2026-05-12 18:03:37 +02:00
2026-05-21 16:14:33 +02:00
2026-05-13 17:40:02 -07:00
2026-05-29 13:54:43 +08:00
2026-05-06 08:33:09 +02:00
2026-05-21 19:06:11 -07:00
2026-05-28 20:50:34 -07:00
2026-06-16 08:10:21 +05:30
2026-06-15 12:41:17 +05:30
2026-04-23 12:13:57 +02:00
2026-05-14 10:44:16 +02:00
2026-05-07 16:06:28 +03:00
2026-05-26 16:21:11 +02:00
2026-06-13 06:27:20 -06:00
2026-06-05 13:36:22 +02:00
2026-04-26 23:38:35 +02:00
2026-05-08 17:00:44 +02:00
2026-05-26 16:21:13 +02:00
2026-05-26 16:21:14 +02:00
2026-04-30 15:45:32 +02:00
2026-06-02 21:27:26 +02:00
2026-06-06 15:21:40 +02:00
2026-04-18 00:10:48 -07:00
2026-04-21 16:41:54 +01:00
2026-05-21 09:32:46 +02:00
2026-05-18 12:26:51 +02:00
2026-06-05 11:44:10 +01:00
2026-05-12 14:42:29 +02:00
2026-04-18 00:10:50 -07:00
2026-04-18 13:07:36 -05:00
2026-04-27 05:54:25 -07:00
2026-04-18 11:29:14 -07:00
2026-04-18 00:10:48 -07:00
2026-06-03 18:20:47 +02:00
2026-04-18 00:10:47 -07:00
2026-06-15 14:50:18 +05:30
2026-05-28 20:50:34 -07:00
2026-04-19 08:01:17 -07:00
2026-04-27 18:46:17 -07:00
2026-05-11 16:22:15 +02:00
2026-06-15 03:59:45 +05:30
2026-04-24 09:41:58 -07:00
2026-05-12 14:42:32 +02:00
2026-05-11 16:50:29 +02:00
2026-04-22 08:53:23 -04:00
2026-06-15 04:15:31 +05:30
2026-04-24 00:34:59 +02:00
2026-04-27 15:47:21 -06:00
2026-05-21 19:06:13 -07:00
2026-05-22 12:19:02 +02:00
2026-06-11 13:41:25 +02:00
2026-06-16 08:44:43 +05:30
2026-04-18 00:10:50 -07:00
2026-06-16 05:18:04 +05:30
2026-06-10 11:08:23 +02:00
2026-06-08 23:28:24 +02:00
2026-04-20 11:35:17 -07:00
2026-06-02 11:39:58 +02:00
2026-04-20 15:42:18 -07:00
2026-05-11 23:13:01 +02:00
2026-06-10 00:58:04 +02:00
2026-06-04 11:04:18 +02:00
2026-05-26 11:02:01 +02:00
2026-04-21 12:48:44 +02:00
2026-05-24 09:40:02 +02:00
2026-05-07 16:29:14 +02:00
2026-06-15 03:05:50 +05:30
2026-04-20 20:10:50 -10:00
2026-05-30 22:25:45 +02:00
2026-06-02 12:41:15 +02:00
2026-05-06 17:40:15 +02:00
2026-05-05 16:02:57 +02:00
2026-05-19 13:49:01 +02:00
2026-06-15 14:50:18 +05:30
2026-05-28 12:23:22 +02:00
2026-04-19 08:44:41 -07:00
2026-05-22 11:51:35 +02:00
2026-06-06 15:21:41 +02:00
2026-05-28 12:26:36 +02:00
2026-06-16 08:44:43 +05:30
2026-05-01 16:24:25 -05:00
2026-05-29 14:05:30 +08:00
2026-05-11 12:25:31 +02:00
2026-05-24 09:39:41 +02:00
2026-05-12 21:48:36 -07:00
2026-04-18 00:10:47 -07:00
2026-05-28 06:51:30 -07:00
2026-06-03 09:13:00 +02:00
2026-06-02 21:27:26 +02:00
2026-05-11 16:59:43 +02:00
2026-06-02 21:41:23 +02:00
2026-06-04 11:04:18 +02:00
2026-05-19 12:17:36 +02:00
2026-05-24 09:38:47 +02:00
2026-04-21 18:54:28 +03:00
2026-06-04 05:03:56 -04:00
2026-05-11 17:03:00 +02:00
2026-06-15 14:21:14 +05:30
2026-04-18 00:10:54 -07:00
2026-06-04 18:22:45 +02:00
2026-05-13 14:49:06 -06:00
2026-05-20 20:23:32 +02:00
2026-06-02 21:27:25 +02:00
2026-06-08 11:53:18 -07:00
2026-04-20 12:02:24 -07:00
2026-04-28 06:13:40 -10:00
2026-06-06 15:22:44 +02:00