diff mbox series

[v5,2/2] mm/sparse.c: allocate memmap preferring the given node

Message ID 20200316125625.GH3486@MiWiFi-R3L-srv (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Baoquan He March 16, 2020, 12:56 p.m. UTC
When allocating memmap for hot added memory with the classic sparse, the
specified 'nid' is ignored in populate_section_memmap().

While in allocating memmap for the classic sparse during boot, the node
given by 'nid' is preferred. And VMEMMAP prefers the node of 'nid' in
both boot stage and memory hot adding. So seems no reason to not respect
the node of 'nid' for the classic sparse when hot adding memory.

Use kvmalloc_node instead to use the passed in 'nid'.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/sparse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pankaj Gupta March 16, 2020, 4:28 p.m. UTC | #1
> When allocating memmap for hot added memory with the classic sparse, the
> specified 'nid' is ignored in populate_section_memmap().
>
> While in allocating memmap for the classic sparse during boot, the node
> given by 'nid' is preferred. And VMEMMAP prefers the node of 'nid' in
> both boot stage and memory hot adding. So seems no reason to not respect
> the node of 'nid' for the classic sparse when hot adding memory.
>
> Use kvmalloc_node instead to use the passed in 'nid'.
>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/sparse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 3fa407d7f70a..31dcdfb55c72 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -719,8 +719,8 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages)
>  struct page * __meminit populate_section_memmap(unsigned long pfn,
>                 unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
>  {
> -       return kvmalloc(array_size(sizeof(struct page),
> -                                  PAGES_PER_SECTION), GFP_KERNEL);
> +       return kvmalloc_node(array_size(sizeof(struct page),
> +                                       PAGES_PER_SECTION), GFP_KERNEL, nid);
>  }
>
>  static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
> --

Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>

> 2.17.2
>
>
David Hildenbrand March 16, 2020, 4:29 p.m. UTC | #2
On 16.03.20 13:56, Baoquan He wrote:
> When allocating memmap for hot added memory with the classic sparse, the
> specified 'nid' is ignored in populate_section_memmap().
> 
> While in allocating memmap for the classic sparse during boot, the node
> given by 'nid' is preferred. And VMEMMAP prefers the node of 'nid' in
> both boot stage and memory hot adding. So seems no reason to not respect
> the node of 'nid' for the classic sparse when hot adding memory.
> 
> Use kvmalloc_node instead to use the passed in 'nid'.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/sparse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 3fa407d7f70a..31dcdfb55c72 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -719,8 +719,8 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages)
>  struct page * __meminit populate_section_memmap(unsigned long pfn,
>  		unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
>  {
> -	return kvmalloc(array_size(sizeof(struct page),
> -				   PAGES_PER_SECTION), GFP_KERNEL);
> +	return kvmalloc_node(array_size(sizeof(struct page),
> +					PAGES_PER_SECTION), GFP_KERNEL, nid);
>  }
>  
>  static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
Wei Yang March 16, 2020, 10:16 p.m. UTC | #3
On Mon, Mar 16, 2020 at 08:56:25PM +0800, Baoquan He wrote:
>When allocating memmap for hot added memory with the classic sparse, the
>specified 'nid' is ignored in populate_section_memmap().
>
>While in allocating memmap for the classic sparse during boot, the node
>given by 'nid' is preferred. And VMEMMAP prefers the node of 'nid' in
>both boot stage and memory hot adding. So seems no reason to not respect
>the node of 'nid' for the classic sparse when hot adding memory.
>
>Use kvmalloc_node instead to use the passed in 'nid'.
>
>Signed-off-by: Baoquan He <bhe@redhat.com>
>Acked-by: Michal Hocko <mhocko@suse.com>
>Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Baoquan He March 24, 2020, 1:07 a.m. UTC | #4
Hi Andrew,

On 03/16/20 at 08:56pm, Baoquan He wrote:
> When allocating memmap for hot added memory with the classic sparse, the
> specified 'nid' is ignored in populate_section_memmap().
> 
> While in allocating memmap for the classic sparse during boot, the node
> given by 'nid' is preferred. And VMEMMAP prefers the node of 'nid' in
> both boot stage and memory hot adding. So seems no reason to not respect
> the node of 'nid' for the classic sparse when hot adding memory.
> 
> Use kvmalloc_node instead to use the passed in 'nid'.

Just checked linux-next, seems this one is missed. Michal suggested
splitting the old v4 into two patches, this patch is to use the passed
in 'nid' to allocate memmap with !VMEMMAP.

Thanks
Baoquan

> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/sparse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 3fa407d7f70a..31dcdfb55c72 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -719,8 +719,8 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages)
>  struct page * __meminit populate_section_memmap(unsigned long pfn,
>  		unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
>  {
> -	return kvmalloc(array_size(sizeof(struct page),
> -				   PAGES_PER_SECTION), GFP_KERNEL);
> +	return kvmalloc_node(array_size(sizeof(struct page),
> +					PAGES_PER_SECTION), GFP_KERNEL, nid);
>  }
>  
>  static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
> -- 
> 2.17.2
> 
>
diff mbox series

Patch

diff --git a/mm/sparse.c b/mm/sparse.c
index 3fa407d7f70a..31dcdfb55c72 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -719,8 +719,8 @@  static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages)
 struct page * __meminit populate_section_memmap(unsigned long pfn,
 		unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
 {
-	return kvmalloc(array_size(sizeof(struct page),
-				   PAGES_PER_SECTION), GFP_KERNEL);
+	return kvmalloc_node(array_size(sizeof(struct page),
+					PAGES_PER_SECTION), GFP_KERNEL, nid);
 }
 
 static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,