mm, memory_hotplug: update pcp lists everytime onlining a memory block
Subsystems (2)
PATCH 1/1 mm, memory_hotplug: update pcp lists everytime onlining a memory block
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus free_pcppages_bulk() is called to free batch size(=1) pages every time system wants to add a page to the pcp list through free_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/memory_hotplug.c +1 -2
@@ -854,8 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,node_states_set_node (nid, &arg);if (need_zonelists_rebuild)build_all_zonelists (NULL ); -else -zone_pcp_update (zone); +zone_pcp_update (zone);init_per_zone_wmark_min ();
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 10 lines · Charan Teja Reddy
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus
free_pcppages_bulk()is called to free batch size(=1) pages every time system wants to add a page to the pcp list throughfree_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
I guess such setups are rare ... but I can imagine it being the case with virtio-mem in the future ... not 100% if this performance optimization is really relevant in practice ... how did you identify this?
Quoted 12 lines
Signed-off-by Charan Teja Reddy <[email protected]>--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/memory_hotplug.c +0
-0
mm/memory_hotplug.c int __ref online_pages(unsigned long pfn, unsigned long nr_pages, · line 860
Quoted 9 lines
mm/memory_hotplug.c +1
-2@@ -854,8 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,node_states_set_node (nid, &arg);if (need_zonelists_rebuild)build_all_zonelists (NULL ); -else -zone_pcp_update (zone); +zone_pcp_update (zone);init_per_zone_wmark_min ();
Does, in general, look sane to me.
Signature · 3 lines
Thanks, David / dhildenb
Thanks David for the comments.
Quoted 12 lines · David Hildenbrand
Quoted 10 lines · Charan Teja Reddy
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus
free_pcppages_bulk()is called to free batch size(=1) pages every time system wants to add a page to the pcp list throughfree_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
Quoted 3 lines
I guess such setups are rare ... but I can imagine it being the case with virtio-mem in the future ... not 100% if this performance optimization is really relevant in practice ... how did you identify this?
Even the Snapdragon hardware that I had tested on contain multiple onlineable memory blocks. But we have the use case in which we online single memory block and once it is filled then online the next block. In the step where single block is onlined, we observed the below pageset params.
pagesets
cpu: 0
count: 0
high: 0
batch: 1
Once the second block is onlined then only seeing some sane values as below.
cpu: 0
count: 32
high: 378
batch: 63In the above case, till the second block is onlined, no page is held in the pcp list. So, updating the pcp params every time when onlining the memory block is required, as an example in the usecase that I had mentioned.
Quoted 19 lines
Quoted 19 lines
Signed-off-by Charan Teja Reddy <[email protected]>--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/memory_hotplug.c +1
-2@@ -854,8 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,node_states_set_node (nid, &arg);if (need_zonelists_rebuild)build_all_zonelists (NULL ); -else -zone_pcp_update (zone); +zone_pcp_update (zone);
Quoted 7 lines
mm/memory_hotplug.c int __ref online_pages(unsigned long pfn, unsigned long nr_pages, · line 860
Quoted 3 lines
mm/memory_hotplug.c +0
-0init_per_zone_wmark_min ();Does, in general, look sane to me.
Reviewed-by David Hildenbrand <[email protected]>
Thanks for the ACK.
Quoted 1 line
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 15 lines · Charan Teja Kalla
Thanks David for the comments.
Quoted 12 lines · David Hildenbrand
Quoted 10 lines · Charan Teja Reddy
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus
free_pcppages_bulk()is called to free batch size(=1) pages every time system wants to add a page to the pcp list throughfree_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
Quoted 8 lines
Quoted 3 lines
I guess such setups are rare ... but I can imagine it being the case with virtio-mem in the future ... not 100% if this performance optimization is really relevant in practice ... how did you identify this?
Even the Snapdragon hardware that I had tested on contain multiple onlineable memory blocks. But we have the use case in which we online single memory block and once it is filled then online the next block. In the step where single block is onlined, we observed the below pageset
Out of interest, why? Is it to optimize energy consumption?
Signature · 3 lines
Thanks, David / dhildenb
Quoted 11 lines · Charan Teja Reddy
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus
free_pcppages_bulk()is called to free batch size(=1) pages every time system wants to add a page to the pcp list throughfree_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
Quoted 1 line
Signed-off-by Charan Teja Reddy <[email protected]>
Makes sense to me.
Quoted 19 lines
--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/memory_hotplug.c +1
-2@@ -854,8 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,node_states_set_node (nid, &arg);if (need_zonelists_rebuild)build_all_zonelists (NULL ); -else -zone_pcp_update (zone); +zone_pcp_update (zone);init_per_zone_wmark_min ();
Quoted 10 lines · Charan Teja Reddy
When onlining a first memory block in a zone, pcp lists are not updated thus pcp struct will have the default setting of ->high = 0,->batch = 1. This means till the second memory block in a zone(if it have) is onlined the pcp lists of this zone will not contain any pages because pcp's ->count is always greater than ->high thus
free_pcppages_bulk()is called to free batch size(=1) pages every time system wants to add a page to the pcp list throughfree_unref_page(). To put this in a word, system is not using benefits offered by the pcp lists when there is a single onlineable memory block in a zone. Correct this by always updating the pcp lists when memory block is onlined.
Yes this seems like an ancient bug
Just nobody has noticed because a single block memory zone is really rare.
Quoted 1 line
Signed-off-by Charan Teja Reddy <[email protected]>
Thanks
Quoted 22 lines
--- mm/memory_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/memory_hotplug.c +1
-2@@ -854,8 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,node_states_set_node (nid, &arg);if (need_zonelists_rebuild)build_all_zonelists (NULL ); -else -zone_pcp_update (zone); +zone_pcp_update (zone);init_per_zone_wmark_min ();Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
Michal Hocko SUSE Labs