Skip to contentSkip to conversation

mm/page_alloc: call set_pageblock_order() once for each node

PATCH In review Wei Yang 3 participants 7 messages Mar 29, 2018 – Apr 6, 2018

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/page_alloc: call set_pageblock_order() once for each node

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index 8c964dcc3a9e..828f5014b006 100644
@@ -6169,7 +6169,6 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)
 		if (!size)
 			continue;
 
-		set_pageblock_order();
 		setup_usemap(pgdat, zone, zone_start_pfn, size);
 		init_currently_empty_zone(zone, zone_start_pfn, size);
 		memmap_init(size, nid, j, zone_start_pfn);
@@ -6254,6 +6253,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
 	alloc_node_mem_map(pgdat);
 
 	reset_deferred_meminit(pgdat);
+	set_pageblock_order();
 	free_area_init_core(pgdat);
 }
 
Signature · 1 line
2.15.1
#1 lore raw
Quoted 9 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

Signature · 2 lines
Mel Gorman
SUSE Labs
author
#2 lore raw
Quoted 9 lines · Mel Gorman
Quoted 8 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

Quoted 5 lines
Quoted 1 line

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

No, I don't expect measurable improvement from this since the number of nodes and zones are limited.

This is just a code refine from logic point of view.

Quoted 4 lines
Signature · 3 lines
-- 
Mel Gorman
SUSE Labs
Signature · 2 lines
Wei Yang
Help you, Help me
reviewer
#3 lore raw
Quoted 12 lines · Wei Yang
Quoted 11 lines · Mel Gorman
Quoted 9 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

Quoted 8 lines
Quoted 3 lines

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

No, I don't expect measurable improvement from this since the number of nodes and zones are limited.

This is just a code refine from logic point of view.

Then, please make sure it is a real refinement. Calling this function per node is only half way to get there as the function is by no means per node.

Signature · 2 lines
Michal Hocko
SUSE Labs
author
#4 lore raw
Quoted 17 lines · Michal Hocko
Quoted 16 lines · Wei Yang
Quoted 14 lines · Mel Gorman
Quoted 9 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

Quoted 9 lines
Quoted 4 lines

No, I don't expect measurable improvement from this since the number of nodes and zones are limited.

This is just a code refine from logic point of view.

Then, please make sure it is a real refinement. Calling this function per node is only half way to get there as the function is by no means per node.

Hi, Michal

I guess you are willing to see this function is only called once for the whole system.

Yes, that is the ideal way, well I don't come up with an elegant way. The best way is to move this to free_area_init_nodes(), while you can see not all arch use this function.

Then I have two options:

A: Move this to free_area_init_nodes() for those arch using it. Call it specifically for those arch not using free_area_init_nodes().

B: call it before setup_arch() in start_kernel()

Hmm... which one you would prefer? If you have a better idea, that would be great.

Quoted 3 lines
Signature · 2 lines
Michal Hocko
SUSE Labs
Signature · 2 lines
Wei Yang
Help you, Help me
reviewer
#5 lore raw
Quoted 39 lines · Wei Yang
Quoted 17 lines · Michal Hocko
Quoted 16 lines · Wei Yang
Quoted 14 lines · Mel Gorman
Quoted 9 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

Quoted 9 lines
Quoted 4 lines

No, I don't expect measurable improvement from this since the number of nodes and zones are limited.

This is just a code refine from logic point of view.

Then, please make sure it is a real refinement. Calling this function per node is only half way to get there as the function is by no means per node.

Hi, Michal

I guess you are willing to see this function is only called once for the whole system.

Yes, that is the ideal way, well I don't come up with an elegant way. The best way is to move this to free_area_init_nodes(), while you can see not all arch use this function.

Then I have two options:

Quoted 7 lines

A: Move this to free_area_init_nodes() for those arch using it. Call it specifically for those arch not using free_area_init_nodes().

B: call it before setup_arch() in start_kernel()

Hmm... which one you would prefer? If you have a better idea, that would be great.

or
C: do nothing and/or just document why do we call it this way (convenience).

Signature · 2 lines
Michal Hocko
SUSE Labs
author
#6 lore raw
Quoted 43 lines · Michal Hocko
Quoted 42 lines · Wei Yang
Quoted 17 lines · Michal Hocko
Quoted 16 lines · Wei Yang
Quoted 14 lines · Mel Gorman
Quoted 9 lines · Wei Yang

set_pageblock_order() is a standalone function which sets pageblock_order, while current implementation calls this function on each ZONE of each node in free_area_init_core().

Since free_area_init_node() is the only user of free_area_init_core(), this patch moves set_pageblock_order() up one level to invoke set_pageblock_order() only once on each node.

The patch looks ok but given that set_pageblock_order returns immediately if it has already been called, I expect the benefit is marginal. Was any improvement in boot time measured?

Quoted 9 lines
Quoted 4 lines

No, I don't expect measurable improvement from this since the number of nodes and zones are limited.

This is just a code refine from logic point of view.

Then, please make sure it is a real refinement. Calling this function per node is only half way to get there as the function is by no means per node.

Hi, Michal

I guess you are willing to see this function is only called once for the whole system.

Yes, that is the ideal way, well I don't come up with an elegant way. The best way is to move this to free_area_init_nodes(), while you can see not all arch use this function.

Then I have two options:

A: Move this to free_area_init_nodes() for those arch using it. Call it specifically for those arch not using free_area_init_nodes().

Quoted 8 lines
Quoted 4 lines

B: call it before setup_arch() in start_kernel()

Hmm... which one you would prefer? If you have a better idea, that would be great.

or
C: do nothing and/or just document why do we call it this way (convenience).

Ok, maybe we can leave it alone now.

Quoted 3 lines
Signature · 2 lines
Michal Hocko
SUSE Labs
Signature · 2 lines
Wei Yang
Help you, Help me