Skip to content

Commit

Permalink
tracing, page-allocator: add trace events for anti-fragmentation fall…
Browse files Browse the repository at this point in the history
…ing back to other migratetypes

Fragmentation avoidance depends on being able to use free pages from lists
of the appropriate migrate type.  In the event this is not possible,
__rmqueue_fallback() selects a different list and in some circumstances
change the migratetype of the pageblock.  Simplistically, the more times
this event occurs, the more likely that fragmentation will be a problem
later for hugepage allocation at least but there are other considerations
such as the order of page being split to satisfy the allocation.

This patch adds a trace event for __rmqueue_fallback() that reports what
page is being used for the fallback, the orders of relevant pages, the
desired migratetype and the migratetype of the lists being used, whether
the pageblock changed type and whether this event is important with
respect to fragmentation avoidance or not.  This information can be used
to help analyse fragmentation avoidance and help decide whether
min_free_kbytes should be increased or not.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Rik van Riel <riel@redhat.com>
Reviewed-by: Ingo Molnar <mingo@elte.hu>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Li Ming Chun <macli@brc.ubc.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Mel Gorman authored and Linus Torvalds committed Sep 22, 2009
1 parent 4b4f278 commit e0fff1b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions include/trace/events/kmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,44 @@ TRACE_EVENT(mm_page_alloc,
show_gfp_flags(__entry->gfp_flags))
);

TRACE_EVENT(mm_page_alloc_extfrag,

TP_PROTO(struct page *page,
int alloc_order, int fallback_order,
int alloc_migratetype, int fallback_migratetype),

TP_ARGS(page,
alloc_order, fallback_order,
alloc_migratetype, fallback_migratetype),

TP_STRUCT__entry(
__field( struct page *, page )
__field( int, alloc_order )
__field( int, fallback_order )
__field( int, alloc_migratetype )
__field( int, fallback_migratetype )
),

TP_fast_assign(
__entry->page = page;
__entry->alloc_order = alloc_order;
__entry->fallback_order = fallback_order;
__entry->alloc_migratetype = alloc_migratetype;
__entry->fallback_migratetype = fallback_migratetype;
),

TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
__entry->page,
page_to_pfn(__entry->page),
__entry->alloc_order,
__entry->fallback_order,
pageblock_order,
__entry->alloc_migratetype,
__entry->fallback_migratetype,
__entry->fallback_order < pageblock_order,
__entry->alloc_migratetype == __entry->fallback_migratetype)
);

#endif /* _TRACE_KMEM_H */

/* This part must be outside protection */
Expand Down
4 changes: 4 additions & 0 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
start_migratetype);

expand(zone, page, order, current_order, area, migratetype);

trace_mm_page_alloc_extfrag(page, order, current_order,
start_migratetype, migratetype);

return page;
}
}
Expand Down

0 comments on commit e0fff1b

Please sign in to comment.