Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1197123
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 5/5] mm, compaction: skip compound pages by order in free scanner |
| Date | 2015-07-31 17:30 +0200 |
| Message-ID | <pSkq0-1ly-45@gated-at.bofh.it> (permalink) |
| References | <pSkpY-1ly-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The compaction free scanner is looking for PageBuddy() pages and skipping all
others. For large compound pages such as THP or hugetlbfs, we can save a lot
of iterations if we skip them at once using their compound_order(). This is
generally unsafe and we can read a bogus value of order due to a race, but if
we are careful, the only danger is skipping too much.
When tested with stress-highalloc from mmtests on 4GB system with 1GB hugetlbfs
pages, the vmstat compact_free_scanned count decreased by at least 15%.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: David Rientjes <rientjes@google.com>
---
mm/compaction.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/mm/compaction.c b/mm/compaction.c
index 70b0776..b978693 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -437,6 +437,24 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
if (!valid_page)
valid_page = page;
+
+ /*
+ * For compound pages such as THP and hugetlbfs, we can save
+ * potentially a lot of iterations if we skip them at once.
+ * The check is racy, but we can consider only valid values
+ * and the only danger is skipping too much.
+ */
+ if (PageCompound(page)) {
+ unsigned int comp_order = compound_order(page);
+
+ if (likely(comp_order < MAX_ORDER)) {
+ blockpfn += (1UL << comp_order) - 1;
+ cursor += (1UL << comp_order) - 1;
+ }
+
+ goto isolate_fail;
+ }
+
if (!PageBuddy(page))
goto isolate_fail;
@@ -496,6 +514,13 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
}
+ /*
+ * There is a tiny chance that we have read bogus compound_order(),
+ * so be careful to not go outside of the pageblock.
+ */
+ if (unlikely(blockpfn > end_pfn))
+ blockpfn = end_pfn;
+
trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn,
nr_scanned, total_isolated);
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/5] Assorted compaction cleanups and optimizations Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:30 +0200
[PATCH v2 2/5] mm, compaction: simplify handling restart position in free pages scanner Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:30 +0200
Re: [PATCH v2 2/5] mm, compaction: simplify handling restart position in free pages scanner Michal Nazarewicz <mina86@mina86.com> - 2015-08-03 19:10 +0200
[PATCH v2 1/5] mm, compaction: more robust check for scanners meeting Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:30 +0200
[PATCH v2 5/5] mm, compaction: skip compound pages by order in free scanner Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:30 +0200
[PATCH v2 4/5] mm, compaction: always skip compound pages by order in migrate scanner Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:30 +0200
Re: [PATCH v2 0/5] Assorted compaction cleanups and optimizations Vlastimil Babka <vbabka@suse.cz> - 2015-07-31 17:40 +0200
csiph-web