mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 03:40:04 +00:00
mm/compaction: fix misbehaviors of fast_find_migrateblock()
[ Upstream commit15d28d0d11
] In the fast_find_migrateblock(), it iterates ocer the freelist to find the proper pageblock. But there are some misbehaviors. First, if the page we found is equal to cc->migrate_pfn, it is considered that we didn't find a suitable pageblock. Secondly, if the loop was terminated because order is less than PAGE_ALLOC_COSTLY_ORDER, it could be considered that we found a suitable one. Thirdly, if the skip bit is set on the page block and we goto continue, it doesn't check nr_scanned. Fourthly, if the page block's skip bit is set, it checks that page block is the last of list, which is unnecessary. Link: https://lkml.kernel.org/r/20210128130411.6125-1-vvghjk1234@gmail.com Fixes:70b44595ea
("mm, compaction: use free lists to quickly locate a migration source") Signed-off-by: Wonhyuk Yang <vvghjk1234@gmail.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Mel Gorman <mgorman@techsingularity.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c200f49595
commit
c70c3b6e62
1 changed files with 12 additions and 15 deletions
|
@ -1630,6 +1630,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
unsigned long pfn = cc->migrate_pfn;
|
unsigned long pfn = cc->migrate_pfn;
|
||||||
unsigned long high_pfn;
|
unsigned long high_pfn;
|
||||||
int order;
|
int order;
|
||||||
|
bool found_block = false;
|
||||||
|
|
||||||
/* Skip hints are relied on to avoid repeats on the fast search */
|
/* Skip hints are relied on to avoid repeats on the fast search */
|
||||||
if (cc->ignore_skip_hint)
|
if (cc->ignore_skip_hint)
|
||||||
|
@ -1672,7 +1673,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance);
|
high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance);
|
||||||
|
|
||||||
for (order = cc->order - 1;
|
for (order = cc->order - 1;
|
||||||
order >= PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit;
|
order >= PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit;
|
||||||
order--) {
|
order--) {
|
||||||
struct free_area *area = &cc->zone->free_area[order];
|
struct free_area *area = &cc->zone->free_area[order];
|
||||||
struct list_head *freelist;
|
struct list_head *freelist;
|
||||||
|
@ -1687,7 +1688,11 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
list_for_each_entry(freepage, freelist, lru) {
|
list_for_each_entry(freepage, freelist, lru) {
|
||||||
unsigned long free_pfn;
|
unsigned long free_pfn;
|
||||||
|
|
||||||
nr_scanned++;
|
if (nr_scanned++ >= limit) {
|
||||||
|
move_freelist_tail(freelist, freepage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
free_pfn = page_to_pfn(freepage);
|
free_pfn = page_to_pfn(freepage);
|
||||||
if (free_pfn < high_pfn) {
|
if (free_pfn < high_pfn) {
|
||||||
/*
|
/*
|
||||||
|
@ -1696,12 +1701,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
* the list assumes an entry is deleted, not
|
* the list assumes an entry is deleted, not
|
||||||
* reordered.
|
* reordered.
|
||||||
*/
|
*/
|
||||||
if (get_pageblock_skip(freepage)) {
|
if (get_pageblock_skip(freepage))
|
||||||
if (list_is_last(freelist, &freepage->lru))
|
|
||||||
break;
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
/* Reorder to so a future search skips recent pages */
|
/* Reorder to so a future search skips recent pages */
|
||||||
move_freelist_tail(freelist, freepage);
|
move_freelist_tail(freelist, freepage);
|
||||||
|
@ -1709,15 +1710,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
update_fast_start_pfn(cc, free_pfn);
|
update_fast_start_pfn(cc, free_pfn);
|
||||||
pfn = pageblock_start_pfn(free_pfn);
|
pfn = pageblock_start_pfn(free_pfn);
|
||||||
cc->fast_search_fail = 0;
|
cc->fast_search_fail = 0;
|
||||||
|
found_block = true;
|
||||||
set_pageblock_skip(freepage);
|
set_pageblock_skip(freepage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nr_scanned >= limit) {
|
|
||||||
cc->fast_search_fail++;
|
|
||||||
move_freelist_tail(freelist, freepage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&cc->zone->lock, flags);
|
spin_unlock_irqrestore(&cc->zone->lock, flags);
|
||||||
}
|
}
|
||||||
|
@ -1728,9 +1724,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
||||||
* If fast scanning failed then use a cached entry for a page block
|
* If fast scanning failed then use a cached entry for a page block
|
||||||
* that had free pages as the basis for starting a linear scan.
|
* that had free pages as the basis for starting a linear scan.
|
||||||
*/
|
*/
|
||||||
if (pfn == cc->migrate_pfn)
|
if (!found_block) {
|
||||||
|
cc->fast_search_fail++;
|
||||||
pfn = reinit_migrate_pfn(cc);
|
pfn = reinit_migrate_pfn(cc);
|
||||||
|
}
|
||||||
return pfn;
|
return pfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue