linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, isolation: avoid checking unmovable pages across pageblock boundary
@ 2020-08-24  6:58 Li Xinhai
  2020-08-24  8:17 ` Oscar Salvador
  2020-08-25  8:26 ` Michal Hocko
  0 siblings, 2 replies; 7+ messages in thread
From: Li Xinhai @ 2020-08-24  6:58 UTC (permalink / raw)
  To: linux-mm; +Cc: akpm, mhocko, david

In has_unmovable_pages(), the page parameter would not always be the
first page within a pageblock (see how the page pointer is passed in from
start_isolate_page_range() after call __first_valid_page()), so that
would cause checking unmovable pages span two pageblocks.

After this patch, the checking is enforced within one pageblock no matter
the page is first one or not, and obey the semantics of this function.

This issue is found by code inspection.

Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
---
 mm/page_alloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0e2bab486fea..c2c5b565f1f3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8213,6 +8213,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page,
 {
 	unsigned long iter = 0;
 	unsigned long pfn = page_to_pfn(page);
+	unsigned long offset = pfn % pageblock_nr_pages;
 
 	/*
 	 * TODO we could make this much more efficient by not checking every
@@ -8234,7 +8235,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page,
 		return page;
 	}
 
-	for (; iter < pageblock_nr_pages; iter++) {
+	for (; iter < pageblock_nr_pages - offset; iter++) {
 		if (!pfn_valid_within(pfn + iter))
 			continue;
 
-- 
2.18.4



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

end of thread, other threads:[~2020-09-14 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24  6:58 [PATCH] mm, isolation: avoid checking unmovable pages across pageblock boundary Li Xinhai
2020-08-24  8:17 ` Oscar Salvador
2020-08-25  8:26 ` Michal Hocko
2020-09-08  8:30   ` David Hildenbrand
2020-09-08  8:30   ` David Hildenbrand
2020-09-14 15:00     ` Michal Hocko
2020-09-14 16:36       ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox