Thread (22 messages) 22 messages, 9 authors, 2d ago

Re: [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state

From: Kaitao Cheng <hidden>
Date: 2026-06-24 13:06:09
Also in: bpf, cgroups, damon, dri-devel, io-uring, kexec, linux-block, linux-crypto, linux-fsdevel, linux-mm, linux-modules, linux-perf-users, linux-pm, linux-trace-kernel, live-patching, lkml, llvm, rcu, sched-ext, virtualization


在 2026/6/22 16:37, Jani Nikula 写道:
On Mon, 22 Jun 2026, Kaitao Cheng [off-list ref] wrote:
quoted
Add *_mutable() iterator variants for list, hlist and llist.  The new
helpers are variadic and support both forms.  In the common case, the
caller omits the temporary cursor and the macro creates a unique internal
cursor with typeof(pos) and __UNIQUE_ID().  If a loop really needs an
explicit temporary cursor, the caller can still pass it and the helper
keeps the existing *_safe() behaviour.

For example, a call site may use the shorter form:

  list_for_each_entry_mutable(pos, head, member)

or keep the explicit temporary cursor form:

  list_for_each_entry_mutable(pos, tmp, head, member)
I'm unconvinced it's a good idea to allow two forms with macro trickery,
*especially* when it's not the last argument you can omit. I think it's
a footgun.

IMO stick with the first form only, and there'll always be the _safe
variant that can be used when the temp pointer is needed.
Could we go back to the v1 version? What do you think of that
implementation approach?

https://lore.kernel.org/all/20260529082149.76764-1-kaitao.cheng@linux.dev/ (local)

-- 
Thanks
Kaitao Cheng
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help