blk-mq: introduce tag starvation observability
Subsystems (2)
v5 cover blk-mq: introduce tag starvation observability
Hi Jens, Steve, Masami,
In high-performance storage environments, particularly when utilising RAID controllers with shared tag sets (BLK_MQ_F_TAG_HCTX_SHARED), severe latency spikes can occur when fast devices are starved of available tags. Currently, diagnosing this specific queue contention requires deploying dynamic kprobes or inferring sleep states, which lacks a simple, out-of-the-box diagnostic path.
This short series introduces dedicated, low-overhead observability for tag exhaustion events in the block layer:
- Patch 1 introduces the "block_rq_tag_wait" tracepoint in the tag allocation slow-path to capture precise, event-based starvation.
- Patch 2 complements this by exposing "wait_on_hw_tag" and "wait_on_sched_tag" per-CPU counters via debugfs for quick, point-in-time cumulative polling.
Together, these provide storage engineers with zero-configuration mechanisms to definitively identify shared-tag bottlenecks.
Please let me know your thoughts.
Changes since v4 [1]:
- Prevented a NULL pointer dereference in the tracepoint fast-assign for disk-less request queues by safely checking q->disk before resolving the dev_t
- Fixed a Use-After-Free (UAF) and permanent memory leak by decoupling the per-CPU counter allocation from the volatile debugfs lifecycle and tying it directly to the core hctx lifecycle (i.e., blk_mq_init_hctx() and blk_mq_exit_hctx())
- Fixed a potential compiler double-fetch bug by wrapping the per-CPU pointer evaluations with READ_ONCE() in blk_mq_debugfs_inc_wait_tags()
- Passed the appropriate gfp_t flags down to the allocation routines to maintain the strict GFP_NOIO context
- Updated kernel-doc descriptions to clarify that the NULL pointer checks guard against memory allocation failures under pressure, rather than initialisation race conditions
Changes since v3 [2]:
- Transitioned tracking architecture from shared atomic_t variables to dynamically allocated per-CPU counters to resolve cache line bouncing (Bart Van Assche)
Changes since v2 [3]:
- Added "Reviewed-by:" and "Tested-by:" tags for patch 1
- Evaluate is_sched_tag directly within TP_fast_assign (Steven Rostedt)
- Introduced atomic counters via debugfs
Changes since v1 [4]:
- Improved the description of the trace point (Damien Le Moal)
- Removed the redundant "active requests" (Laurence Oberman)
- Introduced pool-specific starvation tracking
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/
[4]: https://lore.kernel.org/lkml/[email protected]/
Aaron Tomlin (2):
blk-mq: add tracepoint block_rq_tag_wait
blk-mq: expose tag starvation counts via debugfs
block/blk-mq-debugfs.c | 109 +++++++++++++++++++++++++++++++++++ block/blk-mq-debugfs.h | 19 ++++++ block/blk-mq-tag.c | 8 +++ block/blk-mq.c | 5 ++ include/linux/blk-mq.h | 12 ++++ include/trace/events/block.h | 43 ++++++++++++++ 6 files changed, 196 insertions(+)
Signature · 1 line
2.51.0
PATCH v5 1/2 blk-mq: add tracepoint block_rq_tag_wait
In high-performance storage environments, particularly when utilising RAID controllers with shared tag sets (BLK_MQ_F_TAG_HCTX_SHARED), severe latency spikes can occur when fast devices (SSDs) are starved of hardware tags when sharing the same blk_mq_tag_set.
Currently, diagnosing this specific hardware queue contention is difficult. When a CPU thread exhausts the tag pool, blk_mq_get_tag() forces the current thread to block uninterruptible via io_schedule(). While this can be inferred via sched:sched_switch or dynamically traced by attaching a kprobe to blk_mq_mark_tag_wait(), there is no dedicated, out-of-the-box observability for this event.
This patch introduces the block_rq_tag_wait trace point in the tag allocation slow-path. It triggers immediately before the thread yields the CPU, exposing the exact hardware context (hctx) that is starved, the specific pool experiencing starvation (hardware or software scheduler), and the total pool depth.
This provides storage engineers and performance monitoring agents with a zero-configuration, low-overhead mechanism to definitively identify shared-tag bottlenecks and tune I/O schedulers or cgroup throttling accordingly.
--- block/blk-mq-tag.c | 4 ++++ include/trace/events/block.h | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
block/blk-mq-tag.c +4 -0
@@ -13,6 +13,7 @@#include <linux/kmemleak.h> #include <linux/delay.h> +#include <trace/events/block.h> #include "blk.h" #include "blk-mq.h" #include "blk-mq-sched.h"
@@ -187,6 +188,9 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)if (tag !=BLK_MQ_NO_TAG )break ; +trace_block_rq_tag_wait (data->q, data->hctx, + data->rq_flags &RQF_SCHED_TAGS ); + bt_prev = bt;io_schedule ();
include/trace/events/block.h +43 -0
49 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 2/2 blk-mq: expose tag starvation counts via debugfs
In reply to Aaron TomlinIn high-performance storage environments, particularly when utilising RAID controllers with shared tag sets (BLK_MQ_F_TAG_HCTX_SHARED), severe latency spikes can occur when fast devices are starved of available tags.
This patch introduces two new debugfs attributes for each block hardware queue:
- /sys/kernel/debug/block/[device]/hctxN/wait_on_hw_tag
- /sys/kernel/debug/block/[device]/hctxN/wait_on_sched_tag
These files expose atomic counters that increment each time a submitting context is forced into an uninterruptible sleep via io_schedule() due to the complete exhaustion of physical driver tags or software scheduler tags, respectively.
To ensure negligible performance overhead even in production environments where CONFIG_BLK_DEBUG_FS is actively enabled, this tracking logic utilises dynamically allocated per-CPU counters. When this configuration is disabled, the tracking logic compiles down to a safe no-op.
--- block/blk-mq-debugfs.c | 109 +++++++++++++++++++++++++++++++++++++++++ block/blk-mq-debugfs.h | 19 +++++++ block/blk-mq-tag.c | 4 ++ block/blk-mq.c | 5 ++ include/linux/blk-mq.h | 12 +++++ 5 files changed, 149 insertions(+)
block/blk-mq-debugfs.c +109 -0
@@ -7,6 +7,7 @@#include <linux/blkdev.h> #include <linux/build_bug.h> #include <linux/debugfs.h> +#include <linux/percpu.h> #include "blk.h" #include "blk-mq.h"
@@ -484,6 +485,54 @@ static int hctx_dispatch_busy_show(void *data, struct seq_file *m)return 0 ; } +/** +* hctx_wait_on_hw_tag_show - display hardware tag starvation count +* @data: generic pointer to the associated hardware context (hctx) +* @m: seq_file pointer for debugfs output formatting +* +* Prints the cumulative number of times a submitting context was forced +* to block due to the exhaustion of physical hardware driver tags. +* +* Return: 0 on success. +*/ +static int hctx_wait_on_hw_tag_show (void *data,struct seq_file *m) +{ +struct blk_mq_hw_ctx *hctx = data; +unsigned long count =0 ; +int cpu; + +if (hctx->wait_on_hw_tag) { +for_each_possible_cpu (cpu) + count += *per_cpu_ptr (hctx->wait_on_hw_tag, cpu); + } +seq_printf (m,"%lu\n" , count); +return 0 ; +} + +/** +* hctx_wait_on_sched_tag_show - display scheduler tag starvation count +* @data: generic pointer to the associated hardware context (hctx) +* @m: seq_file pointer for debugfs output formatting +* +* Prints the cumulative number of times a submitting context was forced +* to block due to the exhaustion of software scheduler tags. +* +* Return: 0 on success. +*/ +static int hctx_wait_on_sched_tag_show (void *data,struct seq_file *m) +{ +struct blk_mq_hw_ctx *hctx = data; +unsigned long count =0 ; +int cpu; + +if (hctx->wait_on_sched_tag) { +for_each_possible_cpu (cpu) + count += *per_cpu_ptr (hctx->wait_on_sched_tag, cpu); + } +seq_printf (m,"%lu\n" , count); +return 0 ; +} +#define CTX_RQ_SEQ_OPS (name, type) \ static void *ctx_##name##_rq_list_start(struct seq_file *m, loff_t *pos) \ __acquires(&ctx->lock) \
@@ -599,6 +648,8 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { {"active", 0400, hctx_active_show}, {"dispatch_busy", 0400, hctx_dispatch_busy_show}, {"type", 0400, hctx_type_show}, + {"wait_on_hw_tag", 0400, hctx_wait_on_hw_tag_show}, + {"wait_on_sched_tag", 0400, hctx_wait_on_sched_tag_show}, {}, };
@@ -815,3 +866,61 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)debugfs_remove_recursive (hctx->sched_debugfs_dir); hctx->sched_debugfs_dir =NULL ; } + +/** +* blk_mq_debugfs_alloc_hctx_stats - Allocate per-cpu starvation statistics +* @hctx: hardware context associated with the tag allocation +* @gfp: memory allocation flags +* +* Allocates the per-cpu memory for tracking hardware and scheduler tag +* starvation. +*/ +void blk_mq_debugfs_alloc_hctx_stats (struct blk_mq_hw_ctx *hctx,gfp_t gfp) +{ +if (!hctx->wait_on_hw_tag) + hctx->wait_on_hw_tag = alloc_percpu_gfp(unsigned long, + gfp); +if (!hctx->wait_on_sched_tag) + hctx->wait_on_sched_tag = alloc_percpu_gfp(unsigned long, + gfp); +} + +/** +* blk_mq_debugfs_free_hctx_stats - Free per-cpu starvation statistics +* @hctx: hardware context associated with the tag allocation +* +* Frees the per-cpu memory used for tracking hardware and scheduler tag +* starvation. This must only be called during hardware queue teardown when +* the queue is safely frozen and no active I/O submissions can race to +* increment the statistics. +*/ +void blk_mq_debugfs_free_hctx_stats (struct blk_mq_hw_ctx *hctx) +{ +free_percpu (hctx->wait_on_hw_tag); + hctx->wait_on_hw_tag =NULL ; +free_percpu (hctx->wait_on_sched_tag); + hctx->wait_on_sched_tag =NULL ; +} + +/** +* blk_mq_debugfs_inc_wait_tags - increment the tag starvation counters +* @hctx: hardware context associated with the tag allocation +* @is_sched: true if the starved pool is the software scheduler +* +* Evaluates the exhausted tag pool and safely increments the appropriate +* per-cpu debugfs starvation counter. +* +* Note: The per-cpu pointers are explicitly checked to prevent a NULL +* pointer dereference in the event that the system was under heavy memory +* pressure and the initial per-cpu allocation failed. +*/ +void blk_mq_debugfs_inc_wait_tags (struct blk_mq_hw_ctx *hctx, +bool is_sched) +{ +unsigned long __percpu *tags = is_sched ? +READ_ONCE (hctx->wait_on_sched_tag) : +READ_ONCE (hctx->wait_on_hw_tag); + +if (likely (tags)) +this_cpu_inc (*tags); +}
block/blk-mq-debugfs.h +19 -0
@@ -17,6 +17,8 @@ struct blk_mq_debugfs_attr {const struct seq_operations *seq_ops; }; +void blk_mq_debugfs_inc_wait_tags (struct blk_mq_hw_ctx *hctx, +bool is_sched);int __blk_mq_debugfs_rq_show (struct seq_file *m,struct request *rq);int blk_mq_debugfs_rq_show (struct seq_file *m,void *v);
@@ -26,6 +28,9 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q,void blk_mq_debugfs_unregister_hctx (struct blk_mq_hw_ctx *hctx);void blk_mq_debugfs_register_hctxs (struct request_queue *q);void blk_mq_debugfs_unregister_hctxs (struct request_queue *q); +void blk_mq_debugfs_alloc_hctx_stats (struct blk_mq_hw_ctx *hctx, +gfp_t gfp); +void blk_mq_debugfs_free_hctx_stats (struct blk_mq_hw_ctx *hctx);void blk_mq_debugfs_register_sched (struct request_queue *q);void blk_mq_debugfs_unregister_sched (struct request_queue *q);
@@ -35,6 +40,11 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);void blk_mq_debugfs_register_rq_qos (struct request_queue *q);#else +static inline void blk_mq_debugfs_inc_wait_tags (struct blk_mq_hw_ctx *hctx, +bool is_sched) +{ +} +static inline void blk_mq_debugfs_register (struct request_queue *q) { }
@@ -56,6 +66,15 @@ static inline void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) { } +static inline void blk_mq_debugfs_alloc_hctx_stats (struct blk_mq_hw_ctx *hctx, +gfp_t gfp) +{ +} + +static inline void blk_mq_debugfs_free_hctx_stats (struct blk_mq_hw_ctx *hctx) +{ +} +static inline void blk_mq_debugfs_register_sched (struct request_queue *q) { }
block/blk-mq-tag.c +4 -0
@@ -17,6 +17,7 @@#include "blk.h" #include "blk-mq.h" #include "blk-mq-sched.h" +#include "blk-mq-debugfs.h" /* * Recalculate wakeup batch when tag is shared by hctx.
@@ -191,6 +192,9 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)trace_block_rq_tag_wait (data->q, data->hctx, data->rq_flags &RQF_SCHED_TAGS ); +blk_mq_debugfs_inc_wait_tags (data->hctx, + data->rq_flags &RQF_SCHED_TAGS ); + bt_prev = bt;io_schedule ();
block/blk-mq.c +5 -0
@@ -3991,6 +3991,8 @@ static void blk_mq_exit_hctx(struct request_queue *q, blk_free_flush_queue_callback); hctx->fq =NULL ; +blk_mq_debugfs_free_hctx_stats (hctx); +spin_lock (&q->unused_hctx_lock);list_add (&hctx->hctx_list, &q->unused_hctx_list);spin_unlock (&q->unused_hctx_lock);
@@ -4016,6 +4018,8 @@ static int blk_mq_init_hctx(struct request_queue *q, {gfp_t gfp =GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY; +blk_mq_debugfs_alloc_hctx_stats (hctx, gfp); + hctx->fq =blk_alloc_flush_queue (hctx->numa_node, set->cmd_size, gfp);if (!hctx->fq) goto fail;
@@ -4041,6 +4045,7 @@ static int blk_mq_init_hctx(struct request_queue *q,blk_free_flush_queue (hctx->fq); hctx->fq =NULL ; fail: +blk_mq_debugfs_free_hctx_stats (hctx);return -1 ; }
include/linux/blk-mq.h +12 -0
@@ -453,6 +453,18 @@ struct blk_mq_hw_ctx {struct dentry *debugfs_dir;/** @sched_debugfs_dir: debugfs directory for the scheduler. */ struct dentry *sched_debugfs_dir; +/** +* @wait_on_hw_tag: Cumulative per-cpu counter incremented each +* time a submitting context is forced to block due to physical +* hardware tag exhaustion. +*/ +unsigned long __percpu *wait_on_hw_tag; +/** +* @wait_on_sched_tag: Cumulative per-cpu counter incremented each +* time a submitting context is forced to block due to software +* scheduler tag exhaustion. +*/ +unsigned long __percpu *wait_on_sched_tag;#endif /**
Signature · 1 line
2.51.0
Steven Rostedt
maintainerRe: [PATCH v5 1/2] blk-mq: add tracepoint block_rq_tag_wait
In reply to Aaron TomlinQuoted 5 lines · On Sun, 26 Apr 2026 22:01:41 -0400 Aaron Tomlin <[email protected]> wrote:
include/trace/events/block.h +5
-0+TRACE_EVENT(block_rq_tag_wait, + + TP_PROTO(struct request_queue *q, struct blk_mq_hw_ctx *hctx, bool is_sched_tag), + + TP_ARGS(q, hctx, is_sched_tag),
include/trace/events/block.h DECLARE_EVENT_CLASS(block_rq, · line 255
Quoted 10 lines
include/trace/events/block.h +10
-0+ +TP_STRUCT__entry ( +__field (dev_t ,dev ) +__field ( u32, hctx_id ) +__field ( u32, nr_tags ) +__field ( bool, is_sched_tag ) + ), + +TP_fast_assign ( + __entry->dev = q->disk ? disk_devt(q->disk);
Hmm, does the above even compile?
-- Steve
Quoted 16 lines
include/trace/events/block.h +16
-0+ __entry->hctx_id = hctx->queue_num; + __entry->is_sched_tag = is_sched_tag; + +if (is_sched_tag) + __entry->nr_tags = hctx->sched_tags->nr_tags; +else + __entry->nr_tags = hctx->tags->nr_tags; + ), + +TP_printk ("%d,%d hctx=%u starved on %s tags (depth=%u)" , +MAJOR (__entry->dev),MINOR (__entry->dev), + __entry->hctx_id, + __entry->is_sched_tag ?"scheduler" :"hardware" , + __entry->nr_tags) +); +
Re: [PATCH v5 1/2] blk-mq: add tracepoint block_rq_tag_wait
Quoted 12 lines · Steven Rostedt
Quoted 9 lines · On Sun, 26 Apr 2026 22:01:41 -0400 Aaron Tomlin <[email protected]> wrote:
include/trace/events/block.h +9
-0+TRACE_EVENT(block_rq_tag_wait, + + TP_PROTO(struct request_queue *q, struct blk_mq_hw_ctx *hctx, bool is_sched_tag), + + TP_ARGS(q, hctx, is_sched_tag), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( u32, hctx_id )
Quoted 9 lines
include/trace/events/block.h DECLARE_EVENT_CLASS(block_rq, · line 255
Quoted 6 lines
include/trace/events/block.h +6
-0+ __field( u32, nr_tags ) + __field( bool, is_sched_tag ) + ), + + TP_fast_assign( + __entry->dev = q->disk ? disk_devt(q->disk);Hmm, does the above even compile?
Hi Steve,
TP_fast_assign( __entry->dev = q->disk ? disk_devt(q->disk) : 0;
I embarrassingly dropped ": 0" from the ternary operator while preparing the v5 patch and failed to catch the syntax error before sending it out.
I will fix the syntax, verify the build and spin a v6.
Kind regards,
Signature · 1 line
Aaron Tomlin
kernel test robot
build botRe: [PATCH v5 2/2] blk-mq: expose tag starvation counts via debugfs
In reply to Aaron Tomlinkernel test robot noticed the following build errors:
Hi Aaron,
kernel test robot noticed the following build errors:
[auto build test ERROR on axboe/for-next]
[also build test ERROR on trace/for-next riteshharjani/for-next linus/master v7.1-rc1 next-20260430] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Aaron-Tomlin/blk-mq-add-tracepoint-block_rq_tag_wait/20260428-013259 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git for-next patch link: https://lore.kernel.org/r/20260427020142.358912-3-atomlin%40atomlin.com patch subject: [PATCH v5 2/2] blk-mq: expose tag starvation counts via debugfs config: i386-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260501/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260501/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from ./include/trace/define_trace.h:132,
from ./include/trace/events/block.h:726,
from block/blk-core.c:45:
./include/trace/events/block.h: In function 'do_trace_event_raw_event_block_rq_tag_wait':
>> ./include/trace/events/block.h:255:71: error: expected ':' before ';' token
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
./include/trace/trace_events.h:427:11: note: in definition of macro '__DECLARE_EVENT_CLASS'
427 | { assign; } \
| ^~~~~~
./include/trace/trace_events.h:435:23: note: in expansion of macro 'PARAMS'
435 | PARAMS(assign), PARAMS(print)) \
| ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
40 | DECLARE_EVENT_CLASS(name, \
| ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro 'PARAMS'
44 | PARAMS(assign), \
| ^~~~~~
./include/trace/events/block.h:241:1: note: in expansion of macro 'TRACE_EVENT'
241 | TRACE_EVENT(block_rq_tag_wait,
| ^~~~~~~~~~~
./include/trace/events/block.h:254:9: note: in expansion of macro 'TP_fast_assign'
254 | TP_fast_assign(
| ^~~~~~~~~~~~~~
In file included from ./include/trace/define_trace.h:133:
./include/trace/events/block.h: In function 'do_perf_trace_block_rq_tag_wait':
>> ./include/trace/events/block.h:255:71: error: expected ':' before ';' token
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
./include/trace/perf.h:51:11: note: in definition of macro '__DECLARE_EVENT_CLASS'
51 | { assign; } \
| ^~~~~~
./include/trace/perf.h:67:23: note: in expansion of macro 'PARAMS'
67 | PARAMS(assign), PARAMS(print)) \
| ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
40 | DECLARE_EVENT_CLASS(name, \
| ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro 'PARAMS'
44 | PARAMS(assign), \
| ^~~~~~
./include/trace/events/block.h:241:1: note: in expansion of macro 'TRACE_EVENT'
241 | TRACE_EVENT(block_rq_tag_wait,
| ^~~~~~~~~~~
./include/trace/events/block.h:254:9: note: in expansion of macro 'TP_fast_assign'
254 | TP_fast_assign(
| ^~~~~~~~~~~~~~vim +255 ./include/trace/events/block.h
242
243 TP_PROTO(struct request_queue *q, struct blk_mq_hw_ctx *hctx, bool is_sched_tag),
244
245 TP_ARGS(q, hctx, is_sched_tag),
246
247 TP_STRUCT__entry(
248 __field( dev_t, dev )
249 __field( u32, hctx_id )
250 __field( u32, nr_tags )
251 __field( bool, is_sched_tag )
252 ),
253
254 TP_fast_assign(
> 255 __entry->dev = q->disk ? disk_devt(q->disk);
256 __entry->hctx_id = hctx->queue_num;
257 __entry->is_sched_tag = is_sched_tag;
258
259 if (is_sched_tag)
260 __entry->nr_tags = hctx->sched_tags->nr_tags;
261 else
262 __entry->nr_tags = hctx->tags->nr_tags;
263 ),
264
265 TP_printk("%d,%d hctx=%u starved on %s tags (depth=%u)",
266 MAJOR(__entry->dev), MINOR(__entry->dev),
267 __entry->hctx_id,
268 __entry->is_sched_tag ? "scheduler" : "hardware",
269 __entry->nr_tags) 270 );
271
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v5 2/2] blk-mq: expose tag starvation counts via debugfs
In reply to Aaron Tomlinkernel test robot noticed the following build errors:
Hi Aaron,
kernel test robot noticed the following build errors:
[auto build test ERROR on axboe/for-next]
[also build test ERROR on trace/for-next linus/master v7.1-rc2 next-20260508] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Aaron-Tomlin/blk-mq-add-tracepoint-block_rq_tag_wait/20260428-013259 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git for-next patch link: https://lore.kernel.org/r/20260427020142.358912-3-atomlin%40atomlin.com patch subject: [PATCH v5 2/2] blk-mq: expose tag starvation counts via debugfs config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20260509/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) rustc: rustc 1.88.0 (6b00bc388 2025-06-23) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260509/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from block/blk-core.c:45:
In file included from include/trace/events/block.h:726:
In file included from include/trace/define_trace.h:132:
In file included from include/trace/trace_events.h:468:
>> include/trace/events/block.h:255:47: error: expected ':'
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
| :
include/trace/stages/stage6_event_callback.h:133:33: note: expanded from macro 'TP_fast_assign'
133 | #define TP_fast_assign(args...) args
| ^
include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
44 | PARAMS(assign), \
| ^
include/linux/tracepoint.h:160:25: note: expanded from macro 'PARAMS'
160 | #define PARAMS(args...) args
| ^
include/trace/trace_events.h:435:16: note: expanded from macro 'DECLARE_EVENT_CLASS'
435 | PARAMS(assign), PARAMS(print)) \
| ^
include/linux/tracepoint.h:160:25: note: expanded from macro 'PARAMS'
160 | #define PARAMS(args...) args
| ^
include/trace/trace_events.h:427:4: note: expanded from macro '\
__DECLARE_EVENT_CLASS'
427 | { assign; } \
| ^
include/trace/events/block.h:255:27: note: to match this '?'
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
>> include/trace/events/block.h:255:47: error: expected expression
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
In file included from block/blk-core.c:45:
In file included from include/trace/events/block.h:726:
In file included from include/trace/define_trace.h:133:
In file included from include/trace/perf.h:110:
>> include/trace/events/block.h:255:47: error: expected ':'
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
| :
include/trace/stages/stage6_event_callback.h:133:33: note: expanded from macro 'TP_fast_assign'
133 | #define TP_fast_assign(args...) args
| ^
include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
44 | PARAMS(assign), \
| ^
include/linux/tracepoint.h:160:25: note: expanded from macro 'PARAMS'
160 | #define PARAMS(args...) args
| ^
include/trace/perf.h:67:16: note: expanded from macro 'DECLARE_EVENT_CLASS'
67 | PARAMS(assign), PARAMS(print)) \
| ^
include/linux/tracepoint.h:160:25: note: expanded from macro 'PARAMS'
160 | #define PARAMS(args...) args
| ^
include/trace/perf.h:51:4: note: expanded from macro '\
__DECLARE_EVENT_CLASS'
51 | { assign; } \
| ^
include/trace/events/block.h:255:27: note: to match this '?'
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^
>> include/trace/events/block.h:255:47: error: expected expression
255 | __entry->dev = q->disk ? disk_devt(q->disk);
| ^4 errors generated.
vim +255 include/trace/events/block.h
242
243 TP_PROTO(struct request_queue *q, struct blk_mq_hw_ctx *hctx, bool is_sched_tag),
244
245 TP_ARGS(q, hctx, is_sched_tag),
246
247 TP_STRUCT__entry(
248 __field( dev_t, dev )
249 __field( u32, hctx_id )
250 __field( u32, nr_tags )
251 __field( bool, is_sched_tag )
252 ),
253
254 TP_fast_assign(
> 255 __entry->dev = q->disk ? disk_devt(q->disk);
256 __entry->hctx_id = hctx->queue_num;
257 __entry->is_sched_tag = is_sched_tag;
258
259 if (is_sched_tag)
260 __entry->nr_tags = hctx->sched_tags->nr_tags;
261 else
262 __entry->nr_tags = hctx->tags->nr_tags;
263 ),
264
265 TP_printk("%d,%d hctx=%u starved on %s tags (depth=%u)",
266 MAJOR(__entry->dev), MINOR(__entry->dev),
267 __entry->hctx_id,
268 __entry->is_sched_tag ? "scheduler" : "hardware",
269 __entry->nr_tags) 270 );
271
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v5 2/2] blk-mq: expose tag starvation counts via debugfs
In reply to Aaron TomlinQuoted 12 lines · Aaron Tomlin
block/blk-mq-debugfs.c +12
-0+/** +* blk_mq_debugfs_inc_wait_tags - increment the tag starvation counters +* @hctx: hardware context associated with the tag allocation +* @is_sched: true if the starved pool is the software scheduler +* +* Evaluates the exhausted tag pool and safely increments the appropriate +* per-cpu debugfs starvation counter. +* +* Note: The per-cpu pointers are explicitly checked to prevent a NULL +* pointer dereference in the event that the system was under heavy memory +* pressure and the initial per-cpu allocation failed. +*/
block/blk-mq-debugfs.c void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) · line 926
Quoted 10 lines
block/blk-mq-debugfs.c +10
-0+void blk_mq_debugfs_inc_wait_tags (struct blk_mq_hw_ctx *hctx, +bool is_sched) +{ +unsigned long __percpu *tags = is_sched ? +READ_ONCE (hctx->wait_on_sched_tag) : +READ_ONCE (hctx->wait_on_hw_tag); + +if (likely (tags)) +this_cpu_inc (*tags); +}
Hi Jens,
I have realised that this particular code path, invoked from blk_mq_get_tag() immediately prior to io_schedule(), is in fact, a preemptible context. Consequently, utilising this_cpu_inc() here will invariably trigger a warning when operating under a kernel with CONFIG_DEBUG_PREEMPT=y enabled.
To rectify this, I intend to transition to the use of raw_cpu_inc(). Given that this is solely for a debugfs interface, I believe it is far more prudent to prioritise the mitigation of execution overhead over absolute statistical precision, should a preemption race occur.
Kind regards,
Signature · 1 line
Aaron Tomlin