On 3/14/22 1:57 AM, Tejun Heo wrote: > blk-iocost and iolatency are cgroup aware rq-qos policies but, unlike > elevators, they didn't have a way to disable merges across different > cgroups. This obviously can lead to accounting and control errors but more > importantly to priority inversions - e.g. an IO which belongs to a higher > priority cgroup or IO class may end up getting throttled incorrectly because > it gets merged to an IO issued from a low priority cgroup. > > Fix it by adding blk_cgroup_mergeable() which is called from merge paths to > test whether merges are acceptable from cgroup POV. When iocost or iolatency > is active, this rejects cross-cgroup and cross-issue_as_root merges. > > While at it, > > * Add WARN_ON_ONCE() on blkg mismatch in ioc_rqos_merge() so that we can > easily notice similar failures in the future. > > * Make sure iocost enable/disable transitions only happen when iocost is > actually enabled / disabled. Is there really no better way to do this than add a lot of expensive checks to the fast path? Even just inverting the checks so that if (req->bio->bi_blkg != bio->bi_blkg) ... is checked first would seem a lot saner. In any case, since this isn't a new regression, I'd feel a lot better deferring it to 5.18. -- Jens Axboe