Linux cgroups development
 help / color / mirror / Atom feed
From: Youngjun Park <youngjun.park@lge.com>
To: Usama Arif <usama.arif@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,
	baoquan.he@linux.dev, baohua@kernel.org, yosry@kernel.org,
	joshua.hahnjy@gmail.com, gunho.lee@lge.com, taejoon.song@lge.com,
	hyungjun.cho@lge.com, baver.bae@lge.com, her0gyugyu@gmail.com
Subject: Re: [PATCH v10 2/6] mm: swap: associate swap devices with tiers
Date: Tue, 14 Jul 2026 00:20:45 +0900	[thread overview]
Message-ID: <alUCTVQSVH/gPbjo@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <20260713142856.102257-1-usama.arif@linux.dev>

On Mon, Jul 13, 2026 at 07:28:53AM -0700, Usama Arif wrote:

> >  #endif /* _SWAP_TIER_H */
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index ff567ad893a4..f3cff586cf30 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -3041,6 +3041,8 @@ static void _enable_swap_info(struct swap_info_struct *si)
> >  
> >  	/* Add back to available list */
> >  	add_to_avail_list(si, true);
> > +
> > +	swap_tiers_assign_dev(si);
> 
> Could we move the assignment before the device is added to the active and
> available lists?
> 
> After patch 4, swap allocation checks si->tier_mask while holding only
> swap_avail_lock. But here the new device is added to swap_avail_head
> before swap_tiers_assign_dev() initializes its mask.
> 
> That creates a small window where reclaim can see this swap_info_struct
> with a stale tier_mask. swap_info_struct instances are reused across
> swapoff/swapon, so the stale mask can come from the previous device that
> occupied this slot. A memcg allowed to use the old tier could then
> temporarily allocate from the newly enabled device even if that device
> belongs to a different tier.

Hello Usama. 
Thanks for the review!

Good catch! You're right.
the device becomes visible to swap_alloc_slow() the moment add_to_avail_list() drops swap_avail_lock, 
before the mask is assigned. 

Will move the assignment before the list insertions in v11.

Youngjun

  reply	other threads:[~2026-07-13 15:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  2:56 [PATCH v10 0/6] mm/swap, memcg: Introduce swap tiers for cgroup based swap control Youngjun Park
2026-07-13  2:56 ` [PATCH v10 1/6] mm: swap: introduce swap tier infrastructure Youngjun Park
2026-07-13  2:56 ` [PATCH v10 2/6] mm: swap: associate swap devices with tiers Youngjun Park
2026-07-13 14:28   ` Usama Arif
2026-07-13 15:20     ` Youngjun Park [this message]
2026-07-13  2:56 ` [PATCH v10 3/6] mm: memcontrol: add interface for swap tier selection Youngjun Park
2026-07-13  2:56 ` [PATCH v10 4/6] mm: swap: filter swap allocation by memcg tier mask Youngjun Park
2026-07-13  2:56 ` [PATCH v10 5/6] selftests/mm: add a swap tier configuration test Youngjun Park
2026-07-13  2:56 ` [PATCH v10 6/6] selftests/cgroup: add a swap tier routing test Youngjun Park
2026-07-13 15:50 ` [PATCH v10 0/6] mm/swap, memcg: Introduce swap tiers for cgroup based swap control Yosry Ahmed
2026-07-13 15:57   ` Youngjun Park
2026-07-13 16:01     ` Yosry Ahmed
2026-07-13 16:22       ` Youngjun Park
2026-07-13 17:02       ` Chris Li
2026-07-13 17:11         ` Yosry Ahmed
2026-07-13 18:34           ` Chris Li
2026-07-13 18:37             ` Yosry Ahmed
2026-07-13 19:38               ` Chris Li
2026-07-13 19:57                 ` Yosry Ahmed
2026-07-13 21:49                   ` Chris Li
2026-07-13 17:05   ` Chris Li

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=alUCTVQSVH/gPbjo@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=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=gunho.lee@lge.com \
    --cc=hannes@cmpxchg.org \
    --cc=her0gyugyu@gmail.com \
    --cc=hyungjun.cho@lge.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=taejoon.song@lge.com \
    --cc=usama.arif@linux.dev \
    --cc=yosry@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox