ANDROID: 16K: Use vma_area slab cache for pad VMA

Allocate padding VMA from the vma slab cache; this make it
easier to debug slab leaks than from kmalloc slabs.

Bug: 427145188
Change-Id: I24c5f5d0eb3b06acf506f18f5eb57cd497b13d6d
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2025-06-24 14:58:32 -07:00
parent a213abada8
commit 3b75103301
2 changed files with 6 additions and 3 deletions

View File

@@ -452,7 +452,7 @@ struct kmem_cache *files_cachep;
struct kmem_cache *fs_cachep;
/* SLAB cache for vm_area_struct structures */
static struct kmem_cache *vm_area_cachep;
struct kmem_cache *vm_area_cachep;
/* SLAB cache for mm_struct structures (tsk->mm) */
static struct kmem_cache *mm_cachep;

View File

@@ -270,6 +270,9 @@ static const struct vm_operations_struct pad_vma_ops = {
.name = pad_vma_name,
};
/* Defined in kernel/fork.c */
extern struct kmem_cache *vm_area_cachep;
/*
* Returns a new VMA representing the padding in @vma;
* returns NULL if no padding in @vma or allocation failed.
@@ -281,7 +284,7 @@ static struct vm_area_struct *get_pad_vma(struct vm_area_struct *vma)
if (!is_pgsize_migration_enabled() || !(vma->vm_flags & VM_PAD_MASK))
return NULL;
pad = kzalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
pad = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
if (!pad) {
pr_warn("Page size migration: Failed to allocate padding VMA");
return NULL;
@@ -347,7 +350,7 @@ void show_map_pad_vma(struct vm_area_struct *vma, struct seq_file *m,
else
((show_pad_maps_fn)func)(m, pad);
kfree(pad);
kmem_cache_free(vm_area_cachep, pad);
}
/*