From: Pasha Tatashin <[email protected]>

get_vm_area_node()
Unlike the other public get_vm_area_* variants, this one accepts node
from which to allocate data structure, and also the align, which allows
to create vm area with a specific alignment.

This call is going to be used by partially populated stacks in order
to allocate the VA space for the kernel stacks that might be larger
than the memory mapped behind it.

Signed-off-by: Pasha Tatashin <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
[Switched to vmap_pages_range instead of noflush variant, fix typos]
Signed-off-by: David Stevens <[email protected]>
[vmap_pages_range() already in the header, and remove the export as it
 was not needed, update commit msg]
Signed-off-by: Mostafa Saleh <[email protected]>
---
 include/linux/vmalloc.h |  3 +++
 mm/vmalloc.c            | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index aed121d729b0..e6a9c1bbe789 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -250,6 +250,9 @@ extern struct vm_struct *__get_vm_area_caller(unsigned long 
size,
                                        unsigned long flags,
                                        unsigned long start, unsigned long end,
                                        const void *caller);
+struct vm_struct *get_vm_area_node(unsigned long size, unsigned long align,
+                                  unsigned long flags, int node, gfp_t gfp,
+                                  const void *caller);
 void free_vm_area(struct vm_struct *area);
 extern struct vm_struct *remove_vm_area(const void *addr);
 extern struct vm_struct *find_vm_area(const void *addr);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index bea9f76ed7e7..9f4634c7977e 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3301,6 +3301,30 @@ struct vm_struct *get_vm_area_caller(unsigned long size, 
unsigned long flags,
                                  NUMA_NO_NODE, GFP_KERNEL, caller);
 }
 
+/**
+ * get_vm_area_node - reserve a contiguous and aligned kernel virtual area
+ * @size:       size of the area
+ * @align:      alignment of the start address of the area
+ * @flags:      %VM_IOREMAP for I/O mappings
+ * @node:       NUMA node from which to allocate the area data structure
+ * @gfp:        Flags to pass to the allocator
+ * @caller:     Caller to be stored in the vm area data structure
+ *
+ * Search for an area of @size/align in the kernel virtual mapping area and
+ * reserve it for our purposes. Returns the area descriptor on success or %NULL
+ * on failure.
+ *
+ * Return: the area descriptor on success or %NULL on failure.
+ */
+struct vm_struct *get_vm_area_node(unsigned long size, unsigned long align,
+                                  unsigned long flags, int node, gfp_t gfp,
+                                  const void *caller)
+{
+       return __get_vm_area_node(size, align, PAGE_SHIFT, flags,
+                                 VMALLOC_START, VMALLOC_END,
+                                 node, gfp, caller);
+}
+
 /**
  * find_vm_area - find a continuous kernel virtual area
  * @addr:        base address
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


Reply via email to