mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baoquan He <baoquan.he@linux.dev>
To: Hui Zhu <hui.zhu@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	David Hildenbrand <david@kernel.org>,
	Michal Hocko <mhocko@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Harry Yoo <harry@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Hui Zhu <zhuhui@kylinos.cn>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mm: mglru: reset the mm iteration cursor in try_to_inc_max_seq_nowalk()
Date: Wed, 25 Nov 2026 10:28:19 +0800	[thread overview]
Message-ID: <awZHw6CK4_CaPUUf@fedora> (raw)
In-Reply-To: <0e42e0c4-c1f9-4778-a979-404fbb68130a@linux.dev>

On 11/19/26 at 05:35pm, Hui Zhu wrote:
> 
> 2026/11/19 15:29, Baoquan He:
> > On 11/17/26 at 07:37pm, Hui Zhu wrote:
> > > From: Hui Zhu <zhuhui@kylinos.cn>
> > > 
...snip...
> > > @@ -3263,6 +3264,18 @@ static bool iterate_mm_list(struct lru_gen_mm_walk *walk, struct mm_struct **ite
> > >   	return last;
> > >   }
> > > +/*
> > > + * Advance mm_state->seq without walking the mm_list. The cursor must be
> > > + * dropped as well: iterate_mm_list() resumes from head, and resets the Bloom
> > > + * filter only when head == &mm_list->fifo.
> > > + */
> > This looks like a good catch, while the function name here is a little bit
> > confusing. From the code block inside, we can't see it's doing iteration,
> > just a pair of pointer resetting and a max_seq advancing. I would rather
> > not wrap up them if no good name is concluded. Personal opinion.
> How about inc_mm_state_seq(), after inc_max_seq(), leaving the "why"
> to the comment:
> 
>     /*
>      * The cursor must be dropped along with mm_state->seq:
>      * iterate_mm_list() resumes from head, and resets the Bloom filter
>      * only when head == &mm_list->fifo.
>      */
>     static void inc_mm_state_seq(struct lru_gen_mm_state *mm_state)
> 
> If that still does not read well to you, I will drop the helper in v2 and
> keep the two lines open-coded.

I feel like not wrapping them up is a little better than wrapping in
this case, while it's purely personal flavor. I would like to hear
other reviewers' opinion or it's up to you. Thanks.

> > 
> > Other than the nits,
> > 
> > Reviewed-by: Baoquan He <baoquan.he@linux.dev>
> 
> Thank you!
> 
> Best,
> Hui
> 
> > 
> > > +static void skip_mm_iteration(struct lru_gen_mm_state *mm_state)
> > > +{
> > > +	mm_state->head = NULL;
> > > +	mm_state->tail = NULL;
> > > +	WRITE_ONCE(mm_state->seq, mm_state->seq + 1);
> > > +}
> > > +
> > >   static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long seq)
> > >   {
> > >   	bool success = false;
> > > @@ -3275,9 +3288,7 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long seq)
> > >   	VM_WARN_ON_ONCE(mm_state->seq + 1 < seq);
> > >   	if (seq > mm_state->seq) {
> > > -		mm_state->head = NULL;
> > > -		mm_state->tail = NULL;
> > > -		WRITE_ONCE(mm_state->seq, mm_state->seq + 1);
> > > +		skip_mm_iteration(mm_state);
> > >   		success = true;
> > >   	}
> > > @@ -4686,15 +4697,11 @@ static void try_to_inc_max_seq_nowalk(struct mem_cgroup *memcg,
> > >   	DEFINE_MAX_SEQ(lruvec);
> > >   	bool success = false;
> > > -	/*
> > > -	 * We are not iterating the mm_list here, updating mm_state->seq is just
> > > -	 * to make mm walkers work properly.
> > > -	 */
> > >   	if (mm_state) {
> > >   		spin_lock(&mm_list->lock);
> > >   		VM_WARN_ON_ONCE(mm_state->seq + 1 < max_seq);
> > >   		if (max_seq > mm_state->seq) {
> > > -			WRITE_ONCE(mm_state->seq, mm_state->seq + 1);
> > > +			skip_mm_iteration(mm_state);
> > >   			success = true;
> > >   		}
> > >   		spin_unlock(&mm_list->lock);
> > > -- 
> > > 2.53.0
> > > 

      reply	other threads:[~2026-11-25  2:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:37 Hui Zhu
2026-11-19  7:29 ` Baoquan He
2026-11-19  9:35   ` Hui Zhu
2026-11-25  2:28     ` Baoquan He [this message]

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=awZHw6CK4_CaPUUf@fedora \
    --to=baoquan.he@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry@kernel.org \
    --cc=hui.zhu@linux.dev \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.com \
    --cc=zhuhui@kylinos.cn \
    /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

all inboxes | Powered by JetHome®