From: Shakeel Butt <shakeelb@google.com>
To: Roman Gushchin <guro@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>, Linux MM <linux-mm@kvack.org>,
Kernel Team <kernel-team@fb.com>,
LKML <linux-kernel@vger.kernel.org>,
Dan Schatzberg <dschatzberg@fb.com>
Subject: Re: [PATCH] mm: rework remote memcg charging API to support nesting
Date: Fri, 21 Aug 2020 15:41:41 -0700 [thread overview]
Message-ID: <CALvZod79+g39SUbVA+=Z-e_6m7deE1QqA1p8ogKv+Qpn+SwuKg@mail.gmail.com> (raw)
In-Reply-To: <20200821212056.3769116-1-guro@fb.com>
On Fri, Aug 21, 2020 at 2:21 PM Roman Gushchin <guro@fb.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@fb.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Shakeel Butt <shakeelb@google.com>
> Cc: Dan Schatzberg <dschatzberg@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
prev parent reply other threads:[~2020-08-21 22:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 21:20 Roman Gushchin
2020-08-21 22:41 ` Shakeel Butt [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='CALvZod79+g39SUbVA+=Z-e_6m7deE1QqA1p8ogKv+Qpn+SwuKg@mail.gmail.com' \
--to=shakeelb@google.com \
--cc=akpm@linux-foundation.org \
--cc=dschatzberg@fb.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
/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