Skip to contentSkip to conversation

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

PATCH Superseded Wei Yang 4 participants 7 messages Jun 16, 2019 – Jun 18, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

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

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.

---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index fd13166949b5..3ba8f843cb7a 100644
@@ -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);
 
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Wei Yang

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.

Quoted 2 lines

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

It does.

Quoted 1 line

But the granularity of node id should be mem_section wide.

Right.

Quoted 2 lines
author
#2 lore raw
Quoted 11 lines · Anshuman Khandual
Quoted 2 lines · Wei Yang

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.

Quoted 2 lines

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

It does.

Quoted 8 lines
Quoted 1 line

But the granularity of node id should be mem_section wide.

Right.

Quoted 2 lines

Thanks

Signature · 2 lines
Wei Yang
Help you, Help me
Reviewed-by on v1 1/1
#3 lore raw
In reply to Wei Yang
Quoted 5 lines · Wei Yang

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.

Quoted 12 lines
---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +0 -0
index fd13166949b5..3ba8f843cb7a 100644

mm/sparse.c int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, · line 741

Quoted 7 lines
mm/sparse.c +1 -0
@@ -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

Signature · 3 lines
Thanks,

David / dhildenb
author
#4 lore raw
Quoted 9 lines · David Hildenbrand
Quoted 5 lines · Wei Yang

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.

Quoted 30 lines
Quoted 12 lines
---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +0 -0
index fd13166949b5..3ba8f843cb7a 100644

mm/sparse.c int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, · line 741

Quoted 7 lines
mm/sparse.c +1 -0
@@ -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

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Wei Yang
Help you, Help me
Reviewed-by on v1 1/1
#5 lore raw
In reply to Wei Yang
Quoted 7 lines · Wei Yang

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.

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).

Quoted 19 lines
---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index fd13166949b5..3ba8f843cb7a 100644
@@ -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);
 
Signature · 1 line
2.19.1
Signature · 2 lines
Oscar Salvador
SUSE L3
author
#6 lore raw
Quoted 7 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

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.

Quoted 7 lines
Quoted 1 line

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.

Quoted 25 lines
Quoted 19 lines
---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index fd13166949b5..3ba8f843cb7a 100644
@@ -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);
 
Signature · 1 line
2.19.1
Signature · 2 lines
Oscar Salvador
SUSE L3
Signature · 2 lines
Wei Yang
Help you, Help me