Skip to content

blk-mq: dispatch kworker to housekeeping CPU when hctx cpumask is empty - #1425

Open
ghost wants to merge 1 commit into
linus-master_basefrom
series/1183539=>linus-master
Open

ghost wants to merge 1 commit into
linus-master_basefrom
series/1183539=>linus-master

Conversation

@ghost

@ghost ghost commented Oct 12, 2026

Copy link
Copy Markdown

Pull request for series with
subject: blk-mq: dispatch kworker to housekeeping CPU when hctx cpumask is empty
version: 1
url: https://patchwork.kernel.org/series/1183539/

@ghost

ghost commented Oct 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: d5b6dc3
series: https://patchwork.kernel.org/series/1183539/
version: 1

@ghost
ghost force-pushed the linus-master_base branch from ec9266e to 2e69118 Compare October 12, 2026 12:20
@ghost

ghost commented Oct 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 24a19b9
series: https://patchwork.kernel.org/series/1183539/
version: 1

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 839b854 to a531f0b Compare October 12, 2026 12:28
@ghost ghost added the V1-ci-pass label Oct 14, 2026
@ghost
ghost force-pushed the linus-master_base branch from 2e69118 to 3cdd51f Compare October 14, 2026 11:11
@ghost

ghost commented Oct 14, 2026

Copy link
Copy Markdown
Author

Upstream branch: 4056b3c
series: https://patchwork.kernel.org/series/1183539/
version: 1

@ghost
ghost force-pushed the series/1183539=>linus-master branch from a531f0b to ba19063 Compare October 14, 2026 11:19
@ghost
ghost force-pushed the linus-master_base branch from 3cdd51f to e6ca2c1 Compare October 14, 2026 15:40
@ghost

ghost commented Oct 14, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0fcb05b
series: https://patchwork.kernel.org/series/1183539/
version: 1

@ghost
ghost force-pushed the series/1183539=>linus-master branch from ba19063 to 704e057 Compare October 14, 2026 15:48
@ghost

ghost commented Oct 15, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0fcb05b
series: https://patchwork.kernel.org/series/1186037/
version: 2

@ghost ghost added V2 and removed V1 V1-ci-pass labels Oct 15, 2026
@ghost
ghost force-pushed the series/1183539=>linus-master branch from 704e057 to 993bfc6 Compare October 15, 2026 02:10
@ghost

ghost commented Oct 16, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0fcb05b
series: https://patchwork.kernel.org/series/1186966/
version: 3

@ghost ghost added V3 and removed V2 labels Oct 16, 2026
@ghost
ghost force-pushed the series/1183539=>linus-master branch from 993bfc6 to a99383f Compare October 16, 2026 05:49
@ghost ghost added the V3-ci-pass label Oct 16, 2026
@ghost
ghost force-pushed the linus-master_base branch from e6ca2c1 to 3d027d5 Compare October 17, 2026 03:32
@ghost

ghost commented Oct 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 58161ea
series: https://patchwork.kernel.org/series/1186966/
version: 3

@ghost
ghost force-pushed the series/1183539=>linus-master branch from a99383f to 0c5f86d Compare October 17, 2026 03:38
@ghost
ghost force-pushed the linus-master_base branch from 3d027d5 to 90ea7e4 Compare October 19, 2026 00:00
@ghost

ghost commented Oct 19, 2026

Copy link
Copy Markdown
Author

Upstream branch: c03c1a1
series: https://patchwork.kernel.org/series/1186966/
version: 3

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 0c5f86d to 72a6bb5 Compare October 19, 2026 00:05
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6b4b543
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from cfe5a60 to 544dc89 Compare October 26, 2026 07:17
@ghost
ghost force-pushed the linus-master_base branch from 5d84576 to 6582ed2 Compare October 26, 2026 18:11
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: fb2c3f4
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 544dc89 to 139f513 Compare October 26, 2026 18:21
@ghost
ghost force-pushed the linus-master_base branch from 6582ed2 to b3a1abc Compare October 26, 2026 23:55
@ghost

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

Upstream branch: d135ab4
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 139f513 to e000163 Compare October 27, 2026 00:06
@ghost
ghost force-pushed the linus-master_base branch from b3a1abc to 712496f Compare October 28, 2026 23:34
@ghost

ghost commented Oct 28, 2026

Copy link
Copy Markdown
Author

Upstream branch: c339f40
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from e000163 to 6bf98c3 Compare October 28, 2026 23:44
@ghost
ghost force-pushed the linus-master_base branch from 712496f to a186880 Compare October 30, 2026 13:52
@ghost

ghost commented Oct 30, 2026

Copy link
Copy Markdown
Author

Upstream branch: d89e1d1
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 6bf98c3 to db4d016 Compare October 30, 2026 14:52
@ghost
ghost force-pushed the linus-master_base branch from a186880 to 46206a3 Compare November 2, 2026 17:14
@ghost

ghost commented Nov 2, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6628e7d
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from db4d016 to 28be68d Compare November 2, 2026 18:02
@ghost
ghost force-pushed the linus-master_base branch from 46206a3 to 220bd96 Compare November 3, 2026 23:41
@ghost

ghost commented Nov 4, 2026

Copy link
Copy Markdown
Author

Upstream branch: 05441d6
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 28be68d to a40c7cb Compare November 4, 2026 00:13
@ghost
ghost force-pushed the linus-master_base branch from 220bd96 to 6c4625e Compare November 6, 2026 08:02
@ghost

ghost commented Nov 6, 2026

Copy link
Copy Markdown
Author

Upstream branch: f66469d
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from a40c7cb to a0d55ba Compare November 6, 2026 08:53
@ghost
ghost force-pushed the linus-master_base branch from 6c4625e to c7f678d Compare November 7, 2026 03:08
@ghost

ghost commented Nov 7, 2026

Copy link
Copy Markdown
Author

Upstream branch: d487237
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from a0d55ba to 46f338b Compare November 7, 2026 03:50
@ghost
ghost force-pushed the linus-master_base branch from c7f678d to 6aa6cd1 Compare November 10, 2026 07:53
Commit a46c270 ("blk-mq: don't schedule block kworker on isolated
CPUs") excluded isolated CPUs from hctx->cpumask to prevent worker
threads from executing block work on isolated CPUs. When all CPUs mapped
to a hardware queue are isolated (i.e. blk_mq_hctx_empty_cpumask(hctx)
evaluates to true), blk_mq_hctx_next_cpu() returns WORK_CPU_UNBOUND with
the intention of offloading execution.

However, kblockd_workqueue is allocated as a per-CPU workqueue
(WQ_PERCPU). When WORK_CPU_UNBOUND is queued on a per-CPU workqueue, the
workqueue core resolves the target CPU via raw_smp_processor_id().
Consequently, if a task executing on an isolated CPU submits I/O and
triggers an asynchronous queue dispatch with zero delay (e.g. upon
hardware queue congestion, tag/resource exhaustion returning
BLK_STS_RESOURCE, or plugging), &hctx->run_work is queued directly onto
the local isolated CPU's worker pool. This causes the local per-CPU
high-priority kworker (e.g. "kworker/6:1H-kblockd") to be scheduled on
the isolated CPU. In real-time environments, an active SCHED_FIFO workload
will starve this SCHED_NORMAL worker, causing hardware dispatch to stall,
in addition to introducing unwanted latency jitter on nohz_full cores,
thereby defeating the original objective of commit a46c270.

Introduce blk_mq_hctx_unbound_cpu() to select an online housekeeping CPU
from housekeeping_cpumask(HK_TYPE_DOMAIN) via
cpumask_any_and_distribute() when executing on an isolated CPU, and
otherwise fall back to WORK_CPU_UNBOUND. Use this helper across the
unbound fallback paths in blk_mq_hctx_next_cpu().

Additionally, for single-queue devices, gate the check behind the static
key housekeeping_overridden under CONFIG_CPU_ISOLATION to ensure that
common configurations without CPU isolation incur zero overhead on the
fast path.

This ensures that:
    1.  When executing on an isolated CPU, deferred queue work is
        cleanly offloaded to an online housekeeping CPU across single-queue
        devices, hardware queues with empty cpumasks, and offline CPU
        fallback paths.

    2.  The per-CPU high-priority kworker on the isolated CPU is not
        scheduled, avoiding priority inversion and latency jitter.

    3.  When executing on a non-isolated CPU, WORK_CPU_UNBOUND is
        preserved, maintaining optimal local execution with zero CPU
        bouncing while avoiding timer pinning hazards.

    4.  On systems without CPU isolation, single-queue devices maintain
        the zero-overhead fast path via a static key.

Fixes: a46c270 ("blk-mq: don't schedule block kworker on isolated CPUs")
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: b3dfbde
series: https://patchwork.kernel.org/series/1190989/
version: 4

@ghost
ghost force-pushed the series/1183539=>linus-master branch from 46f338b to 2310017 Compare November 10, 2026 08:22
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.

1 participant