Linux cgroups development
 help / color / mirror / Atom feed
From: YoungJun Park <youngjun.park@lge.com>
To: Baoquan He <baoquan.he@linux.dev>
Cc: akpm@linux-foundation.org, chrisl@kernel.org, linux-mm@kvack.org,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	kasong@tencent.com, hannes@cmpxchg.org, mhocko@kernel.org,
	roman.gushchin@linux.dev, shakeel.butt@linux.dev,
	muchun.song@linux.dev, shikemeng@huaweicloud.com,
	nphamcs@gmail.com, bhe@redhat.com, baohua@kernel.org,
	gunho.lee@lge.com, taejoon.song@lge.com, hyungjun.cho@lge.com,
	mkoutny@suse.com, baver.bae@lge.com, matia.kim@lge.com
Subject: Re: [PATCH v6 3/4] mm: memcontrol: add interfaces for swap tier selection
Date: Wed, 27 May 2026 11:08:06 +0900	[thread overview]
Message-ID: <ahZSBsSiSeQnJZrn@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <ahYzNVQHnWlwYq8u@MiWiFi-R3L-srv>

On Wed, May 27, 2026 at 07:56:37AM +0800, Baoquan He wrote:
> On 04/21/26 at 02:53pm, Youngjun Park wrote:
> ...snip...
> > diff --git a/mm/swap_tier.c b/mm/swap_tier.c
> > index 9019b8978770..b53d6cc67d1e 100644
> > --- a/mm/swap_tier.c
> > +++ b/mm/swap_tier.c
> ...snip...
> > @@ -374,6 +404,80 @@ bool swap_tiers_update(void)
> >  			break;
> >  		swap_tiers_assign_dev(swp);
> >  	}
> > +	/*
> > +	 * XXX: Unused tiers default to ON, disabled after next tier added.
> > +	 * Use removed tier mask to clear settings for removed/re-added tiers.
> > +	 * (Could hold tier refs, but better to keep cgroup config independent)
> > +	 */
> > +	if (mask)
> > +		swap_tier_memcg_propagate(mask);
> 
> Code is neat, and high efficiency, while it's not easy to understand. I
> just sat in front of my computer the whole day yesterday to recall and
> understand why it's done like this, even though I made it clear to my
> self in the past. I think more words would be helpful to decrease the
> difficulty for people to undersntand it. E.g below two paragraphes. Just
> a suggestion and for your reference.

Thanks for the review again :)

Okay I see.
This explanation seems heavily abbreviated.

> diff --git a/mm/swap_tier.c b/mm/swap_tier.c
> index b53d6cc67d1e..0a6adf14ab91 100644
> --- a/mm/swap_tier.c
> +++ b/mm/swap_tier.c
> @@ -405,9 +405,17 @@ bool swap_tiers_update(int mask)
>  		swap_tiers_assign_dev(swp);
>  	}
>  	/*
> -	 * XXX: Unused tiers default to ON, disabled after next tier added.
> -	 * Use removed tier mask to clear settings for removed/re-added tiers.
> -	 * (Could hold tier refs, but better to keep cgroup config independent)
> +	 * When a tier is removed, its index (bit position in the mask) becomes
> +	 * free for reassignment to a future tier.  If a memcg had previously
> +	 * disabled this tier (cleared the bit in its swap.tiers file), the
> +	 * effective mask would keep that bit clear -- meaning the new tier at
> +	 * the same index would be silently unavailable, an invisible cgroup
> +	 * constraint left behind by a tier that no longer exists.
> +	 *
> +	 * To prevent this, OR the removed tier's mask bit into every memcg's
> +	 * tier_mask and tier_effective_mask.  This resets the bit so the new
> +	 * tier is accessible by default; users who want to restrict it must
> +	 * explicitly disable it after the tier is re-created.
>  	 */

The explanation seems good.

it explains why we must clear the "disabled bit",
when a new tier comes and we don't automatically diable,
it can implicitly disable "new tier" which user might not want.

This comes from that fact we don't have a cgroup refecounting on the tier land.
it is the corner case, we must sync for correct behavior.

I will change the comments as like it is.

  reply	other threads:[~2026-05-27  2:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  5:53 [PATCH v6 0/4] mm/swap, memcg: Introduce swap tiers for cgroup based swap control Youngjun Park
2026-04-21  5:53 ` [PATCH v6 1/4] mm: swap: introduce swap tier infrastructure Youngjun Park
2026-05-25 21:49   ` Baoquan He
2026-05-26  6:12     ` YoungJun Park
2026-05-25 22:57   ` Baoquan He
2026-05-26  6:09     ` YoungJun Park
2026-05-26 10:52       ` Baoquan He
2026-04-21  5:53 ` [PATCH v6 2/4] mm: swap: associate swap devices with tiers Youngjun Park
2026-05-25 23:04   ` Baoquan He
2026-04-21  5:53 ` [PATCH v6 3/4] mm: memcontrol: add interfaces for swap tier selection Youngjun Park
2026-04-23  4:34   ` YoungJun Park
2026-05-26 15:33   ` Baoquan He
2026-05-27  1:58     ` YoungJun Park
2026-05-26 23:56   ` Baoquan He
2026-05-27  2:08     ` YoungJun Park [this message]
2026-04-21  5:53 ` [PATCH v6 4/4] mm: swap: filter swap allocation by memcg tier mask Youngjun Park
2026-04-23  4:38   ` YoungJun Park
2026-05-27  1:42   ` Baoquan He
2026-05-27  2:17     ` YoungJun Park

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=ahZSBsSiSeQnJZrn@yjaykim-PowerEdge-T330 \
    --to=youngjun.park@lge.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=baver.bae@lge.com \
    --cc=bhe@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=gunho.lee@lge.com \
    --cc=hannes@cmpxchg.org \
    --cc=hyungjun.cho@lge.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matia.kim@lge.com \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=taejoon.song@lge.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