Currently, ARM64 hardcodes ARCH_DMA_MINALIGN to 128 bytes, which ultimately causes the smallest kmalloc cache in the system to allocate 128 byte objects. This is wasteful on systems that don't have this 128 byte minimum DMA alignment requirement, as their cachelines are 64 bytes in size, and thus, can function properly with kmalloc allocating objects 64 bytes in size. Add a commandline parameter--android_kmalloc_64_create--to create and use all of the different types of kmalloc caches (e.g. kmalloc-*, kmalloc-rcl-*, etc) for 64-byte allocations, if the hardware supports it. The hardware supports 64 byte objects if their size is aligned to the cache line size that is reported by the system. This patch is loosely based on the discussion in [1] and aims to optimize the amount of memory kmalloc uses by allowing slab allocations to be satisfied by the kmalloc-64 cache, if the hardware supports it. This approach differs from [1] by being less invasive, and only attempting to create the kmalloc-64 cache if the kmalloc_64_create parameter is specified in the kernel commandline. The intent of this is to preserve the ABI semantics of kmalloc (i.e. 128 or ARCH_DMA_MINALIGN byte alignment) for existing devices using ARM64 GKI kernels on the android13-5.15 branch, since the KMI is frozen. The final solution from [1] should be used, or this patch should be reworked for future versions of Android and should not be cherry-picked forward. [1] https://lore.kernel.org/linux-mm/20220405135758.774016-1-catalin.marinas@arm.com/ Bug: 241844128 Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com> Change-Id: I6d39e6c6957c944f0327e6774afd33f4c2230019
23 KiB
23 KiB