]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm: remove PMD alignment constraint in execmem_vmalloc()
authorDev Jain <dev.jain@arm.com>
Thu, 18 Sep 2025 09:34:53 +0000 (15:04 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 28 Sep 2025 18:51:31 +0000 (11:51 -0700)
When using vmalloc with VM_ALLOW_HUGE_VMAP flag, it will set the alignment
to PMD_SIZE internally, if it deems huge mappings to be eligible.
Therefore, setting the alignment in execmem_vmalloc is redundant.  Apart
from this, it also reduces the probability of allocation in case vmalloc
fails to allocate hugepages - in the fallback case, vmalloc tries to use
the original alignment and allocate basepages, which unfortunately will
again be PMD_SIZE passed over from execmem_vmalloc, thus constraining the
search for a free space in vmalloc region.

Therefore, remove this constraint.

Link: https://lkml.kernel.org/r/20250918093453.75676-1-dev.jain@arm.com
Signed-off-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/execmem.c

index 0822305413ece14cfc64a994d9d969235feb58ab..810a4ba9c9243ef021a555383b0ed8384f2beefc 100644 (file)
@@ -38,9 +38,6 @@ static void *execmem_vmalloc(struct execmem_range *range, size_t size,
        if (kasan)
                vm_flags |= VM_DEFER_KMEMLEAK;
 
-       if (vm_flags & VM_ALLOW_HUGE_VMAP)
-               align = PMD_SIZE;
-
        p = __vmalloc_node_range(size, align, start, end, gfp_flags,
                                 pgprot, vm_flags, NUMA_NO_NODE,
                                 __builtin_return_address(0));