mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Kaitao Cheng <kaitao.cheng@linux.dev>
Cc: nsc@kernel.org, nathan@kernel.org, paulmck@kernel.org,
	andriy.shevchenko@linux.intel.com, dhowells@redhat.com,
	rdunlap@infradead.org, luca.ceresoli@bootlin.com,
	chengkaitao@kylinos.cn, acme@redhat.com, irogers@google.com,
	peterz@infradead.org, namhyung@kernel.org,
	swapnil.sapkal@amd.com, linux-kernel@vger.kernel.org,
	muchun.song@linux.dev, linux-kbuild@vger.kernel.org
Subject: Re: [PATCH] list: Add safe entry iterators without an explicit n cursor
Date: Fri, 29 May 2026 19:19:25 -0700	[thread overview]
Message-ID: <20260529191925.914d1cfa2b40b5cec32c0e70@linux-foundation.org> (raw)
In-Reply-To: <20260529082149.76764-1-kaitao.cheng@linux.dev>

On Fri, 29 May 2026 16:21:49 +0800 Kaitao Cheng <kaitao.cheng@linux.dev> wrote:

> The list_for_each_entry_safe*() helpers are useful for loops which may
> remove the current entry, but they require callers to provide a second
> cursor named by convention as n. Some users do not need to inspect or
> reset that cursor; they only need the iterator to keep the next entry
> available while the current entry may be removed.
> 
> Add entry iterators which hide that temporary next cursor while otherwise
> following the traversal pattern of the corresponding
> list_for_each_entry_safe*() helpers.
> 
> Do not fold this behavior into list_for_each_entry(). That iterator
> advances from pos after the loop body, and a few existing callers rely
> on that semantics to observe list changes made during the body. For
> example, stress_reorder_work() in kernel/locking/test-ww_mutex.c moves
> the current entry to the list head with list_move(&ll->link, &locks) and
> documents that this restarts iteration. If list_for_each_entry() cached
> the next entry before running the body, the loop would continue from the
> stale saved next entry instead of honoring the modified list order.

Oh boy, this is a whole bunch of inscrutable macro magic and AI review
(https://sashiko.dev/#/patchset/20260529082149.76764-1-kaitao.cheng@linux.dev)
is suggesting that it become even moreso.

I suggest that some patches which _use_ these macros would help to
demonstrate the value.  And perhaps use of a clever regexp which tells
us how many sites might benefit.

  reply	other threads:[~2026-05-30  2:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29  8:21 Kaitao Cheng
2026-05-30  2:19 ` Andrew Morton [this message]
2026-05-30  6:49 ` Muchun Song
2026-06-02  9:12   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260529191925.914d1cfa2b40b5cec32c0e70@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=acme@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=chengkaitao@kylinos.cn \
    --cc=dhowells@redhat.com \
    --cc=irogers@google.com \
    --cc=kaitao.cheng@linux.dev \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=muchun.song@linux.dev \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=swapnil.sapkal@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome