From: Alexandre Ghiti <alex@ghiti.fr>
To: Nhat Pham <nphamcs@gmail.com>, Usama Arif <usama.arif@linux.dev>
Cc: alexandre@ghiti.fr, Andrew Morton <akpm@linux-foundation.org>,
Barry Song <baohua@kernel.org>, Ben Segall <bsegall@google.com>,
cgroups@vger.kernel.org,
Chengming Zhou <chengming.zhou@linux.dev>,
Christoph Lameter <cl@gentwo.org>,
David Hildenbrand <david@kernel.org>,
Dennis Zhou <dennis@kernel.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Juri Lelli <juri.lelli@redhat.com>,
Kairui Song <kasong@tencent.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
K Prateek Nayak <kprateek.nayak@amd.com>,
"Liam R. Howlett" <liam@infradead.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Lorenzo Stoakes <ljs@kernel.org>, Mel Gorman <mgorman@suse.de>,
Michal Hocko <mhocko@kernel.org>, Mike Rapoport <rppt@kernel.org>,
Minchan Kim <minchan@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Peter Zijlstra <peterz@infradead.org>,
Qi Zheng <qi.zheng@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Steven Rostedt <rostedt@goodmis.org>,
Suren Baghdasaryan <surenb@google.com>, Tejun Heo <tj@kernel.org>,
Valentin Schneider <vschneid@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Vlastimil Babka <vbabka@kernel.org>, Wei Xu <weixugc@google.com>,
Yosry Ahmed <yosry@kernel.org>, Yuanchu Xie <yuanchu@google.com>
Subject: Re: [PATCH v2 9/9] mm: zswap: per-node kmem accounting for zswap/zsmalloc
Date: Mon, 29 Jun 2026 15:38:31 +0200 [thread overview]
Message-ID: <044c3a58-7ed0-46f2-88ca-462691fd0b68@ghiti.fr> (raw)
In-Reply-To: <CAKEwX=OKsjtStcuvhQ3WCGYoTJHT6eagBq1mZqX+DdbLm_BFLQ@mail.gmail.com>
Hi Nhat,
On 6/26/26 20:36, Nhat Pham wrote:
> On Fri, Jun 26, 2026 at 7:32 AM Usama Arif <usama.arif@linux.dev> wrote:
>> On Fri, 26 Jun 2026 12:20:58 +0200 Alexandre Ghiti <alex@ghiti.fr> wrote:
>>
>>> Update zswap and zsmalloc to use per-node obj_cgroup for kmem
>>> accounting, attributing compressed page charges to the correct
>>> NUMA node.
>>>
>>> But actually, this is incomplete because it does not correctly account
>>> for entries that straddle pages, those pages being possibly on 2 different
>>> nodes.
>>>
>>> This will be correctly handled by Joshua in a different series [1].
>>>
>>> Link: https://lore.kernel.org/linux-mm/20260311195153.4013476-1-joshua.hahnjy@gmail.com/ [1]
>>> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
>>> ---
>>> include/linux/zsmalloc.h | 2 ++
>>> mm/zsmalloc.c | 11 +++++++++++
>>> mm/zswap.c | 19 ++++++++++++++++++-
>>> 3 files changed, 31 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h
>>> index 478410c880b1..30427f3fe232 100644
>>> --- a/include/linux/zsmalloc.h
>>> +++ b/include/linux/zsmalloc.h
>>> @@ -50,6 +50,8 @@ void zs_obj_read_sg_end(struct zs_pool *pool, unsigned long handle);
>>> void zs_obj_write(struct zs_pool *pool, unsigned long handle,
>>> void *handle_mem, size_t mem_len);
>>>
>>> +int zs_handle_to_nid(struct zs_pool *pool, unsigned long handle);
>>> +
>>> extern const struct movable_operations zsmalloc_mops;
>>>
>>> #endif
>>> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
>>> index 83f5820c45f9..17f7403ebe77 100644
>>> --- a/mm/zsmalloc.c
>>> +++ b/mm/zsmalloc.c
>>> @@ -1380,6 +1380,17 @@ static void obj_free(int class_size, unsigned long obj)
>>> mod_zspage_inuse(zspage, -1);
>>> }
>>>
>>> +int zs_handle_to_nid(struct zs_pool *pool, unsigned long handle)
>>> +{
>>> + unsigned long obj;
>>> + struct zpdesc *zpdesc;
>>> +
>>> + obj = handle_to_obj(handle);
>>> + obj_to_zpdesc(obj, &zpdesc);
>>> + return page_to_nid(zpdesc_page(zpdesc));
>>> +}
>>> +EXPORT_SYMBOL(zs_handle_to_nid);
>> Does this need the same locking as the other handle-to-zspage paths?
>> zs_free() takes pool->lock before handle_to_obj() because zspage migration can
>> update or move the object behind the handle. This helper does the same decode
>> without the lock, so zswap's uncharge path can race migration and charge or
>> uncharge the wrong node, or observe transient zspage state.
>>
> Can we just charge it to the page's node for now? Once Joshua's patch
> series is in, we can correctly charge the node owning the data :)
Even if this patch accounting is incorrect, it is close to reality,
using the original page's node would give results that are really off no?
>
> FWIW, this is how these zswap entries are organized in the LRU too -
> following to the OG page's node.
Oh, we should do something about that right? Because the compressed data
is not necessarily on the original page's node.
Thanks,
Alex
next prev parent reply other threads:[~2026-06-29 13:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 10:20 [RESEND PATCH v2 0/9] per-memcg-per-node kmem accounting Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 1/9] memcg: convert task->objcg to a per-node objcgs array Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 2/9] memcg: charge kmem pages and slab objects against per-node objcg Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 3/9] mm: percpu: fix obj_exts metadata charge size Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 4/9] mm: percpu: Split memcg charging and kmem accounting Alexandre Ghiti
2026-06-29 19:10 ` Joshua Hahn
2026-06-26 10:20 ` [PATCH v2 5/9] mm: memcontrol: track MEMCG_KMEM per NUMA node Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 6/9] mm: percpu: per-node kmem accounting Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 7/9] mm: percpu: per-node kmem accounting for obj_exts metadata Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 8/9] mm: percpu: skip the per-cpu node walk on single-node systems Alexandre Ghiti
2026-06-26 10:20 ` [PATCH v2 9/9] mm: zswap: per-node kmem accounting for zswap/zsmalloc Alexandre Ghiti
2026-06-26 14:32 ` Usama Arif
2026-06-26 18:36 ` Nhat Pham
2026-06-29 13:38 ` Alexandre Ghiti [this message]
2026-06-29 18:08 ` Nhat Pham
2026-06-29 13:14 ` Alexandre Ghiti
2026-06-29 18:14 ` Nhat Pham
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=044c3a58-7ed0-46f2-88ca-462691fd0b68@ghiti.fr \
--to=alex@ghiti.fr \
--cc=akpm@linux-foundation.org \
--cc=alexandre@ghiti.fr \
--cc=baohua@kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=dennis@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kasong@tencent.com \
--cc=kent.overstreet@linux.dev \
--cc=kprateek.nayak@amd.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
--cc=mingo@redhat.com \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=peterz@infradead.org \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=tj@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=weixugc@google.com \
--cc=yosry@kernel.org \
--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®