summaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2016-10-07 19:57:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-07 21:46:27 -0400
commit7ceb009a22517297ae0e32863eb86ec766782263 (patch)
tree1c4e63fe4ca2850dde4fb1427109be5a5d7c5ffd /mm/compaction.c
parentcf378319d335663b6722e74db0211b8af55049d5 (diff)
mm, compaction: don't recheck watermarks after COMPACT_SUCCESS
Joonsoo has reminded me that in a later patch changing watermark checks throughout compaction I forgot to update checks in try_to_compact_pages() and compactd_do_work(). Closer inspection however shows that they are redundant now in the success case, because compact_zone() now reliably reports this with COMPACT_SUCCESS. So effectively the checks just repeat (a subset) of checks that have just passed. So instead of checking watermarks again, just test the return value. Note it's also possible that compaction would declare failure e.g. because its find_suitable_fallback() is more strict than simple watermark check, and then the watermark check we are removing would then still succeed. After this patch this is not possible and it's arguably better, because for long-term fragmentation avoidance we should rather try a different zone than allocate with the unsuitable fallback. If compaction of all zones fail and the allocation is important enough, it will retry and succeed anyway. Also remove the stray "bool success" variable from kcompactd_do_work(). Link: http://lkml.kernel.org/r/20160810091226.6709-5-vbabka@suse.cz Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Reported-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Tested-by: Lorenzo Stoakes <lstoakes@gmail.com> Acked-by: Michal Hocko <mhocko@kernel.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: David Rientjes <rientjes@google.com> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index 335eeeed0c91..2e1113ff7a03 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1698,9 +1698,8 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
1698 alloc_flags, ac_classzone_idx(ac)); 1698 alloc_flags, ac_classzone_idx(ac));
1699 rc = max(status, rc); 1699 rc = max(status, rc);
1700 1700
1701 /* If a normal allocation would succeed, stop compacting */ 1701 /* The allocation should succeed, stop compacting */
1702 if (zone_watermark_ok(zone, order, low_wmark_pages(zone), 1702 if (status == COMPACT_SUCCESS) {
1703 ac_classzone_idx(ac), alloc_flags)) {
1704 /* 1703 /*
1705 * We think the allocation will succeed in this zone, 1704 * We think the allocation will succeed in this zone,
1706 * but it is not certain, hence the false. The caller 1705 * but it is not certain, hence the false. The caller
@@ -1873,8 +1872,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1873 .ignore_skip_hint = true, 1872 .ignore_skip_hint = true,
1874 1873
1875 }; 1874 };
1876 bool success = false;
1877
1878 trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order, 1875 trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order,
1879 cc.classzone_idx); 1876 cc.classzone_idx);
1880 count_vm_event(KCOMPACTD_WAKE); 1877 count_vm_event(KCOMPACTD_WAKE);
@@ -1903,9 +1900,7 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1903 return; 1900 return;
1904 status = compact_zone(zone, &cc); 1901 status = compact_zone(zone, &cc);
1905 1902
1906 if (zone_watermark_ok(zone, cc.order, low_wmark_pages(zone), 1903 if (status == COMPACT_SUCCESS) {
1907 cc.classzone_idx, 0)) {
1908 success = true;
1909 compaction_defer_reset(zone, cc.order, false); 1904 compaction_defer_reset(zone, cc.order, false);
1910 } else if (status == COMPACT_PARTIAL_SKIPPED || status == COMPACT_COMPLETE) { 1905 } else if (status == COMPACT_PARTIAL_SKIPPED || status == COMPACT_COMPLETE) {
1911 /* 1906 /*