Skip to content

Commit

Permalink
mm: remove "count" parameter from has_unmovable_pages()
Browse files Browse the repository at this point in the history
Now that the memory isolate notifier is gone, the parameter is always 0.
Drop it and cleanup has_unmovable_pages().

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: David Hildenbrand <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Anshuman Khandual <[email protected]>
Cc: Qian Cai <[email protected]>
Cc: Pingfan Liu <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Pavel Tatashin <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Wei Yang <[email protected]>
Cc: Alexander Duyck <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Arun KS <[email protected]>
Cc: Michael Ellerman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
davidhildenbrand authored and torvalds committed Jan 31, 2020
1 parent 3f9903b commit fe4c86c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions include/linux/page-isolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ static inline bool is_migrate_isolate(int migratetype)
#define MEMORY_OFFLINE 0x1
#define REPORT_FAILURE 0x2

bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
int migratetype, int flags);
bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
int flags);
void set_pageblock_migratetype(struct page *page, int migratetype);
int move_freepages_block(struct zone *zone, struct page *page,
int migratetype, int *num_movable);
Expand Down
2 changes: 1 addition & 1 deletion mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn)
if (!zone_spans_pfn(zone, pfn))
return false;

return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE,
return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE,
MEMORY_OFFLINE);
}

Expand Down
21 changes: 7 additions & 14 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8180,17 +8180,15 @@ void *__init alloc_large_system_hash(const char *tablename,

/*
* This function checks whether pageblock includes unmovable pages or not.
* If @count is not zero, it is okay to include less @count unmovable pages
*
* PageLRU check without isolation or lru_lock could race so that
* MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable
* check without lock_page also may miss some movable non-lru pages at
* race condition. So you can't expect this function should be exact.
*/
bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
int migratetype, int flags)
bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
int flags)
{
unsigned long found;
unsigned long iter = 0;
unsigned long pfn = page_to_pfn(page);
const char *reason = "unmovable page";
Expand All @@ -8216,13 +8214,11 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
goto unmovable;
}

for (found = 0; iter < pageblock_nr_pages; iter++) {
unsigned long check = pfn + iter;

if (!pfn_valid_within(check))
for (; iter < pageblock_nr_pages; iter++) {
if (!pfn_valid_within(pfn + iter))
continue;

page = pfn_to_page(check);
page = pfn_to_page(pfn + iter);

if (PageReserved(page))
goto unmovable;
Expand Down Expand Up @@ -8271,11 +8267,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
if ((flags & MEMORY_OFFLINE) && PageHWPoison(page))
continue;

if (__PageMovable(page))
if (__PageMovable(page) || PageLRU(page))
continue;

if (!PageLRU(page))
found++;
/*
* If there are RECLAIMABLE pages, we need to check
* it. But now, memory offline itself doesn't call
Expand All @@ -8289,8 +8283,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
* is set to both of a memory hole page and a _used_ kernel
* page at boot.
*/
if (found > count)
goto unmovable;
goto unmovable;
}
return false;
unmovable:
Expand Down
2 changes: 1 addition & 1 deletion mm/page_isolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
* FIXME: Now, memory hotplug doesn't call shrink_slab() by itself.
* We just check MOVABLE pages.
*/
if (!has_unmovable_pages(zone, page, 0, migratetype, isol_flags)) {
if (!has_unmovable_pages(zone, page, migratetype, isol_flags)) {
unsigned long nr_pages;
int mt = get_pageblock_migratetype(page);

Expand Down

0 comments on commit fe4c86c

Please sign in to comment.