Skip to content

Commit bac9c6f

Browse files
cdkeytorvalds
authored andcommitted
mm/page_alloc: fix counting of free pages after take off from buddy
Recently we found that there is a lot MemFree left in /proc/meminfo after do a lot of pages soft offline, it's not quite correct. Before Oscar's rework of soft offline for free pages [1], if we soft offline free pages, these pages are left in buddy with HWPoison flag, and NR_FREE_PAGES is not updated immediately. So the difference between NR_FREE_PAGES and real number of available free pages is also even big at the beginning. However, with the workload running, when we catch HWPoison page in any alloc functions subsequently, we will remove it from buddy, meanwhile update the NR_FREE_PAGES and try again, so the NR_FREE_PAGES will get more and more closer to the real number of available free pages. (regardless of unpoison_memory()) Now, for offline free pages, after a successful call take_page_off_buddy(), the page is no longer belong to buddy allocator, and will not be used any more, but we missed accounting NR_FREE_PAGES in this situation, and there is no chance to be updated later. Do update in take_page_off_buddy() like rmqueue() does, but avoid double counting if some one already set_migratetype_isolate() on the page. [1]: commit 06be6ff ("mm,hwpoison: rework soft offline for free pages") Link: https://lkml.kernel.org/r/[email protected] Fixes: 06be6ff ("mm,hwpoison: rework soft offline for free pages") Signed-off-by: Ding Hui <[email protected]> Suggested-by: Naoya Horiguchi <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Naoya Horiguchi <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 04f7ce3 commit bac9c6f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/page_alloc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9158,6 +9158,8 @@ bool take_page_off_buddy(struct page *page)
91589158
del_page_from_free_list(page_head, zone, page_order);
91599159
break_down_buddy_pages(zone, page_head, page, 0,
91609160
page_order, migratetype);
9161+
if (!is_migrate_isolate(migratetype))
9162+
__mod_zone_freepage_state(zone, -1, migratetype);
91619163
ret = true;
91629164
break;
91639165
}

0 commit comments

Comments
 (0)