Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/vmalloc: move resched point into alloc_vmap_area()

Currently vm_area_alloc_pages() contains two cond_resched() points.
However, the page allocator already has its own in slow path so an extra
resched is not optimal because it delays the loops.

The place where CPU time can be consumed is in the VA-space search in
alloc_vmap_area(), especially if the space is really fragmented using
synthetic stress tests, after a fast path falls back to a slow one.

Move a single cond_resched() there, after dropping free_vmap_area_lock in
a slow path. This keeps fairness where it matters while removing
redundant yields from the page-allocation path.

[akpm@linux-foundation.org: tweak comment grammar]
Link: https://lkml.kernel.org/r/20250917185906.1595454-1-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Uladzislau Rezki (Sony) and committed by
Andrew Morton
7ef5268a 1b00ab48

+6 -2
+6 -2
mm/vmalloc.c
··· 2057 2057 addr = __alloc_vmap_area(&free_vmap_area_root, &free_vmap_area_list, 2058 2058 size, align, vstart, vend); 2059 2059 spin_unlock(&free_vmap_area_lock); 2060 + 2061 + /* 2062 + * This is not a fast path. Check if yielding is needed. This 2063 + * is the only reschedule point in the vmalloc() path. 2064 + */ 2065 + cond_resched(); 2060 2066 } 2061 2067 2062 2068 trace_alloc_vmap_area(addr, size, align, vstart, vend, IS_ERR_VALUE(addr)); ··· 3628 3622 pages + nr_allocated); 3629 3623 3630 3624 nr_allocated += nr; 3631 - cond_resched(); 3632 3625 3633 3626 /* 3634 3627 * If zero or pages were obtained partly, ··· 3669 3664 for (i = 0; i < (1U << order); i++) 3670 3665 pages[nr_allocated + i] = page + i; 3671 3666 3672 - cond_resched(); 3673 3667 nr_allocated += 1U << order; 3674 3668 } 3675 3669