mm/sparsemem: enable vmem_altmap support in vmemmap_alloc_block_buf()

There are many instances where vmemap allocation is often switched between
regular memory and device memory just based on whether altmap is available
or not.  vmemmap_alloc_block_buf() is used in various platforms to
allocate vmemmap mappings.  Lets also enable it to handle altmap based
device memory allocation along with existing regular memory allocations.
This will help in avoiding the altmap based allocation switch in many
places.  To summarize there are two different methods to call

vmemmap_alloc_block_buf(size, node, NULL)   /* Allocate from system RAM */
vmemmap_alloc_block_buf(size, node, altmap) /* Allocate from altmap */

This converts altmap_alloc_block_buf() into a static function, drops it's
entry from the header and updates Documentation/vm/memory-model.rst.

Suggested-by: Robin Murphy <>
Signed-off-by: Anshuman Khandual <>
Signed-off-by: Andrew Morton <>
Tested-by: Jia He <>
Reviewed-by: Catalin Marinas <>
Cc: Jonathan Corbet <>
Cc: Will Deacon <>
Cc: Benjamin Herrenschmidt <>
Cc: Paul Mackerras <>
Cc: Michael Ellerman <>
Cc: Dave Hansen <>
Cc: Andy Lutomirski <>
Cc: Peter Zijlstra <>
Cc: Thomas Gleixner <>
Cc: Ingo Molnar <>
Cc: Borislav Petkov <>
Cc: "H. Peter Anvin" <>
Cc: Dan Williams <>
Cc: David Hildenbrand <>
Cc: Fenghua Yu <>
Cc: Hsin-Yi Wang <>
Cc: "Kirill A. Shutemov" <>
Cc: Mark Rutland <>
Cc: "Matthew Wilcox (Oracle)" <>
Cc: Michal Hocko <>
Cc: Mike Rapoport <>
Cc: Palmer Dabbelt <>
Cc: Paul Walmsley <>
Cc: Pavel Tatashin <>
Cc: Steve Capper <>
Cc: Tony Luck <>
Cc: Yu Zhao <>
Signed-off-by: Linus Torvalds <>
6 files changed