Skip to content

blk-mq-sched: support request batch dispatching for sq elevator#72

Closed
blktests-ci[bot] wants to merge 6 commits intofor-next_basefrom
series/984570=>for-next
Closed

blk-mq-sched: support request batch dispatching for sq elevator#72
blktests-ci[bot] wants to merge 6 commits intofor-next_basefrom
series/984570=>for-next

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Jul 31, 2025

Pull request for series with
subject: blk-mq-sched: support request batch dispatching for sq elevator
version: 2
url: https://patchwork.kernel.org/project/linux-block/list/?series=986960

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 4643847
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 4643847
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from f20ed73 to 0df9b3d Compare July 31, 2025 06:25
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 4643847
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from 0df9b3d to 29fc3ae Compare July 31, 2025 06:33
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 43213b2
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from 29fc3ae to a4a57b7 Compare July 31, 2025 17:00
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 301d58c
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from a4a57b7 to 3fccb24 Compare July 31, 2025 21:54
@blktests-ci blktests-ci Bot force-pushed the for-next_base branch 2 times, most recently from 7bf6dad to 0fb21b4 Compare August 1, 2025 12:14
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 1, 2025

Upstream branch: 301d58c
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from 3fccb24 to fbe38e8 Compare August 1, 2025 12:19
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 1, 2025

Upstream branch: 301d58c
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from fbe38e8 to 3049058 Compare August 1, 2025 12:43
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 3, 2025

Upstream branch: f1815af
series: https://patchwork.kernel.org/project/linux-block/list/?series=986960
version: 2

Currently, both mq-deadline and bfq have global spin lock that will be
grabbed inside elevator methods like dispatch_request, insert_requests,
and bio_merge. And the global lock is the main reason mq-deadline and
bfq can't scale very well.

While dispatching request, blk_mq_get_disatpch_budget() and
blk_mq_get_driver_tag() must be called, and they are not ready to be called
inside elevator methods, hence introduce a new method like
dispatch_requests is not possible.

Hence introduce a new high level elevator lock, currently it is protecting
dispatch_request only. Following patches will convert mq-deadline and bfq
to use this lock and finally support request batch dispatching by calling
the method multiple time while holding the lock.

Signed-off-by: Yu Kuai <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Replace the internal spinlock 'dd->lock' with the new spinlock in
elevator_queue, there are no functional changes.

Signed-off-by: Yu Kuai <[email protected]>
Replace the internal spinlock bfqd->lock with the new spinlock in
elevator_queue. There are no functional changes.

Signed-off-by: Yu Kuai <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected].
Introduce struct sched_dispatch_ctx, and split the helper into
elevator_dispatch_one_request() and elevator_finish_dispatch(). Also
and comments about the non-error return value.

Make code cleaner, and make it easier to add a new branch to dispatch
a batch of requests at a time in the next patch.

Signed-off-by: Yu Kuai <[email protected]>
For dispatch_request method, current behavior is dispatching one request at
a time. In the case of multiple dispatching contexts, This behavior, on the
one hand, introduce intense lock contention:

t1:                     t2:                     t3:
lock                    lock                    lock
// grab lock
ops.dispatch_request
unlock
                        // grab lock
                        ops.dispatch_request
                        unlock
                                                // grab lock
                                                ops.dispatch_request
                                                unlock

on the other hand, messing up the requests dispatching order:
t1:

lock
rq1 = ops.dispatch_request
unlock
                        t2:
                        lock
                        rq2 = ops.dispatch_request
                        unlock

lock
rq3 = ops.dispatch_request
unlock

                        lock
                        rq4 = ops.dispatch_request
                        unlock

//rq1,rq3 issue to disk
                        // rq2, rq4 issue to disk

In this case, the elevator dispatch order is rq 1-2-3-4, however,
such order in disk is rq 1-3-2-4, the order for rq2 and rq3 is inversed.

Fix those problems by introducing elevator_dispatch_requests(), this
helper will grab the lock and dispatch a batch of requests while holding
the lock.

Signed-off-by: Yu Kuai <[email protected]>
@blktests-ci blktests-ci Bot force-pushed the series/984570=>for-next branch from 3049058 to 4162756 Compare August 3, 2025 12:55
@blktests-ci blktests-ci Bot closed this Aug 8, 2025
@blktests-ci blktests-ci Bot deleted the series/984570=>for-next branch August 20, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants