Message ID | 20201030155716.3614401-1-zi.yan@sent.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] mm/compaction: count pages and stop correctly during page isolation. | expand |
On Fri, Oct 30, 2020 at 11:57:15AM -0400, Zi Yan wrote: > In isolate_migratepages_block, when cc->alloc_contig is true, we are > able to isolate compound pages, nr_migratepages and nr_isolated did not > count compound pages correctly, causing us to isolate more pages than we > thought. Use thp_nr_pages to count pages. Otherwise, we might be trapped ^^^^^^^^^^^^ Maybe replace that sentence with "Count compound pages as the number of base pages they contain"?
On 30 Oct 2020, at 14:12, Matthew Wilcox wrote: > On Fri, Oct 30, 2020 at 11:57:15AM -0400, Zi Yan wrote: >> In isolate_migratepages_block, when cc->alloc_contig is true, we are >> able to isolate compound pages, nr_migratepages and nr_isolated did not >> count compound pages correctly, causing us to isolate more pages than we >> thought. Use thp_nr_pages to count pages. Otherwise, we might be trapped > ^^^^^^^^^^^^ > Maybe replace that sentence with "Count compound pages as the number of > base pages they contain"? Sure. And compound_nr is used instead of thp_nr_pages in fact. OK. V3 is coming. — Best Regards, Yan Zi
diff --git a/mm/compaction.c b/mm/compaction.c index ee1f8439369e..3e834ac402f1 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1012,8 +1012,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, isolate_success: list_add(&page->lru, &cc->migratepages); - cc->nr_migratepages++; - nr_isolated++; + cc->nr_migratepages += compound_nr(page); + nr_isolated += compound_nr(page); /* * Avoid isolating too much unless this block is being @@ -1021,7 +1021,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, * or a lock is contended. For contention, isolate quickly to * potentially remove one source of contention. */ - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX && + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX && !cc->rescan && !cc->contended) { ++low_pfn; break; @@ -1132,7 +1132,7 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn, if (!pfn) break; - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX) + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX) break; }