linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Roman Gushchin <guro@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>, Rik van Riel <riel@surriel.com>,
	Shakeel Butt <shakeelb@google.com>,
	Christoph Lameter <cl@linux.com>,
	cgroups@vger.kernel.org, Waiman Long <longman@redhat.com>
Subject: Re: [PATCH v5 6/7] mm: reparent slab memory on cgroup removal
Date: Tue, 28 May 2019 21:33:02 +0300	[thread overview]
Message-ID: <20190528183302.zv75bsxxblc6v4dt@esperanza> (raw)
In-Reply-To: <20190521200735.2603003-7-guro@fb.com>

On Tue, May 21, 2019 at 01:07:34PM -0700, Roman Gushchin wrote:
> Let's reparent memcg slab memory on memcg offlining. This allows us
> to release the memory cgroup without waiting for the last outstanding
> kernel object (e.g. dentry used by another application).
> 
> So instead of reparenting all accounted slab pages, let's do reparent
> a relatively small amount of kmem_caches. Reparenting is performed as
> a part of the deactivation process.
> 
> Since the parent cgroup is already charged, everything we need to do
> is to splice the list of kmem_caches to the parent's kmem_caches list,
> swap the memcg pointer and drop the css refcounter for each kmem_cache
> and adjust the parent's css refcounter. Quite simple.
> 
> Please, note that kmem_cache->memcg_params.memcg isn't a stable
> pointer anymore. It's safe to read it under rcu_read_lock() or
> with slab_mutex held.
> 
> We can race with the slab allocation and deallocation paths. It's not
> a big problem: parent's charge and slab global stats are always
> correct, and we don't care anymore about the child usage and global
> stats. The child cgroup is already offline, so we don't use or show it
> anywhere.
> 
> Local slab stats (NR_SLAB_RECLAIMABLE and NR_SLAB_UNRECLAIMABLE)
> aren't used anywhere except count_shadow_nodes(). But even there it
> won't break anything: after reparenting "nodes" will be 0 on child
> level (because we're already reparenting shrinker lists), and on
> parent level page stats always were 0, and this patch won't change
> anything.
> 
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Reviewed-by: Shakeel Butt <shakeelb@google.com>

This one looks good to me. I can't see why anything could possibly go
wrong after this change.


  reply	other threads:[~2019-05-28 18:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 20:07 [PATCH v5 0/7] mm: reparent slab memory on cgroup removal Roman Gushchin
2019-05-21 20:07 ` [PATCH v5 1/7] mm: postpone kmem_cache memcg pointer initialization to memcg_link_cache() Roman Gushchin
2019-05-28 17:14   ` Vladimir Davydov
2019-05-28 21:56   ` Johannes Weiner
2019-05-21 20:07 ` [PATCH v5 2/7] mm: generalize postponed non-root kmem_cache deactivation Roman Gushchin
2019-05-28 17:11   ` Vladimir Davydov
2019-05-21 20:07 ` [PATCH v5 3/7] mm: introduce __memcg_kmem_uncharge_memcg() Roman Gushchin
2019-05-21 20:07 ` [PATCH v5 4/7] mm: unify SLAB and SLUB page accounting Roman Gushchin
2019-05-28 17:12   ` Vladimir Davydov
2019-05-28 22:00   ` Johannes Weiner
2019-05-21 20:07 ` [PATCH v5 5/7] mm: rework non-root kmem_cache lifecycle management Roman Gushchin
2019-05-28 17:08   ` Vladimir Davydov
2019-05-28 17:37     ` Waiman Long
2019-05-28 17:39       ` Vladimir Davydov
2019-05-28 17:41         ` Waiman Long
2019-05-28 18:00     ` Vladimir Davydov
2019-05-28 22:03   ` Johannes Weiner
2019-05-28 22:28     ` Roman Gushchin
2019-05-21 20:07 ` [PATCH v5 6/7] mm: reparent slab memory on cgroup removal Roman Gushchin
2019-05-28 18:33   ` Vladimir Davydov [this message]
2019-05-28 19:58     ` Roman Gushchin
2019-05-28 20:11       ` Vladimir Davydov
2019-05-28 21:52         ` Roman Gushchin
2019-05-28 22:16       ` Johannes Weiner
2019-05-21 20:07 ` [PATCH v5 7/7] mm: fix /proc/kpagecgroup interface for slab pages Roman Gushchin
2019-05-28 17:38   ` Vladimir Davydov
2019-05-22 21:43 ` [PATCH v5 0/7] mm: reparent slab memory on cgroup removal Roman Gushchin
2019-05-22 21:59   ` Andrew Morton
2019-05-22 22:23     ` Roman Gushchin
2019-05-28  7:01       ` Michal Hocko

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=20190528183302.zv75bsxxblc6v4dt@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=cl@linux.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=longman@redhat.com \
    --cc=mhocko@kernel.org \
    --cc=riel@surriel.com \
    --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).