Re: [REGRESSION] Re: [PATCH 6.1 033/219] memcg: drop kmem.limit_in_bytes

From: Michal Hocko
Date: Mon Sep 25 2023 - 03:40:11 EST


On Fri 22-09-23 09:30:17, Johannes Weiner wrote:
> On Thu, Sep 21, 2023 at 01:21:54PM +0200, Michal Hocko wrote:
> > @@ -3097,6 +3097,7 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
> > static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
> > unsigned int nr_pages)
> > {
> > + struct page_counter *counter;
> > struct mem_cgroup *memcg;
> > int ret;
> >
> > @@ -3107,6 +3108,10 @@ static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
> > goto out;
> >
> > memcg_account_kmem(memcg, nr_pages);
> > +
> > + /* There is no way to set up kmem hard limit so this operation cannot fail */
> > + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
> > + WARN_ON(!page_counter_try_charge(&memcg->kmem, nr_pages, &counter));
>
> This hunk doesn't look quite right.
>
> static void memcg_account_kmem(struct mem_cgroup *memcg, int nr_pages)
> {
> mod_memcg_state(memcg, MEMCG_KMEM, nr_pages);
> if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
> if (nr_pages > 0)
> page_counter_charge(&memcg->kmem, nr_pages);
> else
> page_counter_uncharge(&memcg->kmem, -nr_pages);
> }
> }
>
> Other than that, please add

Good point. I have missed a8c49af3be5f ("memcg: add per-memcg total kernel memory stat")
introduced in 4.18

> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>

Fixed version below. Andrew, it seems we have a good consensus for this.
Could you queue this up and send it to Linus please?
---