linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm 0/8] memcg: reuse per cgroup kmem caches
@ 2014-11-03 20:59 Vladimir Davydov
  2014-11-03 20:59 ` [PATCH -mm 1/8] memcg: do not destroy kmem caches on css offline Vladimir Davydov
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Vladimir Davydov @ 2014-11-03 20:59 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Michal Hocko, Christoph Lameter, Pekka Enberg,
	David Rientjes, Joonsoo Kim, linux-mm, linux-kernel

Hi,

Currently, each kmem active memory cgroup has its own set of kmem
caches. The caches are only used by the memory cgroup they were created
for, so when the cgroup is taken offline they must be destroyed.
However, we can't easily destroy all the caches on css offline, because
they still may contain objects accounted to the cgroup. Actually, we
don't bother destroying busy caches on css offline at all, effectively
leaking them. To make this scheme work as it was intended to, we have to
introduce a kind of asynchronous caches destruction, which is going to
be quite a complex stuff, because we'd have to handle a lot of various
race conditions. And even if we manage to solve them all, kmem caches
created for memory cgroups that are now dead will be dangling
indefinitely long wasting memory.

In this patch set I implement a different approach, which can be
described by the following statements:

 1. Never destroy per memcg kmem caches (except the root cache is
    destroyed, of course).

 2. Reuse kmemcg_id and therefore the set of per memcg kmem caches left
    from a dead memory cgroup.

 3. After allocating a kmem object, check if the slab is accounted to
    the proper (i.e. current) memory cgroup. If it doesn't recharge it.

The benefits are:

 - It's much simpler than what we have now, even though the current
   implementation is incomplete.

 - The number of per cgroup caches of the same kind cannot be be greater
   than the maximal number of online kmem active memory cgroups that
   have ever existed simultaneously. Currently it is unlimited, which is
   really bad.

 - Once a new memory cgroup starts using a cache that was used by a dead
   cgroup before, it will be recharging slabs accounted to the dead
   cgroup while allocating objects from the cache. Therefore all
   references to the old cgroup will be put sooner or later, and it will
   be freed. Currently, cgroups that have kmem objects accounted to them
   on css offline leak for good.

This patch set is based on v3.18-rc2-mmotm-2014-10-29-14-19 with the
following patches by Johannes applied on top:

[patch] mm: memcontrol: remove stale page_cgroup_lock comment
[patch 1/3] mm: embed the memcg pointer directly into struct page
[patch 2/3] mm: page_cgroup: rename file to mm/swap_cgroup.c
[patch 3/3] mm: move page->mem_cgroup bad page handling into generic code

Thanks,

Vladimir Davydov (8):
  memcg: do not destroy kmem caches on css offline
  slab: charge slab pages to the current memory cgroup
  memcg: decouple per memcg kmem cache from the owner memcg
  memcg: zap memcg_{un}register_cache
  memcg: free kmem cache id on css offline
  memcg: introduce memcg_kmem_should_charge helper
  slab: introduce slab_free helper
  slab: recharge slab pages to the allocating memory cgroup

 include/linux/memcontrol.h |   63 ++++++-----
 include/linux/slab.h       |   12 +-
 mm/memcontrol.c            |  260 ++++++++++++++------------------------------
 mm/slab.c                  |   62 +++++++----
 mm/slab.h                  |   28 -----
 mm/slab_common.c           |   66 ++++++++---
 mm/slub.c                  |   26 +++--
 7 files changed, 228 insertions(+), 289 deletions(-)

-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-11-06 15:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03 20:59 [PATCH -mm 0/8] memcg: reuse per cgroup kmem caches Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 1/8] memcg: do not destroy kmem caches on css offline Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 2/8] slab: charge slab pages to the current memory cgroup Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 3/8] memcg: decouple per memcg kmem cache from the owner memcg Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 4/8] memcg: zap memcg_{un}register_cache Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 5/8] memcg: free kmem cache id on css offline Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 6/8] memcg: introduce memcg_kmem_should_charge helper Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 7/8] slab: introduce slab_free helper Vladimir Davydov
2014-11-05 18:42   ` Christoph Lameter
2014-11-06 10:59     ` Vladimir Davydov
2014-11-03 20:59 ` [PATCH -mm 8/8] slab: recharge slab pages to the allocating memory cgroup Vladimir Davydov
2014-11-05 18:43   ` Christoph Lameter
2014-11-06  9:17     ` Vladimir Davydov
2014-11-06 15:01       ` Christoph Lameter
2014-11-06 15:22         ` Vladimir Davydov

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).