slab_common.c (89982f7ccee2fcd8fea7936b81eec6defbf0f131) slab_common.c (84c07d11aa619c6d24c682f469b10f344f0c02aa)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Slab allocator functions that are independent of the allocator strategy
4 *
5 * (C) 2012 Christoph Lameter <cl@linux.com>
6 */
7#include <linux/slab.h>
8

--- 113 unchanged lines hidden (view full) ---

122 if (!x) {
123 __kmem_cache_free_bulk(s, i, p);
124 return 0;
125 }
126 }
127 return i;
128}
129
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Slab allocator functions that are independent of the allocator strategy
4 *
5 * (C) 2012 Christoph Lameter <cl@linux.com>
6 */
7#include <linux/slab.h>
8

--- 113 unchanged lines hidden (view full) ---

122 if (!x) {
123 __kmem_cache_free_bulk(s, i, p);
124 return 0;
125 }
126 }
127 return i;
128}
129
130#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
130#ifdef CONFIG_MEMCG_KMEM
131
132LIST_HEAD(slab_root_caches);
133
134void slab_init_memcg_params(struct kmem_cache *s)
135{
136 s->memcg_params.root_cache = NULL;
137 RCU_INIT_POINTER(s->memcg_params.memcg_caches, NULL);
138 INIT_LIST_HEAD(&s->memcg_params.children);

--- 112 unchanged lines hidden (view full) ---

251
252static inline void destroy_memcg_params(struct kmem_cache *s)
253{
254}
255
256static inline void memcg_unlink_cache(struct kmem_cache *s)
257{
258}
131
132LIST_HEAD(slab_root_caches);
133
134void slab_init_memcg_params(struct kmem_cache *s)
135{
136 s->memcg_params.root_cache = NULL;
137 RCU_INIT_POINTER(s->memcg_params.memcg_caches, NULL);
138 INIT_LIST_HEAD(&s->memcg_params.children);

--- 112 unchanged lines hidden (view full) ---

251
252static inline void destroy_memcg_params(struct kmem_cache *s)
253{
254}
255
256static inline void memcg_unlink_cache(struct kmem_cache *s)
257{
258}
259#endif /* CONFIG_MEMCG && !CONFIG_SLOB */
259#endif /* CONFIG_MEMCG_KMEM */
260
261/*
262 * Figure out what the alignment of the objects will be given a set of
263 * flags, a user specified alignment and the size of the objects.
264 */
265static unsigned int calculate_alignment(slab_flags_t flags,
266 unsigned int align, unsigned int size)
267{

--- 311 unchanged lines hidden (view full) ---

579#else
580 slab_kmem_cache_release(s);
581#endif
582 }
583
584 return 0;
585}
586
260
261/*
262 * Figure out what the alignment of the objects will be given a set of
263 * flags, a user specified alignment and the size of the objects.
264 */
265static unsigned int calculate_alignment(slab_flags_t flags,
266 unsigned int align, unsigned int size)
267{

--- 311 unchanged lines hidden (view full) ---

579#else
580 slab_kmem_cache_release(s);
581#endif
582 }
583
584 return 0;
585}
586
587#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
587#ifdef CONFIG_MEMCG_KMEM
588/*
589 * memcg_create_kmem_cache - Create a cache for a memory cgroup.
590 * @memcg: The memory cgroup the new cache is for.
591 * @root_cache: The parent of the new cache.
592 *
593 * This function attempts to create a kmem cache that will serve allocation
594 * requests going from @memcg to @root_cache. The new cache inherits properties
595 * from its parent.

--- 260 unchanged lines hidden (view full) ---

856static inline int shutdown_memcg_caches(struct kmem_cache *s)
857{
858 return 0;
859}
860
861static inline void flush_memcg_workqueue(struct kmem_cache *s)
862{
863}
588/*
589 * memcg_create_kmem_cache - Create a cache for a memory cgroup.
590 * @memcg: The memory cgroup the new cache is for.
591 * @root_cache: The parent of the new cache.
592 *
593 * This function attempts to create a kmem cache that will serve allocation
594 * requests going from @memcg to @root_cache. The new cache inherits properties
595 * from its parent.

--- 260 unchanged lines hidden (view full) ---

856static inline int shutdown_memcg_caches(struct kmem_cache *s)
857{
858 return 0;
859}
860
861static inline void flush_memcg_workqueue(struct kmem_cache *s)
862{
863}
864#endif /* CONFIG_MEMCG && !CONFIG_SLOB */
864#endif /* CONFIG_MEMCG_KMEM */
865
866void slab_kmem_cache_release(struct kmem_cache *s)
867{
868 __kmem_cache_release(s);
869 destroy_memcg_params(s);
870 kfree_const(s->name);
871 kmem_cache_free(kmem_cache, s);
872}

--- 689 unchanged lines hidden ---
865
866void slab_kmem_cache_release(struct kmem_cache *s)
867{
868 __kmem_cache_release(s);
869 destroy_memcg_params(s);
870 kfree_const(s->name);
871 kmem_cache_free(kmem_cache, s);
872}

--- 689 unchanged lines hidden ---