From: Baoquan He <baoquan.he@linux.dev>
To: Youngjun Park <youngjun.park@lge.com>
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: Tue, 26 May 2026 23:33:37 +0800 [thread overview]
Message-ID: <ahW9UQH93jBT_VaD@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20260421055323.940344-4-youngjun.park@lge.com>
On 04/21/26 at 02:53pm, Youngjun Park wrote:
...snip...
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c3d98ab41f1f..0f67572e5e3e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -68,6 +68,7 @@
> #include <net/ip.h>
> #include "slab.h"
> #include "memcontrol-v1.h"
> +#include "swap_tier.h"
>
> #include <linux/uaccess.h>
>
> @@ -4130,6 +4131,8 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
> refcount_set(&memcg->id.ref, 1);
> css_get(css);
>
> + swap_tiers_memcg_inherit_mask(memcg);
> +
> /*
> * Ensure mem_cgroup_from_private_id() works once we're fully online.
> *
> @@ -5667,6 +5670,88 @@ static int swap_events_show(struct seq_file *m, void *v)
> return 0;
> }
>
> +static int swap_tier_show(struct seq_file *m, void *v)
> +{
> + struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
> +
> + swap_tiers_mask_show(m, READ_ONCE(memcg->tier_mask));
> + return 0;
> +}
> +
> +static ssize_t swap_tier_write(struct kernfs_open_file *of,
> + char *buf, size_t nbytes, loff_t off)
> +{
> + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
> + char *pos, *token;
> + int ret = 0;
> + int original_mask = 0;
> +
> + pos = strstrip(buf);
> +
> + spin_lock(&swap_tier_lock);
> + if (!*pos) {
> + WRITE_ONCE(memcg->tier_mask, TIER_ALL_MASK);
> + goto sync;
> + }
> +
> + original_mask = memcg->tier_mask;
> +
> + while ((token = strsep(&pos, " \t\n")) != NULL) {
> + int mask;
> +
> + if (!*token)
> + continue;
> +
> + if (token[0] != '-' && token[0] != '+') {
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + mask = swap_tiers_mask_lookup(token+1);
> + if (!mask) {
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + /*
> + * if child already set, cannot add that tiers for hierarch mismatching.
> + * parent compatible, child must respect parent selected swap device.
> + */
This paragraph of code comment sounds a little unnatural. We are writing
it into memcg, the child memcg is handled in
swap_tiers_memcg_sync_mask(), isn't it? I don't get the 2nd sentence.
Could you help explain?
> + switch (token[0]) {
> + case '-':
> + WRITE_ONCE(memcg->tier_mask,
> + memcg->tier_mask & ~mask);
> + break;
> + case '+':
> + WRITE_ONCE(memcg->tier_mask,
> + memcg->tier_mask | mask);
> + break;
> + default:
> + ret = -EINVAL;
> + break;
> + }
> +
> + if (ret)
> + goto err;
> + }
> +
> +sync:
> + swap_tiers_memcg_sync_mask(memcg);
> +err:
> + if (ret)
> + WRITE_ONCE(memcg->tier_mask, original_mask);
> + spin_unlock(&swap_tier_lock);
> + return ret ? ret : nbytes;
> +}
> +
...snip...
next prev parent reply other threads:[~2026-05-26 15:33 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 [this message]
2026-05-27 1:58 ` YoungJun Park
2026-05-26 23:56 ` Baoquan He
2026-05-27 2:08 ` YoungJun Park
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=ahW9UQH93jBT_VaD@MiWiFi-R3L-srv \
--to=baoquan.he@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--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 \
--cc=youngjun.park@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 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.