Prepare mutable list iterators to cache cursor state#983
Open
blktests-ci[bot] wants to merge 3 commits into
Open
Prepare mutable list iterators to cache cursor state#983blktests-ci[bot] wants to merge 3 commits into
blktests-ci[bot] wants to merge 3 commits into
Conversation
Author
|
Upstream branch: 66affa3 |
e6d9eb8 to
7d8604f
Compare
added 3 commits
June 24, 2026 01:25
The list_for_each*_safe() helpers are used when the loop body may remove the current entry. Their API exposes the temporary cursor at every call site, even though most users only need it for the iterator implementation and never reference it in the loop body. Add *_mutable() variants for list and hlist iteration. The new helpers support both forms: callers may keep passing an explicit temporary cursor when they need to inspect or reset it, or omit it and let the helper use a unique internal cursor. This makes call sites that only mutate the list through the current entry less noisy, while keeping the existing *_safe() helpers available for compatibility. Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
llist_for_each_safe() and llist_for_each_entry_safe() require callers to provide a temporary cursor even when the cursor is only needed by the iterator itself. This makes call sites noisier than necessary for the common case where the loop body may remove the current entry but does not otherwise inspect the saved next pointer. Add llist_for_each_mutable() and llist_for_each_entry_mutable() variants that support both forms. Callers may omit the temporary cursor and let the helper create an internal unique cursor, or keep passing an explicit cursor when the loop needs to inspect or reset it. Keep the existing safe helpers as compatibility wrappers so current users continue to build unchanged while new code can use the shorter mutable form. Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
The safe list iterators require callers to provide a temporary cursor even when the cursor is only used by the iterator itself. The mutable iterator variants keep the same removal-safe traversal semantics while allowing those internal cursors to be hidden from the call sites. Convert block users of list, hlist and llist safe iterators to the new mutable helpers. Drop the now-unused temporary cursor variables where the loop body does not inspect or reset them. This is a mechanical cleanup with no intended change in traversal order or list mutation behavior. Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
Author
|
Upstream branch: bade58e |
3f1a999 to
fcf138b
Compare
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: Prepare mutable list iterators to cache cursor state
version: 3
url: https://patchwork.kernel.org/project/linux-block/list/?series=1114485