memory-hotplug: fix a drain pcp bug when offline pages
Subsystems (2)
PATCH 1/1 memory-hotplug: fix a drain pcp bug when offline pages
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into MIGRATE_ISOLATE list first. start_isolate_page_range()
set_migratetype_isolate() drain_all_pages(),
Here is a problem, it is not sure that pcp will be moved into MIGRATE_ISOLATE list. They may be moved into MIGRATE_MOVABLE list because page_private() maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild in check_pages_isolated(). drain_all_pages()
drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));
If we add move_freepages_block() after drain_all_pages(), it can not sure that all the pcp will be moved into MIGRATE_ISOLATE list when the system works on high load. The free pages which from pcp may immediately be allocated again.
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
--- mm/page_alloc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
mm/page_alloc.c +2 -1
@@ -673,7 +673,8 @@ static void free_pcppages_bulk(struct zone *zone, int count,/* must delete as __free_one_page list manipulates */ list_del (&page->lru);/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ -__free_one_page (page, zone,0 ,page_private (page)); +__free_one_page (page, zone,0 , +get_pageblock_migratetype (page));trace_mm_page_pcpu_drain (page,0 ,page_private (page)); }while (--to_free && --batch_free && !list_empty (list)); }
-- 1.7.6.1 .
.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello Xishi,
Quoted 16 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));
Quoted 5 lines
If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely. Get_pageblock_migratetype is never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?
Quoted 32 lines
Signed-off-by Xishi Qiu <[email protected]>--- mm/page_alloc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)mm/page_alloc.c +2
-2@@ -673,7 +673,8 @@ static void free_pcppages_bulk(struct zone *zone, int count,/* must delete as __free_one_page list manipulates */ list_del (&page->lru);/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ -__free_one_page (page, zone,0 ,page_private (page)); +__free_one_page (page, zone,0 , +get_pageblock_migratetype (page));trace_mm_page_pcpu_drain (page,0 ,page_private (page)); }while (--to_free && --batch_free && !list_empty (list)); } -- 1.7.6.1 ..
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 23 lines · Minchan Kim
Hello Xishi,
Quoted 20 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.
Quoted 7 lines
Quoted 1 line
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
I use /sys/devices/system/memory/soft_offline_page to offline a lot of pages when the system works on high load, then I find some unknown zero refcount pages, such asget_any_page: 0x650422: unknown zero refcount page type 19400c00000000get_any_page: 0x650867: unknown zero refcount page type 19400c00000000
soft_offline_page()
get_any_page() set_migratetype_isolate() drain_all_pages()
I think after drain_all_pages(), pcp are moved into MIGRATE_MOVABLE list which managed by buddy allocator, but they are allocated and becaome pcp again as the system works on high load. There will be no this problem by applying this patch.
Quoted 4 lines
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely.
Get_pageblock_migratetypeis never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?
Yes, you are right, I will try to find another way to fix this problem.
How about doing this work in set_migratetype_isolate(), find the pcp and change the value of private to get_pageblock_migratetype(page)?
Thanks
Xishi Qiu
Quoted 25 lines
Quoted 25 lines
Signed-off-by Xishi Qiu <[email protected]>--- mm/page_alloc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)mm/page_alloc.c +2
-2@@ -673,7 +673,8 @@ static void free_pcppages_bulk(struct zone *zone, int count,/* must delete as __free_one_page list manipulates */ list_del (&page->lru);/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ -__free_one_page (page, zone,0 ,page_private (page)); +__free_one_page (page, zone,0 , +get_pageblock_migratetype (page));trace_mm_page_pcpu_drain (page,0 ,page_private (page)); }while (--to_free && --batch_free && !list_empty (list)); } -- 1.7.6.1 .
Quoted 8 lines
Quoted 7 lines
.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 46 lines · qiuxishi
Quoted 23 lines · Minchan Kim
Hello Xishi,
Quoted 20 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.Quoted 7 lines
Quoted 1 line
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
I use
/sys/devices/system/memory/soft_offline_pageto offline a lot of pages when the system works on high load, then I find some unknown zero refcount pages, such asget_any_page:0x650422: unknown zero refcount page type19400c00000000get_any_page:0x650867: unknown zero refcount page type19400c00000000
soft_offline_page()get_any_page() set_migratetype_isolate() drain_all_pages()I think after
drain_all_pages(), pcp are moved intoMIGRATE_MOVABLElist which managed by buddy allocator, but they are allocated and becaome pcp again as the system works on high load. There will be no this problem by applying this patch.
Quoted 9 lines
Quoted 4 lines
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely.
Get_pageblock_migratetypeis never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?Yes, you are right, I will try to find another way to fix this problem.
How about doing this work inset_migratetype_isolate(), find the pcp and change the value of private toget_pageblock_migratetype(page)?
Allocator doesn't have any lock when he allocates the page from pcp. How could you prevent race between allocator and memory-hotplug routine(ie, set_migratetype_isolate) without hurting hotpath?
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 52 lines · Minchan Kim
Quoted 51 lines · qiuxishi
Quoted 23 lines · Minchan Kim
Hello Xishi,
Quoted 20 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.Quoted 7 lines
Quoted 1 line
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
I use
/sys/devices/system/memory/soft_offline_pageto offline a lot of pages when the system works on high load, then I find some unknown zero refcount pages, such asget_any_page:0x650422: unknown zero refcount page type19400c00000000get_any_page:0x650867: unknown zero refcount page type19400c00000000
soft_offline_page()get_any_page() set_migratetype_isolate() drain_all_pages()I think after
drain_all_pages(), pcp are moved intoMIGRATE_MOVABLElist which managed by buddy allocator, but they are allocated and becaome pcp again as the system works on high load. There will be no this problem by applying this patch.Quoted 4 lines
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely.
Get_pageblock_migratetypeis never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?
Quoted 8 lines
Quoted 4 lines
Yes, you are right, I will try to find another way to fix this problem.
How about doing this work inset_migratetype_isolate(), find the pcp and change the value of private toget_pageblock_migratetype(page)?Allocator doesn't have any lock when he allocates the page from pcp. How could you prevent race between allocator and memory-hotplug
routine(ie, set_migratetype_isolate)without hurting hotpath?
Hi Minchan,
I have thought about using a jump label in the hot path, which won't cause big
performance drop, but it seems a little dirty. What's your thoughts?
migrate_type = page_private(page); if (static_key_false(&memory_hotplug_inprogress)) migrate_type = get_pageblock_migratetype(page); __free_one_page(page, zone, 0, migrate_type); Regards! Gerry
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi Jiang,
Quoted 58 lines · Jiang Liu
Quoted 57 lines · Minchan Kim
Quoted 55 lines · qiuxishi
Quoted 23 lines · Minchan Kim
Hello Xishi,
Quoted 20 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.Quoted 7 lines
Quoted 1 line
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
I use
/sys/devices/system/memory/soft_offline_pageto offline a lot of pages when the system works on high load, then I find some unknown zero refcount pages, such asget_any_page:0x650422: unknown zero refcount page type19400c00000000get_any_page:0x650867: unknown zero refcount page type19400c00000000
soft_offline_page()get_any_page() set_migratetype_isolate() drain_all_pages()I think after
drain_all_pages(), pcp are moved intoMIGRATE_MOVABLElist which managed by buddy allocator, but they are allocated and becaome pcp again as the system works on high load. There will be no this problem by applying this patch.Quoted 4 lines
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely.
Get_pageblock_migratetypeis never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?Yes, you are right, I will try to find another way to fix this problem.
How about doing this work inset_migratetype_isolate(), find the pcp and change the value of private toget_pageblock_migratetype(page)?
Quoted 6 lines
Quoted 3 lines
Allocator doesn't have any lock when he allocates the page from pcp. How could you prevent race between allocator and memory-hotplug
routine(ie, set_migratetype_isolate)without hurting hotpath?Hi Minchan,
I have thought about using a jump label in the hot path, which won't cause big
performance drop, but it seems a little dirty. What's your thoughts?
I don't know static_key_false internal well.
Questions.
1. Is it implemented by all archs?
2. How is it work? It's almost zero on all archs?
3. Don't we really have any solution other than hacking the hotpath (ie, order-0 page allocation)?
4. Please see my solution on above URL. Does it has any problem?
Quoted 14 lines
migrate_type = page_private(page); if (static_key_false(&memory_hotplug_inprogress)) migrate_type = get_pageblock_migratetype(page); __free_one_page(page, zone, 0, migrate_type); Regards! Gerry--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 memory-hotplug: fix a drain pcp bug when offline pages
Quoted 68 lines · Minchan Kim
Hi Jiang,
Quoted 58 lines · Jiang Liu
Quoted 57 lines · Minchan Kim
Quoted 55 lines · qiuxishi
Quoted 23 lines · Minchan Kim
Hello Xishi,
Quoted 20 lines · qiuxishi
From: Xishi Qiu <[email protected]>
When offline a section, we move all the free pages and pcp into
MIGRATE_ISOLATElist first.start_isolate_page_range()set_migratetype_isolate() drain_all_pages(),Here is a problem, it is not sure that pcp will be moved into
MIGRATE_ISOLATElist. They may be moved intoMIGRATE_MOVABLElist becausepage_private()maybe 2. So when finish migrating pages, the free pages from pcp may be allocated again, and faild incheck_pages_isolated().drain_all_pages()drain_local_pages() drain_pages() free_pcppages_bulk() __free_one_page(page, zone, 0, page_private(page));If we add
move_freepages_block()afterdrain_all_pages(), it can not sure that all the pcp will be moved intoMIGRATE_ISOLATElist when the system works on high load. The free pages which from pcp may immediately be allocated again.Quoted 7 lines
Quoted 1 line
I think the similar bug described in http://marc.info/?t=134250882300003&r=1&w=2
Yes. I reported the problem a few month ago but it's not real bug in practice but found by my eyes during looking the code so I wanted to confirm the problem.
Do you find that problem in real practice? or just code review?
I use
/sys/devices/system/memory/soft_offline_pageto offline a lot of pages when the system works on high load, then I find some unknown zero refcount pages, such asget_any_page:0x650422: unknown zero refcount page type19400c00000000get_any_page:0x650867: unknown zero refcount page type19400c00000000
soft_offline_page()get_any_page() set_migratetype_isolate() drain_all_pages()I think after
drain_all_pages(), pcp are moved intoMIGRATE_MOVABLElist which managed by buddy allocator, but they are allocated and becaome pcp again as the system works on high load. There will be no this problem by applying this patch.Quoted 4 lines
Anyway, I don't like your approach which I already considered because it hurts hotpath while the race is really unlikely.
Get_pageblock_migratetypeis never trivial. We should avoid the overhead in hotpath and move into memory-hotplug itself. Do you see my patch in https://patchwork.kernel.org/patch/1225081/ ?Yes, you are right, I will try to find another way to fix this problem.
How about doing this work inset_migratetype_isolate(), find the pcp and change the value of private toget_pageblock_migratetype(page)?Quoted 6 lines
Quoted 3 lines
Allocator doesn't have any lock when he allocates the page from pcp. How could you prevent race between allocator and memory-hotplug
routine(ie, set_migratetype_isolate)without hurting hotpath?Hi Minchan,
I have thought about using a jump label in the hot path, which won't cause big
performance drop, but it seems a little dirty. What's your thoughts?
Quoted 9 lines
I don't know
static_key_falseinternal well.
Questions.1. Is it implemented by all archs?
2. How is it work? It's almost zero on all archs?
3. Don't we really have any solution other than hacking the hotpath (ie, order-0 page allocation)?
4. Please see my solution on above URL. Does it has any problem?
Hi Minchan,
Yes, your patch does resolve this problem, it returns the failed flag in __test_page_isolated_in_pageblock(), so memory offline will be failed.
My patch resolve this problem too, it drain pcp to MIGRATE_ISOLATE list, so memory offline will be successful, but it causes big performance drop.
I think Gerry's method looks fine.
Thanks
Xishi Qiu
Quoted 6 lines
Quoted 6 lines
migrate_type = page_private(page); if (static_key_false(&memory_hotplug_inprogress)) migrate_type = get_pageblock_migratetype(page); __free_one_page(page, zone, 0, migrate_type);
Quoted 9 lines
Quoted 8 lines
Regards!
Gerry--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>