mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations.patch removed from -mm tree
The patch titled
Subject: mm: memcg/slab: use a single set of kmem_caches for all allocations
has been removed from the -mm tree. Its filename was
mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Roman Gushchin <[email protected]>
Subject: mm: memcg/slab: use a single set of kmem_caches for all allocations
Instead of having two sets of kmem_caches: one for system-wide and non-accounted allocations and the second one shared by all accounted allocations, we can use just one.
The idea is simple: space for obj_cgroup metadata can be allocated on demand and filled only for accounted allocations.
It allows to remove a bunch of code which is required to handle kmem_cache clones for accounted allocations. There is no more need to create them, accumulate statistics, propagate attributes, etc. It's a quite significant simplification.
Also, because the total number of slab_caches is reduced almost twice (not all kmem_caches have a memcg clone), some additional memory savings are expected. On my devvm it additionally saves about 3.5% of slab memory.
---
include/linux/slab.h | 2 include/linux/slab_def.h | 3 include/linux/slub_def.h | 10 - mm/memcontrol.c | 25 +++- mm/slab.c | 41 ------ mm/slab.h | 196 ++++++------------------------- mm/slab_common.c | 230 ------------------------------------- mm/slub.c | 163 -------------------------- 8 files changed, 79 insertions(+), 591 deletions(-)
include/linux/slab_def.h renamed from include/linux/slab_def.h~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +0 -3
@@ -72,9 +72,6 @@ struct kmem_cache {int obj_offset;#endif /* CONFIG_DEBUG_SLAB */ -#ifdef CONFIG_MEMCG -struct memcg_cache_params memcg_params; -#endif #ifdef CONFIG_KASAN struct kasan_cache kasan_info;#endif
include/linux/slab.h renamed from include/linux/slab.h~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +0 -2
@@ -155,8 +155,6 @@ struct kmem_cache *kmem_cache_create_usevoid kmem_cache_destroy (struct kmem_cache *);int kmem_cache_shrink (struct kmem_cache *); -void memcg_create_kmem_cache (struct kmem_cache *cachep); -/* * Please use this macro to create slab caches. Simply specify the * name of the structure and maybe some flags that are listed above.
include/linux/slub_def.h renamed from include/linux/slub_def.h~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +0 -10
@@ -108,17 +108,7 @@ struct kmem_cache {struct list_head list;/* List of slab caches */ #ifdef CONFIG_SYSFS struct kobject kobj;/* For sysfs */ -struct work_struct kobj_remove_work;#endif -#ifdef CONFIG_MEMCG -struct memcg_cache_params memcg_params; -/* For propagation, maximum size of a stored attr */ -unsigned int max_attr_size; -#ifdef CONFIG_SYSFS -struct kset *memcg_kset; -#endif -#endif -#ifdef CONFIG_SLAB_FREELIST_HARDENED unsigned long random;#endif
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +24 -1
@@ -2800,6 +2800,26 @@ static void commit_charge(struct page *p }#ifdef CONFIG_MEMCG_KMEM +int memcg_alloc_page_obj_cgroups (struct page *page,struct kmem_cache *s, +gfp_t gfp) +{ +unsigned int objects =objs_per_slab_page (s, page); +void *vec; + + vec =kcalloc_node (objects,sizeof (struct obj_cgroup *), gfp, +page_to_nid (page)); +if (!vec) +return -ENOMEM ; + +if (cmpxchg (&page->obj_cgroups,NULL , + (struct obj_cgroup **) ((unsigned long )vec |0x1UL ))) +kfree (vec); +else +kmemleak_not_leak (vec); + +return 0 ; +} +/* * Returns a pointer to the memory cgroup to which the kernel object is charged. *
@@ -2826,7 +2846,10 @@ struct mem_cgroup *mem_cgroup_from_obj(v off =obj_to_index (page->slab_cache, page, p); objcg =page_obj_cgroups (page)[off]; -return obj_cgroup_memcg (objcg); +if (objcg) +return obj_cgroup_memcg (objcg); + +return NULL ; }/* All other pages use page->mem_cgroup */
mm/slab.c renamed from mm/slab.c~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +3 -38
65 lines not on this page · raw message
mm/slab_common.c renamed from mm/slab_common.c~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +5 -225
326 lines not on this page · raw message
mm/slab.h renamed from mm/slab.h~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +43 -153
324 lines not on this page · raw message
mm/slub.c renamed from mm/slub.c~mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-allocations +4 -159
254 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
percpu-return-number-of-released-bytes-from-pcpu_free_area.patch mm-memcg-percpu-account-percpu-memory-to-memory-cgroups.patch mm-memcg-percpu-per-memcg-percpu-memory-statistics.patch mm-memcg-percpu-per-memcg-percpu-memory-statistics-v3.patch mm-memcg-charge-memcg-percpu-memory-to-the-parent-cgroup.patch kselftests-cgroup-add-perpcu-memory-accounting-test.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix.patch