Skip to content

Commit b035f5a

Browse files
ctmarinasakpm00
authored andcommitted
mm: slab: reduce the kmalloc() minimum alignment if DMA bouncing possible
If an architecture opted in to DMA bouncing of unaligned kmalloc() buffers (ARCH_WANT_KMALLOC_DMA_BOUNCE), reduce the minimum kmalloc() cache alignment below cache-line size to ARCH_KMALLOC_MINALIGN. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Reviewed-by: Vlastimil Babka <[email protected]> Tested-by: Isaac J. Manjarres <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Alasdair Kergon <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Jerry Snitselaar <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Lars-Peter Clausen <[email protected]> Cc: Logan Gunthorpe <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Mark Brown <[email protected]> Cc: Mike Snitzer <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Saravana Kannan <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 861370f commit b035f5a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mm/slab_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/uaccess.h>
1919
#include <linux/seq_file.h>
2020
#include <linux/dma-mapping.h>
21+
#include <linux/swiotlb.h>
2122
#include <linux/proc_fs.h>
2223
#include <linux/debugfs.h>
2324
#include <linux/kasan.h>
@@ -865,6 +866,10 @@ void __init setup_kmalloc_cache_index_table(void)
865866

866867
static unsigned int __kmalloc_minalign(void)
867868
{
869+
#ifdef CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC
870+
if (io_tlb_default_mem.nslabs)
871+
return ARCH_KMALLOC_MINALIGN;
872+
#endif
868873
return dma_get_cache_alignment();
869874
}
870875

0 commit comments

Comments
 (0)