Skip to content

Commit 71e0425

Browse files
Thadeu Lima de Souza Cascardoianmay81
authored andcommitted
UBUNTU: SAUCE: Revert "mm: memcg/slab: fix memory leak at non-root kmem_cache destroy"
BugLink: https://bugs.launchpad.net/bugs/1894780 This reverts commit 79ffe71. This is commit d38a2b7 upstream. Said commit causes same-sized kmemcaches to become unmergeable, and when a new kmemcache is created, it will fail creating the sysfs entry, making the kmemcache creation to fail. Considering the original commit fix a leak but causes a different leak and failures to create kmemcaches, the revert is preferable until a proper fix is developed. Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Acked-by: Stefan Bader <[email protected]> Acked-by: Ian May <[email protected]> Signed-off-by: Ian May <[email protected]>
1 parent ccce2f9 commit 71e0425

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

mm/slab_common.c

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,6 @@ int slab_unmergeable(struct kmem_cache *s)
326326
if (s->refcount < 0)
327327
return 1;
328328

329-
#ifdef CONFIG_MEMCG_KMEM
330-
/*
331-
* Skip the dying kmem_cache.
332-
*/
333-
if (s->memcg_params.dying)
334-
return 1;
335-
#endif
336-
337329
return 0;
338330
}
339331

@@ -894,15 +886,12 @@ static int shutdown_memcg_caches(struct kmem_cache *s)
894886
return 0;
895887
}
896888

897-
static void memcg_set_kmem_cache_dying(struct kmem_cache *s)
889+
static void flush_memcg_workqueue(struct kmem_cache *s)
898890
{
899891
spin_lock_irq(&memcg_kmem_wq_lock);
900892
s->memcg_params.dying = true;
901893
spin_unlock_irq(&memcg_kmem_wq_lock);
902-
}
903894

904-
static void flush_memcg_workqueue(struct kmem_cache *s)
905-
{
906895
/*
907896
* SLAB and SLUB deactivate the kmem_caches through call_rcu. Make
908897
* sure all registered rcu callbacks have been invoked.
@@ -934,6 +923,10 @@ static inline int shutdown_memcg_caches(struct kmem_cache *s)
934923
{
935924
return 0;
936925
}
926+
927+
static inline void flush_memcg_workqueue(struct kmem_cache *s)
928+
{
929+
}
937930
#endif /* CONFIG_MEMCG_KMEM */
938931

939932
void slab_kmem_cache_release(struct kmem_cache *s)
@@ -951,6 +944,8 @@ void kmem_cache_destroy(struct kmem_cache *s)
951944
if (unlikely(!s))
952945
return;
953946

947+
flush_memcg_workqueue(s);
948+
954949
get_online_cpus();
955950
get_online_mems();
956951

@@ -960,22 +955,6 @@ void kmem_cache_destroy(struct kmem_cache *s)
960955
if (s->refcount)
961956
goto out_unlock;
962957

963-
#ifdef CONFIG_MEMCG_KMEM
964-
memcg_set_kmem_cache_dying(s);
965-
966-
mutex_unlock(&slab_mutex);
967-
968-
put_online_mems();
969-
put_online_cpus();
970-
971-
flush_memcg_workqueue(s);
972-
973-
get_online_cpus();
974-
get_online_mems();
975-
976-
mutex_lock(&slab_mutex);
977-
#endif
978-
979958
err = shutdown_memcg_caches(s);
980959
if (!err)
981960
err = shutdown_cache(s);

0 commit comments

Comments
 (0)