mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: bingfangguo@tencent.com
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dave Chinner <david@fromorbit.com>, Qi Zheng <qi.zheng@linux.dev>,
	Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Bingfang Guo <bfguo@icloud.com>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] memcg: base swap charge accounting on memcgid root status
Date: Sat, 19 Sep 2026 10:56:15 +0800	[thread overview]
Message-ID: <BACBDEEA-F7FD-4EC3-81E8-7806289E8762@linux.dev> (raw)
In-Reply-To: <20260918-bingfangguo-memcgid-rework-v1-2-5bbf3220d88f@tencent.com>



> On Sep 18, 2026, at 17:18, Bingfang Guo via B4 Relay <devnull+bingfangguo.tencent.com@kernel.org> wrote:
> 
> From: Bingfang Guo <bingfangguo@tencent.com>
> 
> A private ID currently pins its original memcg, so testing whether the
> ID belongs to root is equivalent to testing whether the resolved memcg
> is root.
> 
> That equivalence will no longer hold when IDs refer to objcgs. A
> non-root ID may resolve to root after reparenting, but its swap entries
> still carry counter charges inherited by root. Skipping their uncharge
> based on the resolved memcg would leave those charges behind.
> 
> Use the private ID's root status to decide whether a swap entry carries
> a counter charge. A root-ID entry carries none, while a non-root-ID
> entry must release its charge even if its current accounting memcg has
> become root.
> 
> This patch adds a new helper to check if the memcgid equals to that of
> the root memcg.  For swap uncharging and v2 swap charging, simply decide
> whether to charge/uncharge memsw or swap counter based on the swap
> memcgid is root or not. For v1 swapout, don't recharge the memsw
> counter, just cancel the charge if the swap memcg ID refers to the root
> memcg.
> 
> This makes memory and swap charging have similar semantics: one relys on
> the objcg's root status, and the other relys on the memcgid's root
> status.
> 
> Signed-off-by: Bingfang Guo <bingfangguo@tencent.com>

Acked-by: Muchun Song <muchun.song@linux.dev>



  reply	other threads:[~2026-09-19  2:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  9:18 [PATCH 0/4] memcg: move memcgid refcount to objcg to unpin dying memcgs Bingfang Guo via B4 Relay
2026-09-18  9:18 ` [PATCH 1/4] memcg: keep swap charging under RCU protection Bingfang Guo via B4 Relay
2026-09-18 12:07   ` Muchun Song
2026-09-18 16:46   ` Shakeel Butt
2026-09-18 17:51     ` Bingfang Guo
2026-09-18  9:18 ` [PATCH 2/4] memcg: base swap charge accounting on memcgid root status Bingfang Guo via B4 Relay
2026-09-19  2:56   ` Muchun Song [this message]
2026-09-18  9:18 ` [PATCH 3/4] memcg: manipulate memcg private ID references by ID Bingfang Guo via B4 Relay
2026-09-18 18:14   ` Shakeel Butt
2026-09-18 18:46     ` Bingfang Guo
2026-09-18 20:24       ` Shakeel Butt
2026-09-19  3:06   ` Muchun Song
2026-09-18  9:18 ` [PATCH 4/4] memcg: move memcg private ID refcount to objcg Bingfang Guo via B4 Relay
2026-09-18 18:19   ` Shakeel Butt
2026-09-18 19:14     ` Bingfang Guo
2026-09-19  3:32   ` Muchun Song

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=BACBDEEA-F7FD-4EC3-81E8-7806289E8762@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=bfguo@icloud.com \
    --cc=bingfangguo@tencent.com \
    --cc=cgroups@vger.kernel.org \
    --cc=david@fromorbit.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --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=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.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

all inboxes | Powered by JetHome®