1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Internal slab definitions
7 void __init kmem_cache_init(void);
9 /* Reuses the bits in struct page */
11 unsigned long __page_flags;
13 #if defined(CONFIG_SLAB)
15 struct kmem_cache *slab_cache;
18 struct list_head slab_list;
19 void *freelist; /* array of free object indexes */
20 void *s_mem; /* first object */
22 struct rcu_head rcu_head;
26 #elif defined(CONFIG_SLUB)
28 struct kmem_cache *slab_cache;
32 struct list_head slab_list;
33 #ifdef CONFIG_SLUB_CPU_PARTIAL
36 int slabs; /* Nr of slabs left */
40 /* Double-word boundary */
41 void *freelist; /* first free object */
43 unsigned long counters;
51 struct rcu_head rcu_head;
53 unsigned int __unused;
55 #elif defined(CONFIG_SLOB)
57 struct list_head slab_list;
59 void *freelist; /* first free block */
61 unsigned int __unused_2;
64 #error "Unexpected slab allocator configured"
67 atomic_t __page_refcount;
69 unsigned long memcg_data;
73 #define SLAB_MATCH(pg, sl) \
74 static_assert(offsetof(struct page, pg) == offsetof(struct slab, sl))
75 SLAB_MATCH(flags, __page_flags);
77 SLAB_MATCH(compound_head, slab_cache); /* Ensure bit 0 is clear */
79 SLAB_MATCH(compound_head, slab_list); /* Ensure bit 0 is clear */
81 SLAB_MATCH(_refcount, __page_refcount);
83 SLAB_MATCH(memcg_data, memcg_data);
86 static_assert(sizeof(struct slab) <= sizeof(struct page));
87 #if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && defined(CONFIG_SLUB)
88 static_assert(IS_ALIGNED(offsetof(struct slab, freelist), 2*sizeof(void *)));
92 * folio_slab - Converts from folio to slab.
95 * Currently struct slab is a different representation of a folio where
96 * folio_test_slab() is true.
98 * Return: The slab which contains this folio.
100 #define folio_slab(folio) (_Generic((folio), \
101 const struct folio *: (const struct slab *)(folio), \
102 struct folio *: (struct slab *)(folio)))
105 * slab_folio - The folio allocated for a slab
108 * Slabs are allocated as folios that contain the individual objects and are
109 * using some fields in the first struct page of the folio - those fields are
110 * now accessed by struct slab. It is occasionally necessary to convert back to
111 * a folio in order to communicate with the rest of the mm. Please use this
112 * helper function instead of casting yourself, as the implementation may change
115 #define slab_folio(s) (_Generic((s), \
116 const struct slab *: (const struct folio *)s, \
117 struct slab *: (struct folio *)s))
120 * page_slab - Converts from first struct page to slab.
121 * @p: The first (either head of compound or single) page of slab.
123 * A temporary wrapper to convert struct page to struct slab in situations where
124 * we know the page is the compound head, or single order-0 page.
126 * Long-term ideally everything would work with struct slab directly or go
127 * through folio to struct slab.
129 * Return: The slab which contains this page
131 #define page_slab(p) (_Generic((p), \
132 const struct page *: (const struct slab *)(p), \
133 struct page *: (struct slab *)(p)))
136 * slab_page - The first struct page allocated for a slab
139 * A convenience wrapper for converting slab to the first struct page of the
140 * underlying folio, to communicate with code not yet converted to folio or
143 #define slab_page(s) folio_page(slab_folio(s), 0)
146 * If network-based swap is enabled, sl*b must keep track of whether pages
147 * were allocated from pfmemalloc reserves.
149 static inline bool slab_test_pfmemalloc(const struct slab *slab)
151 return folio_test_active((struct folio *)slab_folio(slab));
154 static inline void slab_set_pfmemalloc(struct slab *slab)
156 folio_set_active(slab_folio(slab));
159 static inline void slab_clear_pfmemalloc(struct slab *slab)
161 folio_clear_active(slab_folio(slab));
164 static inline void __slab_clear_pfmemalloc(struct slab *slab)
166 __folio_clear_active(slab_folio(slab));
169 static inline void *slab_address(const struct slab *slab)
171 return folio_address(slab_folio(slab));
174 static inline int slab_nid(const struct slab *slab)
176 return folio_nid(slab_folio(slab));
179 static inline pg_data_t *slab_pgdat(const struct slab *slab)
181 return folio_pgdat(slab_folio(slab));
184 static inline struct slab *virt_to_slab(const void *addr)
186 struct folio *folio = virt_to_folio(addr);
188 if (!folio_test_slab(folio))
191 return folio_slab(folio);
194 static inline int slab_order(const struct slab *slab)
196 return folio_order((struct folio *)slab_folio(slab));
199 static inline size_t slab_size(const struct slab *slab)
201 return PAGE_SIZE << slab_order(slab);
206 * Common fields provided in kmem_cache by all slab allocators
207 * This struct is either used directly by the allocator (SLOB)
208 * or the allocator must include definitions for all fields
209 * provided in kmem_cache_common in their definition of kmem_cache.
211 * Once we can do anonymous structs (C11 standard) we could put a
212 * anonymous struct definition in these allocators so that the
213 * separate allocations in the kmem_cache structure of SLAB and
214 * SLUB is no longer needed.
217 unsigned int object_size;/* The original size of the object */
218 unsigned int size; /* The aligned/padded/added on size */
219 unsigned int align; /* Alignment as calculated */
220 slab_flags_t flags; /* Active flags on the slab */
221 const char *name; /* Slab name for sysfs */
222 int refcount; /* Use counter */
223 void (*ctor)(void *); /* Called on object slot creation */
224 struct list_head list; /* List of all slab caches on the system */
227 #endif /* CONFIG_SLOB */
230 #include <linux/slab_def.h>
234 #include <linux/slub_def.h>
237 #include <linux/memcontrol.h>
238 #include <linux/fault-inject.h>
239 #include <linux/kasan.h>
240 #include <linux/kmemleak.h>
241 #include <linux/random.h>
242 #include <linux/sched/mm.h>
243 #include <linux/list_lru.h>
246 * State of the slab allocator.
248 * This is used to describe the states of the allocator during bootup.
249 * Allocators use this to gradually bootstrap themselves. Most allocators
250 * have the problem that the structures used for managing slab caches are
251 * allocated from slab caches themselves.
254 DOWN, /* No slab functionality yet */
255 PARTIAL, /* SLUB: kmem_cache_node available */
256 PARTIAL_NODE, /* SLAB: kmalloc size for node struct available */
257 UP, /* Slab caches usable but not all extras yet */
258 FULL /* Everything is working */
261 extern enum slab_state slab_state;
263 /* The slab cache mutex protects the management structures during changes */
264 extern struct mutex slab_mutex;
266 /* The list of all slab caches on the system */
267 extern struct list_head slab_caches;
269 /* The slab cache that manages slab cache information */
270 extern struct kmem_cache *kmem_cache;
272 /* A table of kmalloc cache names and sizes */
273 extern const struct kmalloc_info_struct {
274 const char *name[NR_KMALLOC_TYPES];
279 /* Kmalloc array related functions */
280 void setup_kmalloc_cache_index_table(void);
281 void create_kmalloc_caches(slab_flags_t);
283 /* Find the kmalloc slab corresponding for a certain size */
284 struct kmem_cache *kmalloc_slab(size_t, gfp_t);
286 void *__kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags,
287 int node, size_t orig_size,
288 unsigned long caller);
289 void __kmem_cache_free(struct kmem_cache *s, void *x, unsigned long caller);
292 gfp_t kmalloc_fix_flags(gfp_t flags);
294 /* Functions provided by the slab allocators */
295 int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags);
297 struct kmem_cache *create_kmalloc_cache(const char *name, unsigned int size,
298 slab_flags_t flags, unsigned int useroffset,
299 unsigned int usersize);
300 extern void create_boot_cache(struct kmem_cache *, const char *name,
301 unsigned int size, slab_flags_t flags,
302 unsigned int useroffset, unsigned int usersize);
304 int slab_unmergeable(struct kmem_cache *s);
305 struct kmem_cache *find_mergeable(unsigned size, unsigned align,
306 slab_flags_t flags, const char *name, void (*ctor)(void *));
309 __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
310 slab_flags_t flags, void (*ctor)(void *));
312 slab_flags_t kmem_cache_flags(unsigned int object_size,
313 slab_flags_t flags, const char *name);
315 static inline struct kmem_cache *
316 __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
317 slab_flags_t flags, void (*ctor)(void *))
320 static inline slab_flags_t kmem_cache_flags(unsigned int object_size,
321 slab_flags_t flags, const char *name)
327 static inline bool is_kmalloc_cache(struct kmem_cache *s)
330 return (s->flags & SLAB_KMALLOC);
336 /* Legal flag mask for kmem_cache_create(), for various configurations */
337 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \
338 SLAB_CACHE_DMA32 | SLAB_PANIC | \
339 SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS )
341 #if defined(CONFIG_DEBUG_SLAB)
342 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
343 #elif defined(CONFIG_SLUB_DEBUG)
344 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
345 SLAB_TRACE | SLAB_CONSISTENCY_CHECKS)
347 #define SLAB_DEBUG_FLAGS (0)
350 #if defined(CONFIG_SLAB)
351 #define SLAB_CACHE_FLAGS (SLAB_MEM_SPREAD | SLAB_NOLEAKTRACE | \
352 SLAB_RECLAIM_ACCOUNT | SLAB_TEMPORARY | \
354 #elif defined(CONFIG_SLUB)
355 #define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \
356 SLAB_TEMPORARY | SLAB_ACCOUNT | \
357 SLAB_NO_USER_FLAGS | SLAB_KMALLOC)
359 #define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE)
362 /* Common flags available with current configuration */
363 #define CACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS | SLAB_CACHE_FLAGS)
365 /* Common flags permitted for kmem_cache_create */
366 #define SLAB_FLAGS_PERMITTED (SLAB_CORE_FLAGS | \
371 SLAB_CONSISTENCY_CHECKS | \
374 SLAB_RECLAIM_ACCOUNT | \
380 bool __kmem_cache_empty(struct kmem_cache *);
381 int __kmem_cache_shutdown(struct kmem_cache *);
382 void __kmem_cache_release(struct kmem_cache *);
383 int __kmem_cache_shrink(struct kmem_cache *);
384 void slab_kmem_cache_release(struct kmem_cache *);
390 unsigned long active_objs;
391 unsigned long num_objs;
392 unsigned long active_slabs;
393 unsigned long num_slabs;
394 unsigned long shared_avail;
396 unsigned int batchcount;
398 unsigned int objects_per_slab;
399 unsigned int cache_order;
402 void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo);
403 void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s);
404 ssize_t slabinfo_write(struct file *file, const char __user *buffer,
405 size_t count, loff_t *ppos);
407 static inline enum node_stat_item cache_vmstat_idx(struct kmem_cache *s)
409 return (s->flags & SLAB_RECLAIM_ACCOUNT) ?
410 NR_SLAB_RECLAIMABLE_B : NR_SLAB_UNRECLAIMABLE_B;
413 #ifdef CONFIG_SLUB_DEBUG
414 #ifdef CONFIG_SLUB_DEBUG_ON
415 DECLARE_STATIC_KEY_TRUE(slub_debug_enabled);
417 DECLARE_STATIC_KEY_FALSE(slub_debug_enabled);
419 extern void print_tracking(struct kmem_cache *s, void *object);
420 long validate_slab_cache(struct kmem_cache *s);
421 static inline bool __slub_debug_enabled(void)
423 return static_branch_unlikely(&slub_debug_enabled);
426 static inline void print_tracking(struct kmem_cache *s, void *object)
429 static inline bool __slub_debug_enabled(void)
436 * Returns true if any of the specified slub_debug flags is enabled for the
437 * cache. Use only for flags parsed by setup_slub_debug() as it also enables
440 static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags)
442 if (IS_ENABLED(CONFIG_SLUB_DEBUG))
443 VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS));
444 if (__slub_debug_enabled())
445 return s->flags & flags;
449 #ifdef CONFIG_MEMCG_KMEM
451 * slab_objcgs - get the object cgroups vector associated with a slab
452 * @slab: a pointer to the slab struct
454 * Returns a pointer to the object cgroups vector associated with the slab,
455 * or NULL if no such vector has been associated yet.
457 static inline struct obj_cgroup **slab_objcgs(struct slab *slab)
459 unsigned long memcg_data = READ_ONCE(slab->memcg_data);
461 VM_BUG_ON_PAGE(memcg_data && !(memcg_data & MEMCG_DATA_OBJCGS),
463 VM_BUG_ON_PAGE(memcg_data & MEMCG_DATA_KMEM, slab_page(slab));
465 return (struct obj_cgroup **)(memcg_data & ~MEMCG_DATA_FLAGS_MASK);
468 int memcg_alloc_slab_cgroups(struct slab *slab, struct kmem_cache *s,
469 gfp_t gfp, bool new_slab);
470 void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat,
471 enum node_stat_item idx, int nr);
473 static inline void memcg_free_slab_cgroups(struct slab *slab)
475 kfree(slab_objcgs(slab));
476 slab->memcg_data = 0;
479 static inline size_t obj_full_size(struct kmem_cache *s)
482 * For each accounted object there is an extra space which is used
483 * to store obj_cgroup membership. Charge it too.
485 return s->size + sizeof(struct obj_cgroup *);
489 * Returns false if the allocation should fail.
491 static inline bool memcg_slab_pre_alloc_hook(struct kmem_cache *s,
492 struct list_lru *lru,
493 struct obj_cgroup **objcgp,
494 size_t objects, gfp_t flags)
496 struct obj_cgroup *objcg;
498 if (!memcg_kmem_online())
501 if (!(flags & __GFP_ACCOUNT) && !(s->flags & SLAB_ACCOUNT))
504 objcg = get_obj_cgroup_from_current();
510 struct mem_cgroup *memcg;
512 memcg = get_mem_cgroup_from_objcg(objcg);
513 ret = memcg_list_lru_alloc(memcg, lru, flags);
514 css_put(&memcg->css);
520 if (obj_cgroup_charge(objcg, flags, objects * obj_full_size(s)))
526 obj_cgroup_put(objcg);
530 static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
531 struct obj_cgroup *objcg,
532 gfp_t flags, size_t size,
539 if (!memcg_kmem_online() || !objcg)
542 for (i = 0; i < size; i++) {
544 slab = virt_to_slab(p[i]);
546 if (!slab_objcgs(slab) &&
547 memcg_alloc_slab_cgroups(slab, s, flags,
549 obj_cgroup_uncharge(objcg, obj_full_size(s));
553 off = obj_to_index(s, slab, p[i]);
554 obj_cgroup_get(objcg);
555 slab_objcgs(slab)[off] = objcg;
556 mod_objcg_state(objcg, slab_pgdat(slab),
557 cache_vmstat_idx(s), obj_full_size(s));
559 obj_cgroup_uncharge(objcg, obj_full_size(s));
562 obj_cgroup_put(objcg);
565 static inline void memcg_slab_free_hook(struct kmem_cache *s, struct slab *slab,
566 void **p, int objects)
568 struct obj_cgroup **objcgs;
571 if (!memcg_kmem_online())
574 objcgs = slab_objcgs(slab);
578 for (i = 0; i < objects; i++) {
579 struct obj_cgroup *objcg;
582 off = obj_to_index(s, slab, p[i]);
588 obj_cgroup_uncharge(objcg, obj_full_size(s));
589 mod_objcg_state(objcg, slab_pgdat(slab), cache_vmstat_idx(s),
591 obj_cgroup_put(objcg);
595 #else /* CONFIG_MEMCG_KMEM */
596 static inline struct obj_cgroup **slab_objcgs(struct slab *slab)
601 static inline struct mem_cgroup *memcg_from_slab_obj(void *ptr)
606 static inline int memcg_alloc_slab_cgroups(struct slab *slab,
607 struct kmem_cache *s, gfp_t gfp,
613 static inline void memcg_free_slab_cgroups(struct slab *slab)
617 static inline bool memcg_slab_pre_alloc_hook(struct kmem_cache *s,
618 struct list_lru *lru,
619 struct obj_cgroup **objcgp,
620 size_t objects, gfp_t flags)
625 static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
626 struct obj_cgroup *objcg,
627 gfp_t flags, size_t size,
632 static inline void memcg_slab_free_hook(struct kmem_cache *s, struct slab *slab,
633 void **p, int objects)
636 #endif /* CONFIG_MEMCG_KMEM */
639 static inline struct kmem_cache *virt_to_cache(const void *obj)
643 slab = virt_to_slab(obj);
644 if (WARN_ONCE(!slab, "%s: Object is not a Slab page!\n",
647 return slab->slab_cache;
650 static __always_inline void account_slab(struct slab *slab, int order,
651 struct kmem_cache *s, gfp_t gfp)
653 if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
654 memcg_alloc_slab_cgroups(slab, s, gfp, true);
656 mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s),
660 static __always_inline void unaccount_slab(struct slab *slab, int order,
661 struct kmem_cache *s)
663 if (memcg_kmem_online())
664 memcg_free_slab_cgroups(slab);
666 mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s),
667 -(PAGE_SIZE << order));
670 static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
672 struct kmem_cache *cachep;
674 if (!IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) &&
675 !kmem_cache_debug_flags(s, SLAB_CONSISTENCY_CHECKS))
678 cachep = virt_to_cache(x);
679 if (WARN(cachep && cachep != s,
680 "%s: Wrong slab cache. %s but object is from %s\n",
681 __func__, s->name, cachep->name))
682 print_tracking(cachep, x);
686 void free_large_kmalloc(struct folio *folio, void *object);
688 #endif /* CONFIG_SLOB */
690 size_t __ksize(const void *objp);
692 static inline size_t slab_ksize(const struct kmem_cache *s)
695 return s->object_size;
697 #else /* CONFIG_SLUB */
698 # ifdef CONFIG_SLUB_DEBUG
700 * Debugging requires use of the padding between object
701 * and whatever may come after it.
703 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON))
704 return s->object_size;
706 if (s->flags & SLAB_KASAN)
707 return s->object_size;
709 * If we have the need to store the freelist pointer
710 * back there or track user information then we can
711 * only use the space before that information.
713 if (s->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_STORE_USER))
716 * Else we can use all the padding etc for the allocation
722 static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
723 struct list_lru *lru,
724 struct obj_cgroup **objcgp,
725 size_t size, gfp_t flags)
727 flags &= gfp_allowed_mask;
731 if (should_failslab(s, flags))
734 if (!memcg_slab_pre_alloc_hook(s, lru, objcgp, size, flags))
740 static inline void slab_post_alloc_hook(struct kmem_cache *s,
741 struct obj_cgroup *objcg, gfp_t flags,
742 size_t size, void **p, bool init,
743 unsigned int orig_size)
745 unsigned int zero_size = s->object_size;
748 flags &= gfp_allowed_mask;
751 * For kmalloc object, the allocated memory size(object_size) is likely
752 * larger than the requested size(orig_size). If redzone check is
753 * enabled for the extra space, don't zero it, as it will be redzoned
754 * soon. The redzone operation for this extra space could be seen as a
755 * replacement of current poisoning under certain debug option, and
756 * won't break other sanity checks.
758 if (kmem_cache_debug_flags(s, SLAB_STORE_USER | SLAB_RED_ZONE) &&
759 (s->flags & SLAB_KMALLOC))
760 zero_size = orig_size;
763 * As memory initialization might be integrated into KASAN,
764 * kasan_slab_alloc and initialization memset must be
765 * kept together to avoid discrepancies in behavior.
767 * As p[i] might get tagged, memset and kmemleak hook come after KASAN.
769 for (i = 0; i < size; i++) {
770 p[i] = kasan_slab_alloc(s, p[i], flags, init);
771 if (p[i] && init && !kasan_has_integrated_init())
772 memset(p[i], 0, zero_size);
773 kmemleak_alloc_recursive(p[i], s->object_size, 1,
775 kmsan_slab_alloc(s, p[i], flags);
778 memcg_slab_post_alloc_hook(s, objcg, flags, size, p);
783 * The slab lists for all objects.
785 struct kmem_cache_node {
787 raw_spinlock_t list_lock;
788 struct list_head slabs_partial; /* partial list first, better asm code */
789 struct list_head slabs_full;
790 struct list_head slabs_free;
791 unsigned long total_slabs; /* length of all slab lists */
792 unsigned long free_slabs; /* length of free slab list only */
793 unsigned long free_objects;
794 unsigned int free_limit;
795 unsigned int colour_next; /* Per-node cache coloring */
796 struct array_cache *shared; /* shared per node */
797 struct alien_cache **alien; /* on other nodes */
798 unsigned long next_reap; /* updated without locking */
799 int free_touched; /* updated without locking */
803 spinlock_t list_lock;
804 unsigned long nr_partial;
805 struct list_head partial;
806 #ifdef CONFIG_SLUB_DEBUG
807 atomic_long_t nr_slabs;
808 atomic_long_t total_objects;
809 struct list_head full;
815 static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
817 return s->node[node];
821 * Iterator over all nodes. The body will be executed for each node that has
822 * a kmem_cache_node structure allocated (which is true for all online nodes)
824 #define for_each_kmem_cache_node(__s, __node, __n) \
825 for (__node = 0; __node < nr_node_ids; __node++) \
826 if ((__n = get_node(__s, __node)))
830 #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG)
831 void dump_unreclaimable_slab(void);
833 static inline void dump_unreclaimable_slab(void)
838 void ___cache_free(struct kmem_cache *cache, void *x, unsigned long addr);
840 #ifdef CONFIG_SLAB_FREELIST_RANDOM
841 int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count,
843 void cache_random_seq_destroy(struct kmem_cache *cachep);
845 static inline int cache_random_seq_create(struct kmem_cache *cachep,
846 unsigned int count, gfp_t gfp)
850 static inline void cache_random_seq_destroy(struct kmem_cache *cachep) { }
851 #endif /* CONFIG_SLAB_FREELIST_RANDOM */
853 static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c)
855 if (static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON,
859 if (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))
860 return flags & __GFP_ZERO;
863 return flags & __GFP_ZERO;
866 static inline bool slab_want_init_on_free(struct kmem_cache *c)
868 if (static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON,
871 (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)));
875 #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_SLUB_DEBUG)
876 void debugfs_slab_release(struct kmem_cache *);
878 static inline void debugfs_slab_release(struct kmem_cache *s) { }
882 #define KS_ADDRS_COUNT 16
883 struct kmem_obj_info {
885 struct slab *kp_slab;
887 unsigned long kp_data_offset;
888 struct kmem_cache *kp_slab_cache;
890 void *kp_stack[KS_ADDRS_COUNT];
891 void *kp_free_stack[KS_ADDRS_COUNT];
893 void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab);
896 #ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR
897 void __check_heap_object(const void *ptr, unsigned long n,
898 const struct slab *slab, bool to_user);
901 void __check_heap_object(const void *ptr, unsigned long n,
902 const struct slab *slab, bool to_user)
907 #ifdef CONFIG_SLUB_DEBUG
908 void skip_orig_size_check(struct kmem_cache *s, const void *object);
911 #endif /* MM_SLAB_H */