Repository navigation
blk-iocost: fix hweight cache publication and donation fail-safe - #1466
Open
blktests-ci-kpd[bot] wants to merge 2 commits into
Open
blktests-ci-kpd[bot] wants to merge 2 commits into
blktests-ci-kpd[bot] wants to merge 2 commits into
Conversation
transfer_surpluses() warns and then keeps going when the donation calculation produced invalid weights. The following propagation can then divide by a zero hweight_inuse, so the warning is immediately followed by a divide error. When the check trips, abandon this period's donation transfer and release the walk lists. This trades one period without donation for not crashing; the invalid state is not expected on the normal path. Developed with assistance from Claude Code (Anthropic): the assistant analysed the failure path, drafted the change and ran the checks listed below. The author reviewed the result and remains responsible for it. Fixes: e08d02a ("blk-iocost: implement Andy's method for donation weight updates") Cc: stable@vger.kernel.org Signed-off-by: Kunhai Dai <daikunhai@didiglobal.com>
current_hweight() publishes the cache generation and both weights with separate stores. Refreshers running on different CPUs can interleave their stores and leave a new generation paired with weights from an older calculation. The compiler can also reorder the generation store before the weight stores, so a reader that sees the new generation can accept stale weights. A stale weight is not only a reporting artifact. It feeds the cost calculation and the donation logic, where an inconsistent combination can lead to a zero divisor in transfer_surpluses(). In addition, the slow path rereads iocg->hweight_active/inuse after publishing them, so the value it returns can be the one written by another refresher instead of the locally computed one. Pack the generation and both weights into a single atomic64_t and publish them with one atomic write. Readers take one atomic snapshot and return the local values. Weights are in [1, WEIGHT_ONE]; storing each minus one preserves the full range in 16 bits and leaves 32 bits for the generation. The two weight fields remain as the donation workspace used under ioc->lock. Tracepoints decode the packed cache without refreshing it and iocost_monitor.py is updated accordingly. Developed with assistance from Claude Code (Anthropic): the assistant drafted the packed representation, the helpers and the tracepoint/monitor changes, and ran the checks listed below. The author reviewed the result and remains responsible for it. Fixes: 7caa471 ("blkcg: implement blk-iocost") Signed-off-by: Kunhai Dai <daikunhai@didiglobal.com>
Author
|
Upstream branch: c03c1a1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: blk-iocost: fix hweight cache publication and donation fail-safe
version: 2
url: https://patchwork.kernel.org/series/1188903/