Commit 0ba8f2d5 authored by Li Haifeng's avatar Li Haifeng Committed by Linus Torvalds
Browse files

mm/page_alloc: fix the page address of higher page's buddy calculation

The heuristic method for buddy has been introduced since commit

 ("mm/page_alloc.c: simplify calculation of combined index
of adjacent buddy lists").  But the page address of higher page's buddy
was wrongly calculated, which will lead page_is_buddy to fail for ever.
IOW, the heuristic method would be disabled with the wrong page address
of higher page's buddy.

Calculating the page address of higher page's buddy should be based
higher_page with the offset between index of higher page and index of
higher page's buddy.
Signed-off-by: default avatarHaifeng Li <>
Signed-off-by: default avatarGavin Shan <>
Reviewed-by: default avatarMichal Hocko <>
Cc: KyongHo Cho <>
Cc: Mel Gorman <>
Cc: Minchan Kim <>
Cc: Johannes Weiner <>
Cc: <>	[2.6.38+]
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 8dcebaa9
......@@ -584,7 +584,7 @@ static inline void __free_one_page(struct page *page,
combined_idx = buddy_idx & page_idx;
higher_page = page + (combined_idx - page_idx);
buddy_idx = __find_buddy_index(combined_idx, order + 1);
higher_buddy = page + (buddy_idx - combined_idx);
higher_buddy = higher_page + (buddy_idx - combined_idx);
if (page_is_buddy(higher_page, higher_buddy, order + 1)) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment