Lines Matching full:size

147 struct kmem_cache *kmem_cache_create(const char *name, unsigned int size,
151 unsigned int size, unsigned int align,
235 * The largest kmalloc size supported by the SLAB allocators is
276 /* Maximum allocatable size */
278 /* Maximum size for which we actually use a slab cache */
292 * Page size is normally 2^12 bytes and, in this case, if we want to use
293 * byte sized index which can represent 2^8 entries, the size of the object
295 * If minimum size of kmalloc is less than 16, we use it as minimum object
296 * size and give up to use byte sized index.
339 * Figure out which kmalloc slab an allocation of a certain size
346 static __always_inline unsigned int kmalloc_index(size_t size) in kmalloc_index() argument
348 if (!size) in kmalloc_index()
351 if (size <= KMALLOC_MIN_SIZE) in kmalloc_index()
354 if (KMALLOC_MIN_SIZE <= 32 && size > 64 && size <= 96) in kmalloc_index()
356 if (KMALLOC_MIN_SIZE <= 64 && size > 128 && size <= 192) in kmalloc_index()
358 if (size <= 8) return 3; in kmalloc_index()
359 if (size <= 16) return 4; in kmalloc_index()
360 if (size <= 32) return 5; in kmalloc_index()
361 if (size <= 64) return 6; in kmalloc_index()
362 if (size <= 128) return 7; in kmalloc_index()
363 if (size <= 256) return 8; in kmalloc_index()
364 if (size <= 512) return 9; in kmalloc_index()
365 if (size <= 1024) return 10; in kmalloc_index()
366 if (size <= 2 * 1024) return 11; in kmalloc_index()
367 if (size <= 4 * 1024) return 12; in kmalloc_index()
368 if (size <= 8 * 1024) return 13; in kmalloc_index()
369 if (size <= 16 * 1024) return 14; in kmalloc_index()
370 if (size <= 32 * 1024) return 15; in kmalloc_index()
371 if (size <= 64 * 1024) return 16; in kmalloc_index()
372 if (size <= 128 * 1024) return 17; in kmalloc_index()
373 if (size <= 256 * 1024) return 18; in kmalloc_index()
374 if (size <= 512 * 1024) return 19; in kmalloc_index()
375 if (size <= 1024 * 1024) return 20; in kmalloc_index()
376 if (size <= 2 * 1024 * 1024) return 21; in kmalloc_index()
377 if (size <= 4 * 1024 * 1024) return 22; in kmalloc_index()
378 if (size <= 8 * 1024 * 1024) return 23; in kmalloc_index()
379 if (size <= 16 * 1024 * 1024) return 24; in kmalloc_index()
380 if (size <= 32 * 1024 * 1024) return 25; in kmalloc_index()
381 if (size <= 64 * 1024 * 1024) return 26; in kmalloc_index()
389 void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __malloc;
407 static __always_inline void kfree_bulk(size_t size, void **p) in kfree_bulk() argument
409 kmem_cache_free_bulk(NULL, size, p); in kfree_bulk()
413 void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_kmalloc_alignment __malloc;
416 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node) in __kmalloc_node() argument
418 return __kmalloc(size, flags); in __kmalloc_node()
433 int node, size_t size) __assume_slab_alignment __malloc;
438 int node, size_t size) in kmem_cache_alloc_node_trace() argument
440 return kmem_cache_alloc_trace(s, gfpflags, size); in kmem_cache_alloc_node_trace()
446 gfp_t flags, size_t size) in kmem_cache_alloc_trace() argument
450 ret = kasan_kmalloc(s, ret, size, flags); in kmem_cache_alloc_trace()
457 int node, size_t size) in kmem_cache_alloc_node_trace() argument
461 ret = kasan_kmalloc(s, ret, size, gfpflags); in kmem_cache_alloc_node_trace()
466 extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) __assume_page_alignment __…
469 extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) __assume_page_alignm…
472 kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) in kmalloc_order_trace() argument
474 return kmalloc_order(size, flags, order); in kmalloc_order_trace()
478 static __always_inline void *kmalloc_large(size_t size, gfp_t flags) in kmalloc_large() argument
480 unsigned int order = get_order(size); in kmalloc_large()
481 return kmalloc_order_trace(size, flags, order); in kmalloc_large()
486 * @size: how many bytes of memory are required.
490 * for objects smaller than page size in the kernel.
493 * bytes. For @size of power of two bytes, the alignment is also guaranteed
494 * to be at least to the size.
538 static __always_inline void *kmalloc(size_t size, gfp_t flags) in kmalloc() argument
540 if (__builtin_constant_p(size)) { in kmalloc()
544 if (size > KMALLOC_MAX_CACHE_SIZE) in kmalloc()
545 return kmalloc_large(size, flags); in kmalloc()
547 index = kmalloc_index(size); in kmalloc()
554 flags, size); in kmalloc()
557 return __kmalloc(size, flags); in kmalloc()
560 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) in kmalloc_node() argument
563 if (__builtin_constant_p(size) && in kmalloc_node()
564 size <= KMALLOC_MAX_CACHE_SIZE) { in kmalloc_node()
565 unsigned int i = kmalloc_index(size); in kmalloc_node()
572 flags, node, size); in kmalloc_node()
575 return __kmalloc_node(size, flags, node); in kmalloc_node()
581 * @size: element size.
584 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) in kmalloc_array() argument
588 if (unlikely(check_mul_overflow(n, size, &bytes))) in kmalloc_array()
590 if (__builtin_constant_p(n) && __builtin_constant_p(size)) in kmalloc_array()
598 * @size: element size.
601 static inline void *kcalloc(size_t n, size_t size, gfp_t flags) in kcalloc() argument
603 return kmalloc_array(n, size, flags | __GFP_ZERO); in kcalloc()
615 #define kmalloc_track_caller(size, flags) \ argument
616 __kmalloc_track_caller(size, flags, _RET_IP_)
618 static inline void *kmalloc_array_node(size_t n, size_t size, gfp_t flags, in kmalloc_array_node() argument
623 if (unlikely(check_mul_overflow(n, size, &bytes))) in kmalloc_array_node()
625 if (__builtin_constant_p(n) && __builtin_constant_p(size)) in kmalloc_array_node()
630 static inline void *kcalloc_node(size_t n, size_t size, gfp_t flags, int node) in kcalloc_node() argument
632 return kmalloc_array_node(n, size, flags | __GFP_ZERO, node); in kcalloc_node()
638 #define kmalloc_node_track_caller(size, flags, node) \ argument
639 __kmalloc_node_track_caller(size, flags, node, \
644 #define kmalloc_node_track_caller(size, flags, node) \ argument
645 kmalloc_track_caller(size, flags)
659 * @size: how many bytes of memory are required.
662 static inline void *kzalloc(size_t size, gfp_t flags) in kzalloc() argument
664 return kmalloc(size, flags | __GFP_ZERO); in kzalloc()
669 * @size: how many bytes of memory are required.
673 static inline void *kzalloc_node(size_t size, gfp_t flags, int node) in kzalloc_node() argument
675 return kmalloc_node(size, flags | __GFP_ZERO, node); in kzalloc_node()