Thread (14 messages) flat view 14 messages, 4 authors, 2d ago

Re: [PATCH 1/3] blk-cgroup: use a request_queue rhashtable for blkg lookup

From: Nilay Shroff <hidden>
Date: 2026-09-06 11:04:41
Also in: cgroups, dm-devel, gfs2, linux-bcache, linux-block, linux-doc, linux-fsdevel, linux-mm, lkml, nvdimm, virtualization

On 8/23/26 7:00 PM, Yu Kuai wrote:
From: Yu Kuai<yukuai@fygo.io>

blkg lookup currently uses a per-blkcg radix tree keyed by request queue
ID, plus a lookup hint for the common case. This spreads the queue-local
blkcg association index across every blkcg and requires radix-tree
preloading before creating a blkg while holding q->queue_lock.

Replace the radix tree and lookup hint with a request_queue-owned
rhashtable keyed by the blkcg CSS ID. Cache the ID in each blkg; the blkg
holds a CSS reference until after it leaves the hash, so the ID cannot be
reused while it is hash-visible. The integer key also reduces hashing and
comparison work relative to a pointer-sized key on 64-bit systems.

Keep entries until blkg_release() and provide blkg_lookup_any() for callers
which need to find dying entries. blkg_lookup() filters offline entries so
existing lookup semantics remain unchanged.

Keep q->blkg_list for ordered policy and scheduler walks. All current
walkers are cgroupfs or sysfs slow paths, so they can move to rhashtable
iteration once the q->queue_lock to q->blkcg_mutex conversion lands.
Initialize and destroy the hash with request_queue, and remove the
radix-tree preload paths which are no longer needed.

blkg_release() removes the hash entry only when the blkg was successfully
inserted into q->blkg_list; the list_empty case covers allocation or
creation failure before insertion.

Signed-off-by: Yu Kuai<yukuai@fygo.io>
Reviewed-by: Christoph Hellwig<hch@lst.de>
Looks good to me.
Reviewed-by: Nilay Shroff <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help