linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: page_alloc: validate buddy before check its migratetype.
@ 2022-03-30 22:12 Zi Yan
  2022-03-30 22:27 ` Linus Torvalds
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Zi Yan @ 2022-03-30 22:12 UTC (permalink / raw)
  To: Linus Torvalds, Steven Rostedt
  Cc: David Hildenbrand, Vlastimil Babka, Mel Gorman, Mike Rapoport,
	Oscar Salvador, Andrew Morton, linux-mm, linux-kernel, Zi Yan

From: Zi Yan <ziy@nvidia.com>

Whenever a buddy page is found, page_is_buddy() should be called to
check its validity. Add the missing check during pageblock merge check.

Fixes: 1dd214b8f21c ("mm: page_alloc: avoid merging non-fallbackable pageblocks with others")

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
 mm/page_alloc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bdc8f60ae462..6c6af8658775 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1108,6 +1108,9 @@ static inline void __free_one_page(struct page *page,
 
 		buddy_pfn = __find_buddy_pfn(pfn, order);
 		buddy = page + (buddy_pfn - pfn);
+
+		if (!page_is_buddy(page, buddy, order))
+			goto done_merging;
 		buddy_mt = get_pageblock_migratetype(buddy);
 
 		if (migratetype != buddy_mt
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-03-31 22:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30 22:12 [PATCH] mm: page_alloc: validate buddy before check its migratetype Zi Yan
2022-03-30 22:27 ` Linus Torvalds
2022-03-31  0:15   ` Zi Yan
2022-03-30 22:29 ` Steven Rostedt
2022-03-30 23:03 ` Linus Torvalds
2022-03-30 23:48   ` Zi Yan
2022-03-31  0:10     ` Zi Yan
2022-03-31  8:57       ` Vlastimil Babka
2022-03-31 22:07         ` Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).