mm: cma: NUMA node interface
PATCH v3 1/1 mm: cma: NUMA node interface
I've noticed that there is no interfaces exposed by CMA which would let me to declare contigous memory on particular NUMA node.
This patchset adds the ability to try to allocate contiguous memory on specific node. It will fallback to other nodes if the specified one doesn't work.
Implement a new method for declaring contigous memory on particular node and keep cma_declare_contiguous() as a wrapper.
--- include/linux/cma.h | 13 +++++++++++-- include/linux/memblock.h | 3 +++ mm/cma.c | 16 +++++++++------- mm/memblock.c | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-)
include/linux/cma.h +11 -2
@@ -24,10 +24,19 @@ extern phys_addr_t cma_get_base(const struct cma *cma);extern unsigned long cma_get_size (const struct cma *cma);extern const char *cma_get_name (const struct cma *cma); -extern int __init cma_declare_contiguous (phys_addr_t base, +extern int __init cma_declare_contiguous_nid (phys_addr_t base,phys_addr_t size,phys_addr_t limit,phys_addr_t alignment,unsigned int order_per_bit, -bool fixed,const char *name,struct cma **res_cma); +bool fixed,const char *name,struct cma **res_cma, +int nid); +static inline int __init cma_declare_contiguous (phys_addr_t base, +phys_addr_t size,phys_addr_t limit, +phys_addr_t alignment,unsigned int order_per_bit, +bool fixed,const char *name,struct cma **res_cma) +{ +return cma_declare_contiguous_nid (base, size, limit, alignment, + order_per_bit, fixed, name, res_cma,NUMA_NO_NODE ); +} extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, unsigned int order_per_bit, const char *name,
include/linux/memblock.h +3 -0
@@ -348,6 +348,9 @@ static inline int memblock_get_region_node(const struct memblock_region *r)phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end); +phys_addr_t memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t align,phys_addr_t start, +phys_addr_t end,int nid,bool exact_nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,
mm/cma.c +9 -7
@@ -220,7 +220,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, }/** -* cma_declare_contiguous() - reserve custom contiguous area +* cma_declare_contiguous_nid() - reserve custom contiguous area * @base: Base address of the reserved area optional, use 0 for any * @size: Size of the reserved area (in bytes), * @limit: End address of the reserved memory (optional, 0 for any).
@@ -229,6 +229,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,* @fixed: hint about where to place the reserved area * @name: The name of the area. See function cma_init_reserved_mem() * @res_cma: Pointer to store the created cma region. +* @nid: nid of the free area to find, %NUMA_NO_NODE for any node * * This function reserves memory from early allocator. It should be * called by arch specific code once the early allocator (memblock or bootmem)
@@ -238,10 +239,11 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,* If @fixed is true, reserve contiguous area at exactly @base. If false, * reserve in range from @base to @limit. */ -int __init cma_declare_contiguous (phys_addr_t base, +int __init cma_declare_contiguous_nid (phys_addr_t base,phys_addr_t size,phys_addr_t limit,phys_addr_t alignment,unsigned int order_per_bit, -bool fixed,const char *name,struct cma **res_cma) +bool fixed,const char *name,struct cma **res_cma, +int nid) {phys_addr_t memblock_end =memblock_end_of_DRAM ();phys_addr_t highmem_start;
@@ -336,14 +338,14 @@ int __init cma_declare_contiguous(phys_addr_t base,* memory in case of failure. */ if (base < highmem_start && limit > highmem_start) { - addr =memblock_phys_alloc_range (size, alignment, - highmem_start, limit); + addr =memblock_alloc_range_nid (size, alignment, + highmem_start, limit, nid, false); limit = highmem_start; }if (!addr) { - addr =memblock_phys_alloc_range (size, alignment, base, - limit); + addr =memblock_alloc_range_nid (size, alignment, base, + alimit, nid, false);if (!addr) { ret = -ENOMEM ; goto err;
mm/memblock.c +1 -1
@@ -1349,7 +1349,7 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone,* Return: * Physical address of allocated memory block on success, %0 on failure. */ -static phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end,int nid,bool exact_nid)
Signature · 1 line
2.24.1
Quoted 9 lines · Aslan Bakirov
I've noticed that there is no interfaces exposed by CMA which would let me to declare contigous memory on particular NUMA node.
This patchset adds the ability to try to allocate contiguous memory on specific node. It will fallback to other nodes if the specified one doesn't work.
Implement a new method for declaring contigous memory on particular node and keep
cma_declare_contiguous()as a wrapper.
Is there an additional patch which uses this new interface?
Generally the patch seems reasonable but we should have a user.
Ira
Quoted 120 lines
Signed-off-by Aslan Bakirov <[email protected]>--- include/linux/cma.h | 13 +++++++++++-- include/linux/memblock.h | 3 +++ mm/cma.c | 16 +++++++++------- mm/memblock.c | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-)include/linux/cma.h +11
-2@@ -24,10 +24,19 @@ extern phys_addr_t cma_get_base(const struct cma *cma);extern unsigned long cma_get_size (const struct cma *cma);extern const char *cma_get_name (const struct cma *cma); -extern int __init cma_declare_contiguous (phys_addr_t base, +extern int __init cma_declare_contiguous_nid (phys_addr_t base,phys_addr_t size,phys_addr_t limit,phys_addr_t alignment,unsigned int order_per_bit, -bool fixed,const char *name,struct cma **res_cma); +bool fixed,const char *name,struct cma **res_cma, +int nid); +static inline int __init cma_declare_contiguous (phys_addr_t base, +phys_addr_t size,phys_addr_t limit, +phys_addr_t alignment,unsigned int order_per_bit, +bool fixed,const char *name,struct cma **res_cma) +{ +return cma_declare_contiguous_nid (base, size, limit, alignment, + order_per_bit, fixed, name, res_cma,NUMA_NO_NODE ); +} extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, unsigned int order_per_bit, const char *name,include/linux/memblock.h +3
-0@@ -348,6 +348,9 @@ static inline int memblock_get_region_node(const struct memblock_region *r)phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end); +phys_addr_t memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t align,phys_addr_t start, +phys_addr_t end,int nid,bool exact_nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,mm/cma.c +9
-7@@ -220,7 +220,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, }/** -* cma_declare_contiguous() - reserve custom contiguous area +* cma_declare_contiguous_nid() - reserve custom contiguous area * @base: Base address of the reserved area optional, use 0 for any * @size: Size of the reserved area (in bytes), * @limit: End address of the reserved memory (optional, 0 for any). @@ -229,6 +229,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,* @fixed: hint about where to place the reserved area * @name: The name of the area. See function cma_init_reserved_mem() * @res_cma: Pointer to store the created cma region. +* @nid: nid of the free area to find, %NUMA_NO_NODE for any node * * This function reserves memory from early allocator. It should be * called by arch specific code once the early allocator (memblock or bootmem) @@ -238,10 +239,11 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,* If @fixed is true, reserve contiguous area at exactly @base. If false, * reserve in range from @base to @limit. */ -int __init cma_declare_contiguous (phys_addr_t base, +int __init cma_declare_contiguous_nid (phys_addr_t base,phys_addr_t size,phys_addr_t limit,phys_addr_t alignment,unsigned int order_per_bit, -bool fixed,const char *name,struct cma **res_cma) +bool fixed,const char *name,struct cma **res_cma, +int nid) {phys_addr_t memblock_end =memblock_end_of_DRAM ();phys_addr_t highmem_start;@@ -336,14 +338,14 @@ int __init cma_declare_contiguous(phys_addr_t base,* memory in case of failure. */ if (base < highmem_start && limit > highmem_start) { - addr =memblock_phys_alloc_range (size, alignment, - highmem_start, limit); + addr =memblock_alloc_range_nid (size, alignment, + highmem_start, limit, nid, false); limit = highmem_start; }if (!addr) { - addr =memblock_phys_alloc_range (size, alignment, base, - limit); + addr =memblock_alloc_range_nid (size, alignment, base, + alimit, nid, false);if (!addr) { ret = -ENOMEM ; goto err;mm/memblock.c +1
-1@@ -1349,7 +1349,7 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone,* Return: * Physical address of allocated memory block on success, %0 on failure. */ -static phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end,int nid,bool exact_nid)Signature · 1 line
2.24.1
Quoted 9 lines · Ira Weiny
Quoted 1 line · Aslan Bakirov
I've noticed that there is no interfaces exposed by CMA which would let
me
Quoted 6 lines
to declare contigous memory on particular NUMA node.
This patchset adds the ability to try to allocate contiguous memory on specific node. It will fallback to other nodes if the specified one doesn't work.
Quoted 6 lines
Quoted 2 lines
Implement a new method for declaring contigous memory on particular node and keep
cma_declare_contiguous()as a wrapper.Is there an additional patch which uses this new interface?
Generally the patch seems reasonable but we should have a user.
Thanks for the comments. Yes, actually, this is the version 3 of first
patch ([PATCH 1/2] mm: cma: NUMA node interface)
of patchset. Second patch, which uses this interface is "[PATCH 2/2] mm:
hugetlb: Use node interface of cma"
Ira
Quoted 139 lines
include/linux/cma.h extern phys_addr_t cma_get_base(const struct cma
Quoted 15 lines
Signed-off-by Aslan Bakirov <[email protected]>--- include/linux/cma.h | 13 +++++++++++-- include/linux/memblock.h | 3 +++ mm/cma.c | 16 +++++++++------- mm/memblock.c | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-)include/linux/cma.h +0
-0@@ -24,10 +24,19 @@ extern phys_addr_t cma_get_base(const struct cma*cma);
include/linux/cma.h extern phys_addr_t cma_get_base(const struct cma *cma);
Quoted 8 lines
include/linux/cma.h +1
-2extern unsigned long cma_get_size (const struct cma *cma);extern const char *cma_get_name (const struct cma *cma); -extern int __init cma_declare_contiguous (phys_addr_t base, +extern int __init cma_declare_contiguous_nid(phys_addr_t base, phys_addr_t size, phys_addr_t limit, phys_addr_t alignment, unsigned int order_per_bit, - bool fixed, const char *name, struct cma**res_cma);
include/linux/memblock.h static inline int memblock_get_region_node(const
Quoted 18 lines
include/linux/cma.h +10
-0+ bool fixed, const char *name, struct cma **res_cma, + int nid); +static inline int __init cma_declare_contiguous (phys_addr_t base, +phys_addr_t size,phys_addr_t limit, +phys_addr_t alignment,unsigned int order_per_bit, +bool fixed,const char *name,struct cma **res_cma) +{ +return cma_declare_contiguous_nid (base, size, limit, alignment, + order_per_bit, fixed, name, res_cma,NUMA_NO_NODE ); +} extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, unsigned int order_per_bit, const char *name,include/linux/memblock.h +0
-0@@ -348,6 +348,9 @@ static inline int memblock_get_region_node(conststruct
memblock_region*r)include/linux/memblock.h static inline int memblock_get_region_node(const · line 348
Quoted 2 lines
include/linux/memblock.h +0
-0phys_addr_t memblock_phys_alloc_range(phys_addr_t size, phys_addr_talign,
include/linux/memblock.h static inline int memblock_get_region_node(const struct memblock_region *r)
Quoted 4 lines
include/linux/memblock.h +3
-0phys_addr_t start, phys_addr_t end); +phys_addr_t memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t align,phys_addr_t start, + phys_addr_t end, int nid, bool
exact_nid);include/linux/memblock.h static inline int memblock_get_region_node(const · line 353
Quoted 1 line
include/linux/memblock.h +0
-0phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_talign, int nid);
mm/cma.c int __init cma_init_reserved_mem(phys_addr_t base,
Quoted 7 lines
include/linux/memblock.h +0
-0static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,mm/cma.c +0
-0@@ -220,7 +220,7 @@ int __init cma_init_reserved_mem(phys_addr_t base,
phys_addr_tsize,mm/cma.c int __init cma_init_reserved_mem(phys_addr_t base,
Quoted 9 lines
mm/cma.c +1
-1}/** -* cma_declare_contiguous() - reserve custom contiguous area +* cma_declare_contiguous_nid() - reserve custom contiguous area * @base: Base address of the reserved area optional, use 0 for any * @size: Size of the reserved area (in bytes), * @limit: End address of the reserved memory (optional, 0 for any). @@ -229,6 +229,7 @@ int __init cma_init_reserved_mem(phys_addr_t base,
phys_addr_tsize,mm/cma.c int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
Quoted 7 lines
mm/cma.c +1
-0* @fixed: hint about where to place the reserved area * @name: The name of the area. See function cma_init_reserved_mem() * @res_cma: Pointer to store the created cma region. +* @nid: nid of the free area to find, %NUMA_NO_NODE for any node * * This function reserves memory from early allocator. It should be * called by arch specific code once the early allocator (memblock or bootmem)
mm/cma.c int __init cma_init_reserved_mem(phys_addr_t base,
Quoted 1 line
mm/cma.c +0
-0@@ -238,10 +239,11 @@ int __init cma_init_reserved_mem(phys_addr_t base,
phys_addr_tsize,mm/cma.c int __init cma_init_reserved_mem(phys_addr_t base, · line 239
Quoted 1 line
mm/cma.c +0
-0* If @fixed is true, reserve contiguous area at exactly @base. If false,
Quoted 13 lines
mm/cma.c +3
-2* reserve in range from @base to @limit. */ -int __init cma_declare_contiguous (phys_addr_t base, +int __init cma_declare_contiguous_nid (phys_addr_t base,phys_addr_t size,phys_addr_t limit,phys_addr_t alignment,unsigned int order_per_bit, -bool fixed,const char *name,struct cma **res_cma) +bool fixed,const char *name,struct cma **res_cma, +int nid) {phys_addr_t memblock_end =memblock_end_of_DRAM ();phys_addr_t highmem_start;mm/cma.c int __init cma_declare_contiguous(phys_addr_t base, · line 340
Quoted 5 lines
mm/cma.c +0
-2@@ -336,14 +338,14 @@ int __init cma_declare_contiguous(phys_addr_t base,* memory in case of failure. */ if (base < highmem_start && limit > highmem_start) { - addr = memblock_phys_alloc_range(size, alignment, - highmem_start,limit);
mm/cma.c int __init cma_declare_contiguous(phys_addr_t base,
Quoted 7 lines
mm/cma.c +2
-1+ addr =memblock_alloc_range_nid (size, alignment, + highmem_start, limit, nid, false); limit = highmem_start; }if (!addr) { - addr = memblock_phys_alloc_range(size, alignment,base,
mm/cma.c int __init cma_declare_contiguous(phys_addr_t base, · line 347
Quoted 2 lines
mm/cma.c +1
-1- limit); + addr = memblock_alloc_range_nid(size, alignment,base,
mm/memblock.c __next_mem_pfn_range_in_zone(u64 *idx, struct zone
Quoted 9 lines
mm/cma.c +1
-0+ alimit, nid, false);if (!addr) { ret = -ENOMEM ; goto err;mm/memblock.c +0
-0@@ -1349,7 +1349,7 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone*zone,
mm/memblock.c __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone,
Quoted 6 lines
mm/memblock.c +1
-1* Return: * Physical address of allocated memory block on success, %0 on failure. */ -static phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size, +phys_addr_t __init memblock_alloc_range_nid (phys_addr_t size, phys_addr_t align, phys_addr_tstart,
Quoted 6 lines
mm/memblock.c +0
-1phys_addr_t end, int nid, bool exact_nid) --2.24.1
Quoted 16 lines · Aslan Bakirov
Quoted 14 lines · Ira Weiny
Quoted 1 line · Aslan Bakirov
I've noticed that there is no interfaces exposed by CMA which would let
me
Quoted 8 lines
to declare contigous memory on particular NUMA node.
This patchset adds the ability to try to allocate contiguous memory on specific node. It will fallback to other nodes if the specified one doesn't work.
Implement a new method for declaring contigous memory on particular node and keep
cma_declare_contiguous()as a wrapper.Is there an additional patch which uses this new interface?
Quoted 7 lines
Quoted 1 line
Generally the patch seems reasonable but we should have a user.
Thanks for the comments. Yes, actually, this is the version 3 of first
patch ([PATCH 1/2] mm: cma: NUMA node interface)
of patchset. Second patch, which uses this interface is "[PATCH 2/2] mm:
hugetlb: Use node interface of cma"
It would have been much more clear to send those two patches together as you can see.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 23 lines · Michal Hocko
Quoted 4 lines · Aslan Bakirov
Quoted 2 lines · Ira Weiny
Quoted 1 line · Aslan Bakirov
I've noticed that there is no interfaces exposed by CMA which would
let
Quoted 4 lines
Quoted 4 lines
me
Quoted 3 lines
to declare contigous memory on particular NUMA node.
This patchset adds the ability to try to allocate contiguous memory
on
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
specific node. It will fallback to other nodes if the specified one doesn't work.
Implement a new method for declaring contigous memory on particular
node
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
and keep
cma_declare_contiguous()as a wrapper.Is there an additional patch which uses this new interface?
Generally the patch seems reasonable but we should have a user.
Quoted 9 lines
Quoted 3 lines
Thanks for the comments. Yes, actually, this is the version 3 of first
patch ([PATCH 1/2] mm: cma: NUMA node interface)
of patchset. Second patch, which uses this interface is "[PATCH 2/2]mm:
Quoted 1 line
hugetlb: Use node interface of cma"
It would have been much more clear to send those two patches together as you can see.
Sincerely apologies, sent them again.
Quoted 4 lines
--
Michal Hocko
SUSE Labs