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

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

From: Jani Nikula <jani.nikula@linux.intel.com>
Date: 2026-06-22 08:37:48
Also in: bpf, cgroups, damon, dri-devel, io-uring, kexec, linux-block, linux-crypto, linux-fsdevel, linux-mm, linux-perf-users, linux-pm, linux-trace-kernel, live-patching, lkml, llvm, netdev, rcu, sched-ext, virtualization

On Mon, 22 Jun 2026, Kaitao Cheng [off-list ref] wrote:
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.


BR,
Jani.


-- 
Jani Nikula, Intel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help