From: Muchun Song <muchun.song@linux.dev>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Chinner <david@fromorbit.com>, Qi Zheng <qi.zheng@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org
Subject: Re: [PATCH v2 0/2] mm/shrinker: make per-memcg shrinker units cheaper
Date: Thu, 15 Oct 2026 21:29:37 +0800 [thread overview]
Message-ID: <25784AE4-EE4B-4B15-A436-17F98354C10A@linux.dev> (raw)
In-Reply-To: <84c9e97b-67c0-4c9b-bb7d-81811af8a16b@virtuozzo.com>
> On Oct 15, 2026, at 19:42, Konstantin Khorenko <khorenko@virtuozzo.com> wrote:
>
> On 10/14/26 22:50, Andrew Morton wrote:
>>> On Wed, 14 Oct 2026 16:54:36 +0200 Konstantin Khorenko <khorenko@virtuozzo.com> wrote:
>>>
>>> Every memory cgroup allocates, per NUMA node, one shrinker_info_unit
>>> per 64 memcg-aware shrinker ids up to shrinker_nr_max, whether or not it
>>> ever charges an object to those shrinkers. Every superblock registers
>>> such a shrinker, so the cost is
>>>
>>> memory cgroups x NUMA nodes x shrinker_nr_max / 64 x 1 KiB
>>>
>>> because the unit is 520 bytes and comes from kmalloc-1k.
>>
>> So we could almost halve this just by using a dedicated kmem_cache?
>
> Yeap, a dedicated cache gets approximately the same cost per shrinker id.
> On a 48-CPU box SLUB puts 31 units in an order-2 slab, about 528 bytes each:
>
> ids/unit bytes/unit bytes/id
> today, kmalloc-1k 64 1024 16
> patch 1, kmalloc-512 63 512 ~8.1
> dedicated cache 64 ~528 ~8.3
> dedicated cache, HWCACHE_ALIGN 64 576 9
>
> So the two are ~equal on memory, and the choice is about the code.
>
> I went with 63 ids per unit because the unit then simply fills the
> kmalloc slot it already comes from.
>
> The price is an odd SHRINKER_UNIT_BITS and roundup() instead of round_up(),
> plus the static_assert.
>
> If you prefer the cache, I'm happy to redo patch 1 that way.
> Patch 2 does not care about the unit size.
Please use a dedicated cache, more straightforward for me. But also give some time to maintainers for reviewing the patch 2 before your update.
Thanks.
>
> --
> Best regards,
> Konstantin
>
prev parent reply other threads:[~2026-10-15 13:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 14:54 [PATCH v2 0/2] mm/shrinker: make per-memcg shrinker units cheaper Konstantin Khorenko
2026-10-14 14:54 ` [PATCH v2 1/2] mm/shrinker: size shrinker_info_unit to a power of two Konstantin Khorenko
2026-10-14 14:54 ` [PATCH v2 2/2] mm/shrinker: allocate the per-memcg shrinker units on demand Konstantin Khorenko
2026-10-14 20:50 ` [PATCH v2 0/2] mm/shrinker: make per-memcg shrinker units cheaper Andrew Morton
2026-10-15 11:42 ` Konstantin Khorenko
2026-10-15 13:29 ` Muchun Song [this message]
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=25784AE4-EE4B-4B15-A436-17F98354C10A@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@fromorbit.com \
--cc=hannes@cmpxchg.org \
--cc=khorenko@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
/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