slab: allows kmalloc min size independent on arch dma min alignment when CONFIG_ROCKCHIP_MINI_KERNEL=y

Copy a description from the ARCH_DMA_MINALIGN definition:
--
  Some archs want to perform DMA into kmalloc caches and need a guaranteed
  alignment larger than the alignment of a 64-bit integer.
  Setting ARCH_KMALLOC_MINALIGN in arch headers allows that.

For a specific product, which can make sure that the kmalloc won't used
by DMA, then it can set the kmalloc min size lower than arch dma min
alignment.

For ROCKCHIP_MINI_KERNEL, we can try to do it.

Before this patch:
       Name	Objects	Objsize	Loss	Slabs/Part/Cpu
kmalloc-8	2419	8	155.6	37/1/1
kmalloc-16	2669	16	180.2	43/3/1
kmalloc-32	1726	32	110.5	26/1/1
kmalloc-64	1013	64	69.6	16/4/1
kmalloc-96	658	96	86	20/2/1
kmalloc-128	352	128	45	10/0/1
kmalloc-192	567	192	110.5	26/0/1
kmalloc-256	140	256	36.8	8/1/1
kmalloc-512	311	512	172	41/5/1
kmalloc-1k	104	1024	139.2	16/5/1
kmalloc-2k	40	2048	81.9	4/0/1
kmalloc-4k	590	4096	2458	73/1/1
kmalloc-8k	8	8192	65.5	1/0/1

With this patch:
kmalloc-8	2560	8	20.4	4/0/1
kmalloc-16	2811	16	57.3	13/5/1
kmalloc-32	1791	32	57.3	13/1/1
kmalloc-64	1017	64	65.5	15/2/1
kmalloc-96	660	96	65.5	15/3/1
kmalloc-128	352	128	45	10/0/1
kmalloc-192	567	192	110.5	26/0/1
kmalloc-256	140	256	36.8	8/1/1
kmalloc-512	311	512	172	41/5/1
kmalloc-1k	105	1024	139.2	16/5/1
kmalloc-2k	40	2048	81.9	4/0/1
kmalloc-4k	590	4096	2458	73/1/1
kmalloc-8k	8	8192	65.5	1/0/1

Save about 300K.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: Ifa2a7ab13481180cc45c7b59e3a744f68f46aab5
This commit is contained in:
Jianqun Xu
2022-04-12 14:58:34 +08:00
committed by Tao Huang
parent 81d89711e3
commit c97fea6ed1

View File

@@ -200,7 +200,7 @@ static inline void __check_heap_object(const void *ptr, unsigned long n,
* alignment larger than the alignment of a 64-bit integer. * alignment larger than the alignment of a 64-bit integer.
* Setting ARCH_KMALLOC_MINALIGN in arch headers allows that. * Setting ARCH_KMALLOC_MINALIGN in arch headers allows that.
*/ */
#if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 #if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 && !IS_ENABLED(CONFIG_ROCKCHIP_MINI_KERNEL)
#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
#define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN #define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN
#define KMALLOC_SHIFT_LOW ilog2(ARCH_DMA_MINALIGN) #define KMALLOC_SHIFT_LOW ilog2(ARCH_DMA_MINALIGN)