linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] blk-mq: use array manage hctx map instead of xarray
@ 2025-11-28  8:53 Fengnan Chang
  2025-11-28  8:53 ` [PATCH v3 1/2] " Fengnan Chang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Fengnan Chang @ 2025-11-28  8:53 UTC (permalink / raw)
  To: axboe, linux-block, ming.lei, hare, hch, yukuai; +Cc: Fengnan Chang

After commit 4e5cc99e1e48 ("blk-mq: manage hctx map via xarray"), we use
an xarray instead of array to store hctx, but in poll mode, each time
in blk_mq_poll, we need use xa_load to find corresponding hctx, this
introduce some costs. In my test, xa_load may cost 3.8% cpu.

After revert previous change, eliminates the overhead of xa_load and can
result in a 3% performance improvement.

potentital use-after-free on q->queue_hw_ctx can be fixed by use rcu to
avoid, same as Yu Kuai did in [1].

[1] https://lore.kernel.org/all/20220225072053.2472431-1-yukuai3@huawei.com/

v3:
fix build error and part sparse warnings, not all sparse warnings, because
the queue is freezed in __blk_mq_update_nr_hw_queues, only need protect
'queue_hw_ctx' through rcu where it can be accessed without grabbing
'q_usage_counter'.

v2:
1. modify synchronize_rcu() to synchronize_rcu_expedited()
2. use rcu_dereference(q->queue_hw_ctx)[id] in queue_hctx to better read.

Fengnan Chang (2):
  blk-mq: use array manage hctx map instead of xarray
  blk-mq: fix potential uaf for 'queue_hw_ctx'

 block/blk-mq-tag.c     |  2 +-
 block/blk-mq.c         | 63 ++++++++++++++++++++++++++++--------------
 block/blk-mq.h         |  2 +-
 include/linux/blk-mq.h | 14 +++++++++-
 include/linux/blkdev.h |  2 +-
 5 files changed, 58 insertions(+), 25 deletions(-)


base-commit: 4941a17751c99e17422be743c02c923ad706f888
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-12-01 12:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28  8:53 [PATCH v3 0/2] blk-mq: use array manage hctx map instead of xarray Fengnan Chang
2025-11-28  8:53 ` [PATCH v3 1/2] " Fengnan Chang
2025-11-28  8:53 ` [PATCH v3 2/2] blk-mq: fix potential uaf for 'queue_hw_ctx' Fengnan Chang
2025-11-28 16:20   ` Jens Axboe
2025-12-01 12:26     ` fengnan chang
2025-11-28  9:54 ` [PATCH v3 0/2] blk-mq: use array manage hctx map instead of xarray Yu Kuai
2025-11-28 10:00   ` fengnan chang
2025-11-28 16:09     ` Jens Axboe
2025-11-28 16:22 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).