提交 1d4746d3 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

mm, compaction: distinguish COMPACT_DEFERRED from COMPACT_SKIPPED

try_to_compact_pages() can currently return COMPACT_SKIPPED even when
the compaction is defered for some zone just because zone DMA is skipped
in 99% of cases due to watermark checks.  This makes COMPACT_DEFERRED
basically unusable for the page allocator as a feedback mechanism.

Make sure we distinguish those two states properly and switch their
ordering in the enum.  This would mean that the COMPACT_SKIPPED will be
returned only when all eligible zones are skipped.

As a result COMPACT_DEFERRED handling for THP in __alloc_pages_slowpath
will be more precise and we would bail out rather than reclaim.
Signed-off-by: NMichal Hocko <mhocko@suse.com>
Acked-by: NVlastimil Babka <vbabka@suse.cz>
Acked-by: NHillf Danton <hillf.zj@alibaba-inc.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 c46649de
...@@ -4,13 +4,16 @@ ...@@ -4,13 +4,16 @@
/* Return values for compact_zone() and try_to_compact_pages() */ /* Return values for compact_zone() and try_to_compact_pages() */
/* When adding new states, please adjust include/trace/events/compaction.h */ /* When adding new states, please adjust include/trace/events/compaction.h */
enum compact_result { enum compact_result {
/* compaction didn't start as it was deferred due to past failures */
COMPACT_DEFERRED,
/* /*
* compaction didn't start as it was not possible or direct reclaim * compaction didn't start as it was not possible or direct reclaim
* was more suitable * was more suitable
*/ */
COMPACT_SKIPPED, COMPACT_SKIPPED,
/* compaction didn't start as it was deferred due to past failures */
COMPACT_DEFERRED,
/* compaction not active last round */
COMPACT_INACTIVE = COMPACT_DEFERRED,
/* compaction should continue to another pageblock */ /* compaction should continue to another pageblock */
COMPACT_CONTINUE, COMPACT_CONTINUE,
/* /*
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <trace/events/mmflags.h> #include <trace/events/mmflags.h>
#define COMPACTION_STATUS \ #define COMPACTION_STATUS \
EM( COMPACT_DEFERRED, "deferred") \
EM( COMPACT_SKIPPED, "skipped") \ EM( COMPACT_SKIPPED, "skipped") \
EM( COMPACT_DEFERRED, "deferred") \
EM( COMPACT_CONTINUE, "continue") \ EM( COMPACT_CONTINUE, "continue") \
EM( COMPACT_PARTIAL, "partial") \ EM( COMPACT_PARTIAL, "partial") \
EM( COMPACT_COMPLETE, "complete") \ EM( COMPACT_COMPLETE, "complete") \
......
...@@ -1578,7 +1578,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, ...@@ -1578,7 +1578,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
int may_perform_io = gfp_mask & __GFP_IO; int may_perform_io = gfp_mask & __GFP_IO;
struct zoneref *z; struct zoneref *z;
struct zone *zone; struct zone *zone;
enum compact_result rc = COMPACT_DEFERRED; enum compact_result rc = COMPACT_SKIPPED;
int all_zones_contended = COMPACT_CONTENDED_LOCK; /* init for &= op */ int all_zones_contended = COMPACT_CONTENDED_LOCK; /* init for &= op */
*contended = COMPACT_CONTENDED_NONE; *contended = COMPACT_CONTENDED_NONE;
...@@ -1595,8 +1595,10 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, ...@@ -1595,8 +1595,10 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
enum compact_result status; enum compact_result status;
int zone_contended; int zone_contended;
if (compaction_deferred(zone, order)) if (compaction_deferred(zone, order)) {
rc = max_t(enum compact_result, COMPACT_DEFERRED, rc);
continue; continue;
}
status = compact_zone_order(zone, order, gfp_mask, mode, status = compact_zone_order(zone, order, gfp_mask, mode,
&zone_contended, alloc_flags, &zone_contended, alloc_flags,
...@@ -1667,7 +1669,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, ...@@ -1667,7 +1669,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
* If at least one zone wasn't deferred or skipped, we report if all * If at least one zone wasn't deferred or skipped, we report if all
* zones that were tried were lock contended. * zones that were tried were lock contended.
*/ */
if (rc > COMPACT_SKIPPED && all_zones_contended) if (rc > COMPACT_INACTIVE && all_zones_contended)
*contended = COMPACT_CONTENDED_LOCK; *contended = COMPACT_CONTENDED_LOCK;
return rc; return rc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册