Commit a03ed8f1 authored by Brendan Jackman's avatar Brendan Jackman Committed by Andrew Morton
Browse files

mm/vmalloc: clarify why vmap_range_noflush() might sleep

The only reason vmap_range_noflush() can sleep is because of pagetable
allocations.

The actual allocation mechanism is arch-specific so might_alloc() doesn't
work here (what GFP flags would be used?).  Hence, just add a comment.

Also note that this might do a TLB shootdown.  This is not actually
sleeping but it requires IRQs on for x86, and might_sleep() incidentally
serves to detect violations of that too.

Link: https://lkml.kernel.org/r/20251215-b4-vmalloc-might_alloc-v3-1-92dd8e406868@google.com


Signed-off-by: default avatarBrendan Jackman <jackmanb@google.com>
Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 6c790212
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -305,6 +305,11 @@ static int vmap_range_noflush(unsigned long addr, unsigned long end,
	int err;
	pgtbl_mod_mask mask = 0;

	/*
	 * Might allocate pagetables (for most archs a more precise annotation
	 * would be might_alloc(GFP_PGTABLE_KERNEL)). Also might shootdown TLB
	 * (requires IRQs enabled on x86).
	 */
	might_sleep();
	BUG_ON(addr >= end);