Linux cgroups development
 help / color / mirror / Atom feed
* [PATCH 0/3] block: skip the blkcg walk in blk_cgroup_congested() when nothing is throttled
@ 2026-08-06 18:37 Usama Arif
  2026-08-06 18:37 ` [PATCH 1/3] blk-iolatency: clear delay state when freeing policy data Usama Arif
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Usama Arif @ 2026-08-06 18:37 UTC (permalink / raw)
  To: axboe, cgroups, josef, linux-block, linux-kernel, tj
  Cc: shakeel.butt, hannes, riel, kernel-team, Usama Arif

blk_cgroup_congested() walks the current task's blkcg ancestor chain on every
readahead decision and, once swap is in use, on every anonymous and shmem
folio allocation.  The answer is almost always "no", but finding that out
costs two loads *per level* on two cold cache lines, plus an out-of-line
kthread_blkcg() and an RCU read-side pair.  On a fleet profile of hosts
running containers with 5-10 level hierarchies it costs about as much as all
of mutex_lock(), 99.4% of it under __folio_throttle_swaprate().

Patch 3 gates the walk on a global count of blkcgs with a non-zero
congestion_count, so the common case is a load and a predicted branch.

That only works if the count is correctly maintained, currently two teardown
paths can leave a blkcg permanently marked congested.  Today that only hurts
tasks in the affected cgroup, but it hurts them for the life of the cgroup -
readahead cut to a single page, async readahead skipped, and a throttle
scheduled on every anonymous folio allocation.  With a global gate it would
cost every other task on the machine the walk as well.  Patches 1 and 2 fix
those two paths and stand on their own as bugfixes; patch 3 depends on them.
 
Usama Arif (3):
  blk-iolatency: clear delay state when freeing policy data
  blk-iocost: clear delay state when freeing policy data
  block: skip blkcg walk in blk_cgroup_congested() when nothing
    throttled

 block/blk-cgroup.c         | 15 ++++++++++++++-
 block/blk-cgroup.h         | 25 +++++++++++++++++++++----
 block/blk-iocost.c         |  7 +++++++
 block/blk-iolatency.c      |  9 +++++++++
 include/linux/blk-cgroup.h | 23 ++++++++++++++++++++++-
 5 files changed, 73 insertions(+), 6 deletions(-)

-- 
2.53.0-Meta


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

end of thread, other threads:[~2026-08-06 18:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 18:37 [PATCH 0/3] block: skip the blkcg walk in blk_cgroup_congested() when nothing is throttled Usama Arif
2026-08-06 18:37 ` [PATCH 1/3] blk-iolatency: clear delay state when freeing policy data Usama Arif
2026-08-06 18:37 ` [PATCH 2/3] blk-iocost: " Usama Arif
2026-08-06 18:37 ` [PATCH 3/3] block: skip blkcg walk in blk_cgroup_congested() when nothing throttled Usama Arif

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox