Re: [PATCH v7 4/4] mm: swap: filter swap allocation by memcg tier mask

From: YoungJun Park

Date: Sun May 31 2026 - 23:50:42 EST


On Sat, May 30, 2026 at 11:21:12AM -0700, Nhat Pham wrote:
> On Sat, May 30, 2026 at 10:51 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
> >
> >
> > How expensive is it to add per-cpu caching for each device :(
>
> to clarify - a percpu_swap_cluster per si for every si.
>
> >
>
> ... or for each tier (assuming devices in each tier share the same
> performance characteristics, and could be used interchangeably?).
>
> Basically:
>
> struct percpu_swap_cluster {
> struct swap_info_struct *si[MAX_SWAPTIER][SWAP_NR_ORDERS];
> unsigned long offset[MAX_SWAPTIER][SWAP_NR_ORDERS];
> local_lock_t lock;
> };
>
> Seems like 4 is the default number of tier right? So the extra
> overhead is just (nr cpu) * 10 * 3 * (sizeof(unsigned long) +
> sizeof(*ptr)) or wev?

I agree. I actually considered the idea of a tier-centric cache as well.

You might remember that in the previous "per cgroup swap priority"
patchset, I implemented per-cpu caches per priority, which is essentially
the same as having them per tier.

However, as you agreed in another thread, including this optimization
right now might be a bit premature. If the core swap tier idea gets
merged, I plan to explore this optimization further as follow-up work.

Thanks
Youngjun Park