Skip to content

nvmet: add cgroup_id to charge namespace I/O to a cgroup - #25

Open
ghost wants to merge 1 commit into
for-next_basefrom
series/1174579=>for-next
Open

ghost wants to merge 1 commit into
for-next_basefrom
series/1174579=>for-next

Conversation

@ghost

@ghost ghost commented Nov 10, 2026

Copy link
Copy Markdown

Pull request for series with
subject: nvmet: add cgroup_id to charge namespace I/O to a cgroup
version: 13
url: https://patchwork.kernel.org/series/1204350/

@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: de52810
series: https://patchwork.kernel.org/series/1204350/
version: 13

@ghost
ghost force-pushed the for-next_base branch from 8c33852 to 18eb5ad Compare November 10, 2026 10:19
The nvmet issues namespace IOs from kernel threads. So the io.max and
other cgroup controllers can't apply limits to the namespaces.
Consider this scenario: LVM creates multiple logical volumes on the
same physical disk, and the logical volumes are assigned to different
nvmet subsystems/namespaces. We want to stop a remote noisy user from
using all the disk iops via nvmet. So add a per namespace cgroup_id to
associate the namespace with a cgroup. Each namespace can then be
throttled separately.

The per namespace cgroup is good enough for the io.max, but is not good
enough for the io.cost and io.latency. The io.cost and io.latency may
put a thread to sleep. If the thread is shared by different namespaces,
all of them will be impacted together. Submit the IOs via a workqueue to
avoid this impact.

With cgroup_id set, every I/O command except Reservation commands runs
from its own work item on a per namespace WQ_HIGHPRI workqueue. Zone
management and the file backend's Flush, DSM and Write Zeroes run
directly in that work item. Each work item runs under memalloc_noio and
looks up the cgroup's effective io css. A command whose queue is being
deleted is aborted. buffered_io is not supported.

Performance test:
On a 4 core VM and 4G ramdisk, export tcp-nvmeof targets to 127.0.0.1,
run fio with below parameters:
fio --bs=4k --rw=randwrite --iodepth=32 --numjobs=4 --ioengine=libaio --direct=1

file backend result:
|                            | IOPS   | Mean Latency | p99 latency |
|without this patch          | 204.4k | 625.8 µs     | 668 µs      |
|this patch, cgroup_id unset | 204.4k | 625.7 µs     | 668 µs      |
|this patch, cgroup_id set   | 155.9k | 820.6 µs     | 1139 µs     |

block device backend result:
|                            | IOPS   | Mean Latency | p99 latency |
|without this patch          | 216.0k | 592.2 µs     | 627 µs      |
|this patch, cgroup_id unset | 216.0k | 592.1 µs     | 627 µs      |
|this patch, cgroup_id set   | 160.0k | 799.6 µs     | 1090 µs     |

With this patch and no cgroup_id set, the performance is almost the same.
When we set the cgroup_id, with no io controller limit, we can see a
performance decrease but it is still very fast.

Signed-off-by: Peng Yu <yupeng0921@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Assisted-by: Claude:claude-fable-5 [Claude Code]
Assisted-by: Claude:claude-opus-5-5 [Claude Code]
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: de52810
series: https://patchwork.kernel.org/series/1204350/
version: 13

@ghost
ghost force-pushed the series/1174579=>for-next branch from b7e3a87 to 066668e Compare November 10, 2026 10:28
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