Re: [PATCH] mm: zswap: honor zero cgroup limits after successful reclaim
From: Yosry Ahmed
Date: Thu Nov 12 2026 - 11:38:44 EST
On Thu, Nov 12, 2026 at 7:45 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
>
> On Wed, Nov 11, 2026 at 5:55 PM Tomás Senart <ts@xxxxxxxxxxx> wrote:
> >
> > On Thu, Nov 12, 2026 at 12:28 AM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> > > Why is that a problem? Setting memory.zswap.max to 0 while the cgroup
> > > has active swapping processes is naturally racy. The limit can be set
> > > to 0 right after we check it again anyway?
> >
> > Agreed on the race, this doesn't try to fix it.
> >
> > The case here is different: with the limit already at 0, every store
> > writes back an old entry and then stores the new page anyway, until
> > the pool drains. It's bounded, so if it's not worth a special case,
> > happy to drop it.
>
> Yeah I don't think zswap.max = 0 is special here. We can violate the
> limit by changing zswap.max to a value lower than zswap.current. In
> future zswap_store() attempt, we will let it proceed if it shrinks at
> least one page.
Yeah if we will handle this, we should check the limits again instead
of special casing zswap.max = 0, but I am not sure if it's worth
fixing. The simple way would be calling obj_cgroup_may_zswap() again,
but more efficiently we can have obj_cgroup_may_zswap() output the
difference between the limit and current usage, or have a "try charge"
API that handles this internally.