Lines Matching full:size

147 struct kmem_cache *kmem_cache_create(const char *name, unsigned int size,
151 unsigned int size, unsigned int align,
239 * The largest kmalloc size supported by the SLAB allocators is
280 /* Maximum allocatable size */
282 /* Maximum size for which we actually use a slab cache */
296 * Page size is normally 2^12 bytes and, in this case, if we want to use
297 * byte sized index which can represent 2^8 entries, the size of the object
299 * If minimum size of kmalloc is less than 16, we use it as minimum object
300 * size and give up to use byte sized index.
343 * Figure out which kmalloc slab an allocation of a certain size
350 static __always_inline unsigned int kmalloc_index(size_t size) in kmalloc_index() argument
352 if (!size) in kmalloc_index()
355 if (size <= KMALLOC_MIN_SIZE) in kmalloc_index()
358 if (KMALLOC_MIN_SIZE <= 32 && size > 64 && size <= 96) in kmalloc_index()
360 if (KMALLOC_MIN_SIZE <= 64 && size > 128 && size <= 192) in kmalloc_index()
362 if (size <= 8) return 3; in kmalloc_index()
363 if (size <= 16) return 4; in kmalloc_index()
364 if (size <= 32) return 5; in kmalloc_index()
365 if (size <= 64) return 6; in kmalloc_index()
366 if (size <= 128) return 7; in kmalloc_index()
367 if (size <= 256) return 8; in kmalloc_index()
368 if (size <= 512) return 9; in kmalloc_index()
369 if (size <= 1024) return 10; in kmalloc_index()
370 if (size <= 2 * 1024) return 11; in kmalloc_index()
371 if (size <= 4 * 1024) return 12; in kmalloc_index()
372 if (size <= 8 * 1024) return 13; in kmalloc_index()
373 if (size <= 16 * 1024) return 14; in kmalloc_index()
374 if (size <= 32 * 1024) return 15; in kmalloc_index()
375 if (size <= 64 * 1024) return 16; in kmalloc_index()
376 if (size <= 128 * 1024) return 17; in kmalloc_index()
377 if (size <= 256 * 1024) return 18; in kmalloc_index()
378 if (size <= 512 * 1024) return 19; in kmalloc_index()
379 if (size <= 1024 * 1024) return 20; in kmalloc_index()
380 if (size <= 2 * 1024 * 1024) return 21; in kmalloc_index()
381 if (size <= 4 * 1024 * 1024) return 22; in kmalloc_index()
382 if (size <= 8 * 1024 * 1024) return 23; in kmalloc_index()
383 if (size <= 16 * 1024 * 1024) return 24; in kmalloc_index()
384 if (size <= 32 * 1024 * 1024) return 25; in kmalloc_index()
385 if (size <= 64 * 1024 * 1024) return 26; in kmalloc_index()
393 void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __malloc;
411 static __always_inline void kfree_bulk(size_t size, void **p) in kfree_bulk() argument
413 kmem_cache_free_bulk(NULL, size, p); in kfree_bulk()
417 void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_kmalloc_alignment __malloc;
420 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node) in __kmalloc_node() argument
422 return __kmalloc(size, flags); in __kmalloc_node()
437 int node, size_t size) __assume_slab_alignment __malloc;
442 int node, size_t size) in kmem_cache_alloc_node_trace() argument
444 return kmem_cache_alloc_trace(s, gfpflags, size); in kmem_cache_alloc_node_trace()
450 gfp_t flags, size_t size) in kmem_cache_alloc_trace() argument
454 ret = kasan_kmalloc(s, ret, size, flags); in kmem_cache_alloc_trace()
461 int node, size_t size) in kmem_cache_alloc_node_trace() argument
465 ret = kasan_kmalloc(s, ret, size, gfpflags); in kmem_cache_alloc_node_trace()
470 extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) __assume_page_alignment __…
473 extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) __assume_page_alignm…
476 kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) in kmalloc_order_trace() argument
478 return kmalloc_order(size, flags, order); in kmalloc_order_trace()
482 static __always_inline void *kmalloc_large(size_t size, gfp_t flags) in kmalloc_large() argument
484 unsigned int order = get_order(size); in kmalloc_large()
485 return kmalloc_order_trace(size, flags, order); in kmalloc_large()
490 * @size: how many bytes of memory are required.
494 * for objects smaller than page size in the kernel.
497 * bytes. For @size of power of two bytes, the alignment is also guaranteed
498 * to be at least to the size.
542 static __always_inline void *kmalloc(size_t size, gfp_t flags) in kmalloc() argument
544 if (__builtin_constant_p(size)) { in kmalloc()
548 if (size > KMALLOC_MAX_CACHE_SIZE) in kmalloc()
549 return kmalloc_large(size, flags); in kmalloc()
551 index = kmalloc_index(size); in kmalloc()
558 flags, size); in kmalloc()
561 return __kmalloc(size, flags); in kmalloc()
565 * Determine size used for the nth kmalloc cache.
566 * return size or 0 if a kmalloc cache for that
567 * size does not exist
584 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) in kmalloc_node() argument
587 if (__builtin_constant_p(size) && in kmalloc_node()
588 size <= KMALLOC_MAX_CACHE_SIZE) { in kmalloc_node()
589 unsigned int i = kmalloc_index(size); in kmalloc_node()
596 flags, node, size); in kmalloc_node()
599 return __kmalloc_node(size, flags, node); in kmalloc_node()
607 * @size: element size.
610 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) in kmalloc_array() argument
614 if (unlikely(check_mul_overflow(n, size, &bytes))) in kmalloc_array()
616 if (__builtin_constant_p(n) && __builtin_constant_p(size)) in kmalloc_array()
624 * @size: element size.
627 static inline void *kcalloc(size_t n, size_t size, gfp_t flags) in kcalloc() argument
629 return kmalloc_array(n, size, flags | __GFP_ZERO); in kcalloc()
641 #define kmalloc_track_caller(size, flags) \ argument
642 __kmalloc_track_caller(size, flags, _RET_IP_)
644 static inline void *kmalloc_array_node(size_t n, size_t size, gfp_t flags, in kmalloc_array_node() argument
649 if (unlikely(check_mul_overflow(n, size, &bytes))) in kmalloc_array_node()
651 if (__builtin_constant_p(n) && __builtin_constant_p(size)) in kmalloc_array_node()
656 static inline void *kcalloc_node(size_t n, size_t size, gfp_t flags, int node) in kcalloc_node() argument
658 return kmalloc_array_node(n, size, flags | __GFP_ZERO, node); in kcalloc_node()
664 #define kmalloc_node_track_caller(size, flags, node) \ argument
665 __kmalloc_node_track_caller(size, flags, node, \
670 #define kmalloc_node_track_caller(size, flags, node) \ argument
671 kmalloc_track_caller(size, flags)
685 * @size: how many bytes of memory are required.
688 static inline void *kzalloc(size_t size, gfp_t flags) in kzalloc() argument
690 return kmalloc(size, flags | __GFP_ZERO); in kzalloc()
695 * @size: how many bytes of memory are required.
699 static inline void *kzalloc_node(size_t size, gfp_t flags, int node) in kzalloc_node() argument
701 return kmalloc_node(size, flags | __GFP_ZERO, node); in kzalloc_node()