diff mbox series

mm/sparse: set section nid for hot-add memory

Message ID 20190616023554.19316-1-richardw.yang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series mm/sparse: set section nid for hot-add memory | expand

Commit Message

Wei Yang June 16, 2019, 2:35 a.m. UTC
section_to_node_table[] is used to record section's node id, which is
used in page_to_nid(). While for hot-add memory, this is missed.

BTW, current online_pages works because it leverages nid in memory_block.
But the granularity of node id should be mem_section wide.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Anshuman Khandual June 17, 2019, 4:23 a.m. UTC | #1
On 06/16/2019 08:05 AM, Wei Yang wrote:
> section_to_node_table[] is used to record section's node id, which is
> used in page_to_nid(). While for hot-add memory, this is missed.

Used for NODE_NOT_IN_PAGE_FLAGS case and it is missed for hot-added memory.

> 
> BTW, current online_pages works because it leverages nid in memory_block.

It does.

> But the granularity of node id should be mem_section wide.

Right.

> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Wei Yang June 17, 2019, 8:46 a.m. UTC | #2
On Mon, Jun 17, 2019 at 09:53:05AM +0530, Anshuman Khandual wrote:
>On 06/16/2019 08:05 AM, Wei Yang wrote:
>> section_to_node_table[] is used to record section's node id, which is
>> used in page_to_nid(). While for hot-add memory, this is missed.
>
>Used for NODE_NOT_IN_PAGE_FLAGS case and it is missed for hot-added memory.
>
>> 
>> BTW, current online_pages works because it leverages nid in memory_block.
>
>It does.
>
>> But the granularity of node id should be mem_section wide.
>
>Right.
>
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>
>Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

Thanks
David Hildenbrand June 17, 2019, 1:13 p.m. UTC | #3
On 16.06.19 04:35, Wei Yang wrote:
> section_to_node_table[] is used to record section's node id, which is
> used in page_to_nid(). While for hot-add memory, this is missed.
> 
> BTW, current online_pages works because it leverages nid in memory_block.
> But the granularity of node id should be mem_section wide.

set_section_nid() is only relevant if the NID is not part of the vmemmaps.

> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  mm/sparse.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index fd13166949b5..3ba8f843cb7a 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -735,6 +735,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
>  	 */
>  	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
>  
> +	set_section_nid(section_nr, nid);
>  	section_mark_present(ms);
>  	sparse_init_one_section(ms, section_nr, memmap, usemap);
>  
> 

Although I dislike basically all of the current ->nid design, this seems
to be the right thing to do

Reviewed-by: David Hildenbrand <david@redhat.com>
Oscar Salvador June 17, 2019, 3:43 p.m. UTC | #4
On Sun, Jun 16, 2019 at 10:35:54AM +0800, Wei Yang wrote:
> section_to_node_table[] is used to record section's node id, which is
> used in page_to_nid(). While for hot-add memory, this is missed.
> 
> BTW, current online_pages works because it leverages nid in memory_block.
> But the granularity of node id should be mem_section wide.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

While the patch is valid, I think that the changelog could be improved a bit.
For example, I would point out the possible problems we can face if it is not set
properly (e.g: page_to_nid() operations failing to give the right node) and when
section_to_node_table[] is used (NODE_NOT_IN_PAGE_FLAGS scenario).

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  mm/sparse.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index fd13166949b5..3ba8f843cb7a 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -735,6 +735,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
>  	 */
>  	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
>  
> +	set_section_nid(section_nr, nid);
>  	section_mark_present(ms);
>  	sparse_init_one_section(ms, section_nr, memmap, usemap);
>  
> -- 
> 2.19.1
>
Wei Yang June 18, 2019, 12:36 a.m. UTC | #5
On Mon, Jun 17, 2019 at 03:13:33PM +0200, David Hildenbrand wrote:
>On 16.06.19 04:35, Wei Yang wrote:
>> section_to_node_table[] is used to record section's node id, which is
>> used in page_to_nid(). While for hot-add memory, this is missed.
>> 
>> BTW, current online_pages works because it leverages nid in memory_block.
>> But the granularity of node id should be mem_section wide.
>
>set_section_nid() is only relevant if the NID is not part of the vmemmaps.
>

Yep, you are right.

>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  mm/sparse.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index fd13166949b5..3ba8f843cb7a 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -735,6 +735,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
>>  	 */
>>  	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
>>  
>> +	set_section_nid(section_nr, nid);
>>  	section_mark_present(ms);
>>  	sparse_init_one_section(ms, section_nr, memmap, usemap);
>>  
>> 
>
>Although I dislike basically all of the current ->nid design, this seems
>to be the right thing to do
>
>Reviewed-by: David Hildenbrand <david@redhat.com>
>
>-- 
>
>Thanks,
>
>David / dhildenb
Wei Yang June 18, 2019, 12:45 a.m. UTC | #6
On Mon, Jun 17, 2019 at 05:43:25PM +0200, Oscar Salvador wrote:
>On Sun, Jun 16, 2019 at 10:35:54AM +0800, Wei Yang wrote:
>> section_to_node_table[] is used to record section's node id, which is
>> used in page_to_nid(). While for hot-add memory, this is missed.
>> 
>> BTW, current online_pages works because it leverages nid in memory_block.
>> But the granularity of node id should be mem_section wide.
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>
>While the patch is valid, I think that the changelog could be improved a bit.
>For example, I would point out the possible problems we can face if it is not set
>properly (e.g: page_to_nid() operations failing to give the right node) and when
>section_to_node_table[] is used (NODE_NOT_IN_PAGE_FLAGS scenario).
>

Thanks, let me give more words on this.

>Reviewed-by: Oscar Salvador <osalvador@suse.de>
>
>> ---
>>  mm/sparse.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index fd13166949b5..3ba8f843cb7a 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -735,6 +735,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
>>  	 */
>>  	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
>>  
>> +	set_section_nid(section_nr, nid);
>>  	section_mark_present(ms);
>>  	sparse_init_one_section(ms, section_nr, memmap, usemap);
>>  
>> -- 
>> 2.19.1
>> 
>
>-- 
>Oscar Salvador
>SUSE L3
diff mbox series

Patch

diff --git a/mm/sparse.c b/mm/sparse.c
index fd13166949b5..3ba8f843cb7a 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -735,6 +735,7 @@  int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
 
+	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 	sparse_init_one_section(ms, section_nr, memmap, usemap);