Lines Matching defs:s

79 unsigned int kmem_cache_size(struct kmem_cache *s)
81 return s->object_size;
89 struct kmem_cache *s;
91 list_for_each_entry(s, &slab_caches, list) {
92 if (!strcmp(s->name, name))
102 pr_err("kmem_cache_create(%s) integrity check failed\n", name);
108 "kmem_cache of name '%s' already exists\n", name);
151 int slab_unmergeable(struct kmem_cache *s)
153 if (slab_nomerge || (s->flags & SLAB_NEVER_MERGE))
156 if (s->ctor)
160 if (s->usersize)
167 if (s->refcount < 0)
176 struct kmem_cache *s;
193 list_for_each_entry_reverse(s, &slab_caches, list) {
194 if (slab_unmergeable(s))
197 if (size > s->size)
200 if ((flags & SLAB_MERGE_SAME) != (s->flags & SLAB_MERGE_SAME))
206 if ((s->size & ~(align - 1)) != s->size)
209 if (s->size - size >= sizeof(void *))
212 return s;
222 struct kmem_cache *s;
228 /* If a custom freelist pointer is requested make sure it's sane. */
237 s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
238 if (!s)
240 err = do_kmem_cache_create(s, name, object_size, args, flags);
244 s->refcount = 1;
245 list_add(&s->list, &slab_caches);
246 return s;
249 kmem_cache_free(kmem_cache, s);
274 struct kmem_cache *s = NULL;
283 * It's also possible that this is the first cache created with
321 s = __kmem_cache_alias(name, object_size, args->align, flags,
323 if (s)
333 s = create_cache(cache_name, object_size, args, flags);
334 if (IS_ERR(s)) {
335 err = PTR_ERR(s);
344 panic("%s: Failed to create slab '%s'. Error %d\n",
347 pr_warn("%s(%s) failed with error %d\n",
353 return s;
419 cache_name = kasprintf(GFP_KERNEL, "%s-%s", name, short_size + 1);
455 static void kmem_cache_release(struct kmem_cache *s)
457 kfence_shutdown_cache(s);
459 sysfs_slab_release(s);
461 slab_kmem_cache_release(s);
464 void slab_kmem_cache_release(struct kmem_cache *s)
466 __kmem_cache_release(s);
467 kfree_const(s->name);
468 kmem_cache_free(kmem_cache, s);
471 void kmem_cache_destroy(struct kmem_cache *s)
475 if (unlikely(!s) || !kasan_check_byte(s))
478 /* in-flight kfree_rcu()'s may include objects from our cache */
482 (s->flags & SLAB_TYPESAFE_BY_RCU)) {
500 s->refcount--;
501 if (s->refcount) {
508 kasan_cache_shutdown(s);
510 err = __kmem_cache_shutdown(s);
511 WARN(err, "%s %s: Slab cache still has objects when called from %pS",
512 __func__, s->name, (void *)_RET_IP_);
514 list_del(&s->list);
520 sysfs_slab_unlink(s);
521 debugfs_slab_release(s);
526 if (s->flags & SLAB_TYPESAFE_BY_RCU)
529 kmem_cache_release(s);
595 pr_cont(" slab%s %s", cp, kp.kp_slab_cache->name);
597 pr_cont(" slab%s", cp);
635 void __init create_boot_cache(struct kmem_cache *s, const char *name,
657 err = do_kmem_cache_create(s, name, size, &kmem_args, flags);
660 panic("Creation of kmalloc slab %s size=%u failed. Reason %d\n",
663 s->refcount = -1; /* Exempt from merging for now */
670 struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
672 if (!s)
673 panic("Out of memory when creating slab %s\n", name);
675 create_boot_cache(s, name, size, flags | SLAB_KMALLOC, 0, size);
676 list_add(&s->list, &slab_caches);
677 s->refcount = 1;
678 return s;
1088 static void cache_show(struct kmem_cache *s, struct seq_file *m)
1093 get_slabinfo(s, &sinfo);
1095 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
1096 s->name, sinfo.active_objs, sinfo.num_objs, s->size,
1108 struct kmem_cache *s = list_entry(p, struct kmem_cache, list);
1112 cache_show(s, m);
1118 struct kmem_cache *s;
1136 list_for_each_entry(s, &slab_caches, list) {
1137 if (s->flags & SLAB_RECLAIM_ACCOUNT)
1140 get_slabinfo(s, &sinfo);
1143 pr_info("%-17s %10luKB %10luKB\n", s->name,
1144 (sinfo.active_objs * s->size) / 1024,
1145 (sinfo.num_objs * s->size) / 1024);
1221 /* Disable KASAN checks as the object's redzone is accessed. */
1306 * it's printed later when the behaviour could be undefined due to