All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
To: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org
Subject: Re: [PATCH 3/3] mm/memcg: move generation assignment and comparison together
Date: Wed, 30 Mar 2022 11:57:07 -0400	[thread overview]
Message-ID: <YkR902CHgavwleet@cmpxchg.org> (raw)
In-Reply-To: <20220225003437.12620-4-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Fri, Feb 25, 2022 at 12:34:37AM +0000, Wei Yang wrote:
> For each round-trip, we assign generation on first invocation and
> compare it on subsequent invocations.
> 
> Let's move them together to make it more self-explaining. Also this
> reduce a check on prev.
> 
> Signed-off-by: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This makes sense. The function is structured into 1) load state, 2)
advance, 3) save state. The load state is a better fit for
initializing reclaim->generation.

> @@ -996,7 +996,14 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
>  		mz = root->nodeinfo[reclaim->pgdat->node_id];
>  		iter = &mz->iter;
>  
> -		if (prev && reclaim->generation != iter->generation)
> +		/*
> +		 * On first invocation, assign iter->generation to
> +		 * reclaim->generation.
> +		 * On subsequent invocations, make sure no one else jump in.
> +		 */
> +		if (!prev)
> +			reclaim->generation = iter->generation;
> +		else if (reclaim->generation != iter->generation)
>  			goto out_unlock;

The comment duplicates the code, it doesn't explain why we're doing
this. How about:

		/*
		 * On start, join the current reclaim iteration cycle.
		 * Exit when a concurrent walker completes it.
		 */

With that, please feel free to add:

Acked-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>

WARNING: multiple messages have this Message-ID (diff)
From: Johannes Weiner <hannes@cmpxchg.org>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: mhocko@kernel.org, vdavydov.dev@gmail.com,
	akpm@linux-foundation.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 3/3] mm/memcg: move generation assignment and comparison together
Date: Wed, 30 Mar 2022 11:57:07 -0400	[thread overview]
Message-ID: <YkR902CHgavwleet@cmpxchg.org> (raw)
In-Reply-To: <20220225003437.12620-4-richard.weiyang@gmail.com>

On Fri, Feb 25, 2022 at 12:34:37AM +0000, Wei Yang wrote:
> For each round-trip, we assign generation on first invocation and
> compare it on subsequent invocations.
> 
> Let's move them together to make it more self-explaining. Also this
> reduce a check on prev.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>

This makes sense. The function is structured into 1) load state, 2)
advance, 3) save state. The load state is a better fit for
initializing reclaim->generation.

> @@ -996,7 +996,14 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
>  		mz = root->nodeinfo[reclaim->pgdat->node_id];
>  		iter = &mz->iter;
>  
> -		if (prev && reclaim->generation != iter->generation)
> +		/*
> +		 * On first invocation, assign iter->generation to
> +		 * reclaim->generation.
> +		 * On subsequent invocations, make sure no one else jump in.
> +		 */
> +		if (!prev)
> +			reclaim->generation = iter->generation;
> +		else if (reclaim->generation != iter->generation)
>  			goto out_unlock;

The comment duplicates the code, it doesn't explain why we're doing
this. How about:

		/*
		 * On start, join the current reclaim iteration cycle.
		 * Exit when a concurrent walker completes it.
		 */

With that, please feel free to add:

Acked-by: Johannes Weiner <hannes@cmpxchg.org>


  parent reply	other threads:[~2022-03-30 15:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25  0:34 [PATCH 0/3] mm/memcg: some cleanup for mem_cgroup_iter() Wei Yang
2022-02-25  0:34 ` Wei Yang
     [not found] ` <20220225003437.12620-1-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-02-25  0:34   ` [PATCH 1/3] mm/memcg: set memcg after css verified and got reference Wei Yang
2022-02-25  0:34     ` Wei Yang
     [not found]     ` <20220225003437.12620-2-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-29 18:44       ` Johannes Weiner
2022-03-29 18:44         ` Johannes Weiner
2022-02-25  0:34   ` [PATCH 2/3] mm/memcg: set pos to prev unconditionally Wei Yang
2022-02-25  0:34     ` Wei Yang
     [not found]     ` <20220225003437.12620-3-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-29 18:48       ` Johannes Weiner
2022-03-29 18:48         ` Johannes Weiner
     [not found]         ` <YkNUZYrSHPjJ1XOb-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2022-03-30  0:47           ` Wei Yang
2022-03-30  0:47             ` Wei Yang
2022-03-30 12:08             ` Johannes Weiner
2022-03-30 12:08               ` Johannes Weiner
     [not found]               ` <YkRIUbEGHVIbVRNO-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2022-03-30 14:22                 ` Wei Yang
2022-03-30 14:22                   ` Wei Yang
2022-02-25  0:34   ` [PATCH 3/3] mm/memcg: move generation assignment and comparison together Wei Yang
2022-02-25  0:34     ` Wei Yang
     [not found]     ` <20220225003437.12620-4-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-30 15:57       ` Johannes Weiner [this message]
2022-03-30 15:57         ` Johannes Weiner
     [not found]         ` <YkR902CHgavwleet-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2022-03-30 23:04           ` Wei Yang
2022-03-30 23:04             ` Wei Yang
2022-02-25  8:13   ` [PATCH 0/3] mm/memcg: some cleanup for mem_cgroup_iter() Michal Hocko
2022-02-25  8:13     ` Michal Hocko

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=YkR902CHgavwleet@cmpxchg.org \
    --to=hannes-druugvl0lcnafugrpc6u6w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.