linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Roman Gushchin <guro@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Dennis Zhou <dennis@kernel.org>, Christoph Lameter <cl@linux.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Shakeel Butt <shakeelb@google.com>,
	linux-mm@kvack.org, kernel-team@fb.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 2/5] mm: memcg/percpu: account percpu memory to memory cgroups
Date: Tue, 26 May 2020 13:31:53 -0400	[thread overview]
Message-ID: <20200526173153.GE83516@mtj.thefacebook.com> (raw)
In-Reply-To: <20200519201806.2308480-3-guro@fb.com>

On Tue, May 19, 2020 at 01:18:03PM -0700, Roman Gushchin wrote:
> Percpu memory is becoming more and more widely used by various
> subsystems, and the total amount of memory controlled by the percpu
> allocator can make a good part of the total memory.
> 
> As an example, bpf maps can consume a lot of percpu memory,
> and they are created by a user. Also, some cgroup internals
> (e.g. memory controller statistics) can be quite large.
> On a machine with many CPUs and big number of cgroups they
> can consume hundreds of megabytes.
> 
> So the lack of memcg accounting is creating a breach in the memory
> isolation. Similar to the slab memory, percpu memory should be
> accounted by default.
> 
> To implement the perpcu accounting it's possible to take the slab
> memory accounting as a model to follow. Let's introduce two types of
> percpu chunks: root and memcg. What makes memcg chunks different is
> an additional space allocated to store memcg membership information.
> If __GFP_ACCOUNT is passed on allocation, a memcg chunk should be be
> used. If it's possible to charge the corresponding size to the target
> memory cgroup, allocation is performed, and the memcg ownership data
> is recorded. System-wide allocations are performed using root chunks,
> so there is no additional memory overhead.
> 
> To implement a fast reparenting of percpu memory on memcg removal,
> we don't store mem_cgroup pointers directly: instead we use obj_cgroup
> API, introduced for slab accounting.

The overall approach makes sense to me but it'd help to have a high level
comment explaining what's going on and why.

Thanks.

-- 
tejun


  reply	other threads:[~2020-05-26 17:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19 20:18 [PATCH RFC 0/5] mm: memcg accounting of percpu memory Roman Gushchin
2020-05-19 20:18 ` [PATCH RFC 1/5] percpu: return number of released bytes from pcpu_free_area() Roman Gushchin
2020-05-19 20:18 ` [PATCH RFC 2/5] mm: memcg/percpu: account percpu memory to memory cgroups Roman Gushchin
2020-05-26 17:31   ` Tejun Heo [this message]
2020-05-27 21:02   ` Dennis Zhou
2020-05-19 20:18 ` [PATCH RFC 3/5] mm: memcg/percpu: per-memcg percpu memory statistics Roman Gushchin
2020-05-19 20:18 ` [PATCH RFC 4/5] mm: memcg: charge memcg percpu memory to the parent cgroup Roman Gushchin
2020-05-19 20:18 ` [PATCH RFC 5/5] kselftests: cgroup: add perpcu memory accounting test Roman Gushchin

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=20200526173153.GE83516@mtj.thefacebook.com \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --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 \
    --cc=shakeelb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).