Re: [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state
Kaitao Cheng <[email protected]> Wed, 24 Jun 2026 21:05:32 +0800
| Newsgroups | org.kernel.vger.audit,dev.linux.lists.damon,dev.linux.lists.llvm,dev.linux.lists.sched-ext,dev.linux.lists.virtualization,org.freedesktop.lists.dri-devel,org.infradead.lists.kexec,org.kernel.vger.bpf,org.kernel.vger.cgroups,org.kernel.vger.io-uring,org.kernel.vger.linux-block,org.kernel.vger.linux-crypto,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-modules,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-pm,org.kernel.vger.linux-trace-kernel,org.kernel.vger.live-patching,org.kernel.vger.netdev,org.kernel.vger.rcu,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
在 2026/6/22 16:37, Jani Nikula 写道: > On Mon, 22 Jun 2026, Kaitao Cheng <[email protected]> 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. Could we go back to the v1 version? What do you think of that implementation approach? https://lore.kernel.org/all/[email protected]/ -- Thanks Kaitao Cheng