+ memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch added to -mm tree
Subsystems (3)
[email protected]
maintainerSubject: + memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 21 Feb 2014 14:29:16 -0800
The patch titled
Subject: memcg, slab: do not destroy children caches if parent has aliases
has been added to the -mm tree. Its filename is
memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Vladimir Davydov <[email protected]>
Subject: memcg, slab: do not destroy children caches if parent has aliases
Currently we destroy children caches at the very beginning of kmem_cache_destroy(). This is wrong, because the root cache will not necessarily be destroyed in the end - if it has aliases (refcount > 0), kmem_cache_destroy() will simply decrement its refcount and return. In this case, at best we will get a bunch of warnings in dmesg, like this one:
kmem_cache_destroy kmalloc-32:0: Slab cache still has objects
CPU: 1 PID: 7139 Comm: modprobe Tainted: G B W 3.13.0+ #117 Hardware name: ffff88007d7a6368 ffff880039b07e48 ffffffff8168cc2e ffff88007d7a6d68 ffff88007d7a6300 ffff880039b07e68 ffffffff81175e9f 0000000000000000 ffff88007d7a6300 ffff880039b07e98 ffffffff811b67c7 ffff88003e803c00 Call Trace: [<ffffffff8168cc2e>] dump_stack+0x49/0x5b [<ffffffff81175e9f>] kmem_cache_destroy+0xdf/0xf0 [<ffffffff811b67c7>] kmem_cache_destroy_memcg_children+0x97/0xc0 [<ffffffff81175dcf>] kmem_cache_destroy+0xf/0xf0 [<ffffffffa0130b21>] xfs_mru_cache_uninit+0x21/0x30 [xfs] [<ffffffffa01893ea>] exit_xfs_fs+0x2e/0xc44 [xfs] [<ffffffff810eeb58>] SyS_delete_module+0x198/0x1f0 [<ffffffff816994f9>] system_call_fastpath+0x16/0x1b
At worst - if kmem_cache_destroy() will race with an allocation from a memcg cache - the kernel will panic.
This patch fixes this by moving children caches destruction after the check if the cache has aliases. Plus, it forbids destroying a root cache if it still has children caches, because each children cache keeps a reference to its parent.
---
include/linux/memcontrol.h | 6 -- mm/memcontrol.c | 13 ++---- mm/slab_common.c | 75 +++++++++++++++++++++++------------ 3 files changed, 57 insertions(+), 37 deletions(-)
include/linux/memcontrol.h renamed from include/linux/memcontrol.h~memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases +1 -5
@@ -513,7 +513,7 @@ struct kmem_cache * __memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp);void mem_cgroup_destroy_cache (struct kmem_cache *cachep); -void kmem_cache_destroy_memcg_children (struct kmem_cache *s); +int __kmem_cache_destroy_memcg_children (struct kmem_cache *s);/** * memcg_kmem_newpage_charge: verify if a new kmem allocation is allowed.
@@ -667,10 +667,6 @@ memcg_kmem_get_cache(struct kmem_cache * {return cachep; } - -static inline void kmem_cache_destroy_memcg_children (struct kmem_cache *s) -{ -}#endif /* CONFIG_MEMCG_KMEM */ #endif /* _LINUX_MEMCONTROL_H */
mm/memcontrol.c renamed from mm/memcontrol.c~memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases +6 -7
@@ -3420,15 +3420,10 @@ void mem_cgroup_destroy_cache(struct kmeschedule_work (&cachep->memcg_params->destroy); } -void kmem_cache_destroy_memcg_children (struct kmem_cache *s) +int __kmem_cache_destroy_memcg_children (struct kmem_cache *s) {struct kmem_cache *c; -int i; - -if (!s->memcg_params) -return ; -if (!s->memcg_params->is_root_cache) -return ; +int i, failed =0 ;/* * If the cache is being destroyed, we trust that there is no one else
@@ -3462,8 +3457,12 @@ void kmem_cache_destroy_memcg_children(s c->memcg_params->dead = false;cancel_work_sync (&c->memcg_params->destroy);kmem_cache_destroy (c); + +if (cache_from_memcg_idx (s, i)) + failed++; }mutex_unlock (&activate_kmem_mutex); +return failed; }static void mem_cgroup_destroy_all_caches (struct mem_cgroup *memcg)
mm/slab_common.c renamed from mm/slab_common.c~memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases +50 -25
89 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mm-vmscan-respect-numa-policy-mask-when-shrinking-slab-on-direct-reclaim.patch mm-vmscan-move-call-to-shrink_slab-to-shrink_zones.patch mm-vmscan-remove-shrink_control-arg-from-do_try_to_free_pages.patch mm-vmscan-shrink_slab-rename-max_pass-freeable.patch kobject-dont-block-for-each-kobject_uevent.patch kobject-dont-block-for-each-kobject_uevent-v2.patch slub-do-not-drop-slab_mutex-for-sysfs_slab_add.patch memcg-slab-never-try-to-merge-memcg-caches.patch memcg-slab-cleanup-memcg-cache-creation.patch memcg-slab-separate-memcg-vs-root-cache-creation-paths.patch memcg-slab-unregister-cache-from-memcg-before-starting-to-destroy-it.patch memcg-slab-do-not-destroy-children-caches-if-parent-has-aliases.patch slub-adjust-memcg-caches-when-creating-cache-alias.patch slub-rework-sysfs-layout-for-memcg-caches.patch
linux-next.patch