From: sashiko-bot@kernel.org
To: linuszeng <linuszeng@tencent.com>
Cc: dri-devel@lists.freedesktop.org, hannes@cmpxchg.org,
tj@kernel.org, mkoutny@suse.com
Subject: Re: [PATCH 1/3] mm: page_counter: add page_counter_protection struct and init API
Date: Wed, 09 Sep 2026 08:23:18 +0000 [thread overview]
Message-ID: <20260909082318.C6EDA1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-descriptive-name-v1-1-1828961cb01a@tencent.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing fixup of `prot.parent` linkage when dynamically creating dmem cgroup pools breaks hierarchical protection.
--
commit 534b5f88933b6e08b308d664bd9c8b28861c0c8c
Author: linuszeng <linuszeng@tencent.com>
mm: page_counter: add page_counter_protection struct and init API
This commit extracts the hierarchical protection state (memory.min and
memory.low) from struct page_counter into a new page_counter_protection
structure. It introduces page_counter_init_protection() to attach this
context, saving space for counters that don't support protection.
> diff --git a/kernel/cgroup/dmem.c b/kernel/cgroup/dmem.c
> index 4683f3d680226..e33d807cdea89 100644
> --- a/kernel/cgroup/dmem.c
> +++ b/kernel/cgroup/dmem.c
> @@ -426,8 +427,9 @@ alloc_pool_single(struct dmemcg_state *dmemcs, struct dmem_cgroup_region *region
> if (parent)
> ppool = find_cg_pool_locked(parent, region);
>
> - page_counter_init(&pool->cnt,
> - ppool ? &ppool->cnt : NULL, true);
> + page_counter_init(&pool->cnt, ppool ? &ppool->cnt : NULL);
> + page_counter_init_protection(&pool->cnt, &pool->prot,
> + ppool ? &ppool->prot : NULL);
> reset_all_resource_limits(pool);
> refcount_set(&pool->ref, 1);
> kref_get(®ion->ref);
[Severity: High]
Does get_cg_pool_locked() also need to be updated to fix up the prot.parent
linkage?
When alloc_pool_single() is called during a bottom-up dynamic pool creation,
ppool can be NULL. This sets pool->prot.parent to NULL here. Later in
get_cg_pool_locked(), the missing parent pools are created and a fixup loop
links the counters:
kernel/cgroup/dmem.c:get_cg_pool_locked() {
...
/* ppool was created if it didn't exist by above loop. */
ppool = find_cg_pool_locked(pp, region);
/* Fix up parent links, mark as inited. */
pool->cnt.parent = &ppool->cnt;
if (ppool && !pool->parent) {
...
}
Because pool->prot.parent = &ppool->prot; is missing in this fixup loop,
prot.parent permanently remains NULL. This causes propagate_protected_usage()
to silently abort due to !prot->parent, breaking hierarchical protection
for the dmem cgroup.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-descriptive-name-v1-0-1828961cb01a@tencent.com?part=1
next prev parent reply other threads:[~2026-09-09 8:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 8:08 [PATCH 0/3] mm: page_counter: move hierarchical protection out of struct page_counter linuszeng via B4 Relay
2026-09-09 8:08 ` linuszeng
2026-09-09 8:08 ` [PATCH 1/3] mm: page_counter: add page_counter_protection struct and init API linuszeng via B4 Relay
2026-09-09 8:08 ` linuszeng
2026-09-09 8:23 ` sashiko-bot [this message]
2026-09-09 8:08 ` [PATCH 2/3] mm: page_counter: track protection state in page_counter_protection linuszeng via B4 Relay
2026-09-09 8:08 ` linuszeng
2026-09-09 8:08 ` [PATCH 3/3] mm: page_counter: drop protection fields from struct page_counter linuszeng via B4 Relay
2026-09-09 8:08 ` linuszeng
2026-09-09 8:38 ` sashiko-bot
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=20260909082318.C6EDA1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hannes@cmpxchg.org \
--cc=linuszeng@tencent.com \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@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 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.