[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALvZod79+g39SUbVA+=Z-e_6m7deE1QqA1p8ogKv+Qpn+SwuKg@mail.gmail.com>
Date: Fri, 21 Aug 2020 15:41:41 -0700
From: Shakeel Butt <shakeelb@...gle.com>
To: Roman Gushchin <guro@...com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Linux MM <linux-mm@...ck.org>,
Kernel Team <kernel-team@...com>,
LKML <linux-kernel@...r.kernel.org>,
Dan Schatzberg <dschatzberg@...com>
Subject: Re: [PATCH] mm: rework remote memcg charging API to support nesting
On Fri, Aug 21, 2020 at 2:21 PM Roman Gushchin <guro@...com> wrote:
>
> Currently the remote memcg charging API consists of two functions:
> memalloc_use_memcg() and memalloc_unuse_memcg(), which set and clear
> the memcg value, which overwrites the memcg of the current task.
>
> memalloc_use_memcg(target_memcg);
> <...>
> memalloc_unuse_memcg();
>
> It works perfectly for allocations performed from a normal context,
> however an attempt to call it from an interrupt context or just nest
> two remote charging blocks will lead to an incorrect accounting.
> On exit from the inner block the active memcg will be cleared
> instead of being restored.
>
> memalloc_use_memcg(target_memcg);
>
> memalloc_use_memcg(target_memcg_2);
> <...>
> memalloc_unuse_memcg();
>
> Error: allocation here are charged to the memcg of the current
> process instead of target_memcg.
>
> memalloc_unuse_memcg();
>
> This patch extends the remote charging API by switching to a single
> function: struct mem_cgroup *set_active_memcg(struct mem_cgroup *memcg),
> which sets the new value and returns the old one. So a remote charging
> block will look like:
>
> old_memcg = set_active_memcg(target_memcg);
> <...>
> set_active_memcg(old_memcg);
>
> This patch is heavily based on the patch by Johannes Weiner,
> which can be found here: https://lkml.org/lkml/2020/5/28/806 .
>
> Signed-off-by: Roman Gushchin <guro@...com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Shakeel Butt <shakeelb@...gle.com>
> Cc: Dan Schatzberg <dschatzberg@...com>
Reviewed-by: Shakeel Butt <shakeelb@...gle.com>
Powered by blists - more mailing lists