Skip to content
Permalink
Browse files
mm/slab: kmalloc with GFP_DMA32 allocate from SLAB_CACHE_DMA32
The flag GFP_DMA32 only effect in kmalloc_large currently.

This patch will create caches with GFP_DMA32 to support kmalloc with
size under KMALLOC_MAX_CACHE_SIZE.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
  • Loading branch information
jayxurockchip authored and intel-lab-lkp committed Mar 12, 2021
1 parent 2932a9e commit 93abfa9fa97332c9d5c1727fcf76b604b6da33de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
@@ -309,6 +309,9 @@ enum kmalloc_cache_type {
KMALLOC_RECLAIM,
#ifdef CONFIG_ZONE_DMA
KMALLOC_DMA,
#endif
#ifdef CONFIG_ZONE_DMA32
KMALLOC_DMA32,
#endif
NR_KMALLOC_TYPES
};
@@ -333,6 +336,10 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags)
*/
return flags & __GFP_DMA ? KMALLOC_DMA : KMALLOC_RECLAIM;
#else
#ifdef CONFIG_ZONE_DMA32
if (unlikely(flags & __GFP_DMA32))
return KMALLOC_DMA32;
#endif
return flags & __GFP_RECLAIMABLE ? KMALLOC_RECLAIM : KMALLOC_NORMAL;
#endif
}
@@ -804,6 +804,20 @@ void __init create_kmalloc_caches(slab_flags_t flags)
}
}
#endif
#ifdef CONFIG_ZONE_DMA32
for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
struct kmem_cache *s = kmalloc_caches[KMALLOC_NORMAL][i];

if (s) {
unsigned int size = kmalloc_size(i);
const char *n = kmalloc_cache_name("dma32-kmalloc", size);

BUG_ON(!n);
kmalloc_caches[KMALLOC_DMA32][i] = create_kmalloc_cache(
n, size, SLAB_CACHE_DMA32 | flags, 0, 0);
}
}
#endif
}
#endif /* !CONFIG_SLOB */

0 comments on commit 93abfa9

Please sign in to comment.