Skip to contentSkip to conversation

mm/sparse: use __nr_to_section(section_nr) to get mem_section

PATCH In review Wei Yang 3 participants 3 messages Aug 9, 2019

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/sparse: use __nr_to_section(section_nr) to get mem_section

__pfn_to_section is defined as __nr_to_section(pfn_to_section_nr(pfn)).

Since we already get section_nr, it is not necessary to get mem_section from start_pfn. By doing so, we reduce one redundant operation.

---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
index 72f010d9bff5..95158a148cd1 100644
@@ -867,7 +867,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
 
-	ms = __pfn_to_section(start_pfn);
+	ms = __nr_to_section(section_nr);
 	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Wei Yang

__pfn_to_section is defined as __nr_to_section(pfn_to_section_nr(pfn)).

Right.

Quoted 5 lines

Since we already get section_nr, it is not necessary to get mem_section from start_pfn. By doing so, we reduce one redundant operation.

Looks right.

With this applied, memory hot add still works on arm64.

Quoted 18 lines
---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
index 72f010d9bff5..95158a148cd1 100644
@@ -867,7 +867,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
 
-	ms = __pfn_to_section(start_pfn);
+	ms = __nr_to_section(section_nr);
 	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 
#2 lore raw
Quoted 8 lines · Anshuman Khandual
Quoted 1 line · Wei Yang

__pfn_to_section is defined as __nr_to_section(pfn_to_section_nr(pfn)).

Right.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Since we already get section_nr, it is not necessary to get mem_section from start_pfn. By doing so, we reduce one redundant operation.

Looks right.

With this applied, memory hot add still works on arm64.

Thanks for your test.

Quoted 21 lines
Quoted 18 lines
---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
index 72f010d9bff5..95158a148cd1 100644
@@ -867,7 +867,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
 
-	ms = __pfn_to_section(start_pfn);
+	ms = __nr_to_section(section_nr);
 	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 
Signature · 2 lines
Wei Yang
Help you, Help me