Skip to content

Commit 7f46774

Browse files
committed
Merge tag 'mm-compaction-5.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mel/linux
Pull mm/compaction fixes from Mel Gorman: "The merge window for 5.1 introduced a number of compaction-related patches. with intermittent reports of corruption and functional issues. The bugs are due to sloopy checking of zone boundaries and a corner case where invalid indexes are used to access the free lists. Reports are not common but at least two users and 0-day have tripped over them. There is a chance that one of the syzbot reports are related but it has not been confirmed properly. The normal submission path is with Andrew but there have been some delays and I consider them urgent enough that they should be picked up before RC4 to avoid duplicate reports. All of these have been successfully tested on older RC windows. This will make this branch look like a rebase but in fact, they've simply been lifted again from Andrew's tree and placed on a fresh branch. I've no reason to believe that this has invalidated the testing given the lack of change in compaction and the nature of the fixes" * tag 'mm-compaction-5.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mel/linux: mm/compaction.c: abort search if isolation fails mm/compaction.c: correct zone boundary handling when resetting pageblock skip hints
2 parents c7084ed + 5b56d99 commit 7f46774

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

mm/compaction.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ __reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source,
242242
bool check_target)
243243
{
244244
struct page *page = pfn_to_online_page(pfn);
245+
struct page *block_page;
245246
struct page *end_page;
246247
unsigned long block_pfn;
247248

@@ -267,20 +268,26 @@ __reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source,
267268
get_pageblock_migratetype(page) != MIGRATE_MOVABLE)
268269
return false;
269270

271+
/* Ensure the start of the pageblock or zone is online and valid */
272+
block_pfn = pageblock_start_pfn(pfn);
273+
block_page = pfn_to_online_page(max(block_pfn, zone->zone_start_pfn));
274+
if (block_page) {
275+
page = block_page;
276+
pfn = block_pfn;
277+
}
278+
279+
/* Ensure the end of the pageblock or zone is online and valid */
280+
block_pfn += pageblock_nr_pages;
281+
block_pfn = min(block_pfn, zone_end_pfn(zone) - 1);
282+
end_page = pfn_to_online_page(block_pfn);
283+
if (!end_page)
284+
return false;
285+
270286
/*
271287
* Only clear the hint if a sample indicates there is either a
272288
* free page or an LRU page in the block. One or other condition
273289
* is necessary for the block to be a migration source/target.
274290
*/
275-
block_pfn = pageblock_start_pfn(pfn);
276-
pfn = max(block_pfn, zone->zone_start_pfn);
277-
page = pfn_to_page(pfn);
278-
if (zone != page_zone(page))
279-
return false;
280-
pfn = block_pfn + pageblock_nr_pages;
281-
pfn = min(pfn, zone_end_pfn(zone));
282-
end_page = pfn_to_page(pfn);
283-
284291
do {
285292
if (pfn_valid_within(pfn)) {
286293
if (check_source && PageLRU(page)) {
@@ -309,7 +316,7 @@ __reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source,
309316
static void __reset_isolation_suitable(struct zone *zone)
310317
{
311318
unsigned long migrate_pfn = zone->zone_start_pfn;
312-
unsigned long free_pfn = zone_end_pfn(zone);
319+
unsigned long free_pfn = zone_end_pfn(zone) - 1;
313320
unsigned long reset_migrate = free_pfn;
314321
unsigned long reset_free = migrate_pfn;
315322
bool source_set = false;
@@ -1363,7 +1370,7 @@ fast_isolate_freepages(struct compact_control *cc)
13631370
count_compact_events(COMPACTISOLATED, nr_isolated);
13641371
} else {
13651372
/* If isolation fails, abort the search */
1366-
order = -1;
1373+
order = cc->search_order + 1;
13671374
page = NULL;
13681375
}
13691376
}

0 commit comments

Comments
 (0)