Commit 2d1e1041 authored by Vlastimil Babka's avatar Vlastimil Babka Committed by Linus Torvalds

mm, compaction: distinguish contended status in tracepoints

Compaction returns prematurely with COMPACT_PARTIAL when contended or has
fatal signal pending.  This is ok for the callers, but might be misleading
in the traces, as the usual reason to return COMPACT_PARTIAL is that we
think the allocation should succeed.  After this patch we distinguish the
premature ending condition in the mm_compaction_finished and
mm_compaction_end tracepoints.

The contended status covers the following reasons:
- lock contention or need_resched() detected in async compaction
- fatal signal pending
- too many pages isolated in the zone (only for async compaction)
Further distinguishing the exact reason seems unnecessary for now.
Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: David Rientjes <rientjes@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1743d050
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
/* For more detailed tracepoint output */ /* For more detailed tracepoint output */
#define COMPACT_NO_SUITABLE_PAGE 5 #define COMPACT_NO_SUITABLE_PAGE 5
#define COMPACT_NOT_SUITABLE_ZONE 6 #define COMPACT_NOT_SUITABLE_ZONE 6
#define COMPACT_CONTENDED 7
/* When adding new states, please adjust include/trace/events/compaction.h */ /* When adding new states, please adjust include/trace/events/compaction.h */
/* Used to signal whether compaction detected need_sched() or lock contention */ /* Used to signal whether compaction detected need_sched() or lock contention */
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
EM( COMPACT_PARTIAL, "partial") \ EM( COMPACT_PARTIAL, "partial") \
EM( COMPACT_COMPLETE, "complete") \ EM( COMPACT_COMPLETE, "complete") \
EM( COMPACT_NO_SUITABLE_PAGE, "no_suitable_page") \ EM( COMPACT_NO_SUITABLE_PAGE, "no_suitable_page") \
EMe(COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") EM( COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") \
EMe(COMPACT_CONTENDED, "contended")
#ifdef CONFIG_ZONE_DMA #ifdef CONFIG_ZONE_DMA
#define IFDEF_ZONE_DMA(X) X #define IFDEF_ZONE_DMA(X) X
......
...@@ -1202,7 +1202,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc, ...@@ -1202,7 +1202,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
unsigned long watermark; unsigned long watermark;
if (cc->contended || fatal_signal_pending(current)) if (cc->contended || fatal_signal_pending(current))
return COMPACT_PARTIAL; return COMPACT_CONTENDED;
/* Compaction run completes if the migrate and free scanner meet */ /* Compaction run completes if the migrate and free scanner meet */
if (compact_scanners_met(cc)) { if (compact_scanners_met(cc)) {
...@@ -1393,7 +1393,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) ...@@ -1393,7 +1393,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
switch (isolate_migratepages(zone, cc)) { switch (isolate_migratepages(zone, cc)) {
case ISOLATE_ABORT: case ISOLATE_ABORT:
ret = COMPACT_PARTIAL; ret = COMPACT_CONTENDED;
putback_movable_pages(&cc->migratepages); putback_movable_pages(&cc->migratepages);
cc->nr_migratepages = 0; cc->nr_migratepages = 0;
goto out; goto out;
...@@ -1424,7 +1424,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) ...@@ -1424,7 +1424,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
* and we want compact_finished() to detect it * and we want compact_finished() to detect it
*/ */
if (err == -ENOMEM && !compact_scanners_met(cc)) { if (err == -ENOMEM && !compact_scanners_met(cc)) {
ret = COMPACT_PARTIAL; ret = COMPACT_CONTENDED;
goto out; goto out;
} }
} }
...@@ -1477,6 +1477,9 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) ...@@ -1477,6 +1477,9 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
trace_mm_compaction_end(start_pfn, cc->migrate_pfn, trace_mm_compaction_end(start_pfn, cc->migrate_pfn,
cc->free_pfn, end_pfn, sync, ret); cc->free_pfn, end_pfn, sync, ret);
if (ret == COMPACT_CONTENDED)
ret = COMPACT_PARTIAL;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment