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

Jani Nikula <[email protected]>
Newsgroups org.kernel.vger.io-uring,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.audit,org.kernel.vger.bpf,org.kernel.vger.cgroups,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
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland
Message-ID <[email protected]>
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.


BR,
Jani.


-- 
Jani Nikula, Intel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.