Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b2a2d4a authored by Mel Gorman's avatar Mel Gorman
Browse files

mm: migrate: Add a tracepoint for migrate_pages



The pgmigrate_success and pgmigrate_fail vmstat counters tells the user
about migration activity but not the type or the reason. This patch adds
a tracepoint to identify the type of page migration and why the page is
being migrated.

Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
Reviewed-by: default avatarRik van Riel <riel@redhat.com>
parent 5647bc29
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -7,6 +7,15 @@

typedef struct page *new_page_t(struct page *, unsigned long private, int **);

enum migrate_reason {
	MR_COMPACTION,
	MR_MEMORY_FAILURE,
	MR_MEMORY_HOTPLUG,
	MR_SYSCALL,		/* also applies to cpusets */
	MR_MEMPOLICY_MBIND,
	MR_CMA
};

#ifdef CONFIG_MIGRATION

extern void putback_lru_pages(struct list_head *l);
@@ -14,7 +23,7 @@ extern int migrate_page(struct address_space *,
			struct page *, struct page *, enum migrate_mode);
extern int migrate_pages(struct list_head *l, new_page_t x,
			unsigned long private, bool offlining,
			enum migrate_mode mode);
			enum migrate_mode mode, int reason);
extern int migrate_huge_page(struct page *, new_page_t x,
			unsigned long private, bool offlining,
			enum migrate_mode mode);
@@ -35,7 +44,7 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping,
static inline void putback_lru_pages(struct list_head *l) {}
static inline int migrate_pages(struct list_head *l, new_page_t x,
		unsigned long private, bool offlining,
		enum migrate_mode mode) { return -ENOSYS; }
		enum migrate_mode mode, int reason) { return -ENOSYS; }
static inline int migrate_huge_page(struct page *page, new_page_t x,
		unsigned long private, bool offlining,
		enum migrate_mode mode) { return -ENOSYS; }
+51 −0
Original line number Diff line number Diff line
#undef TRACE_SYSTEM
#define TRACE_SYSTEM migrate

#if !defined(_TRACE_MIGRATE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_MIGRATE_H

#define MIGRATE_MODE						\
	{MIGRATE_ASYNC,		"MIGRATE_ASYNC"},		\
	{MIGRATE_SYNC_LIGHT,	"MIGRATE_SYNC_LIGHT"},		\
	{MIGRATE_SYNC,		"MIGRATE_SYNC"}		

#define MIGRATE_REASON						\
	{MR_COMPACTION,		"compaction"},			\
	{MR_MEMORY_FAILURE,	"memory_failure"},		\
	{MR_MEMORY_HOTPLUG,	"memory_hotplug"},		\
	{MR_SYSCALL,		"syscall_or_cpuset"},		\
	{MR_MEMPOLICY_MBIND,	"mempolicy_mbind"},		\
	{MR_CMA,		"cma"}

TRACE_EVENT(mm_migrate_pages,

	TP_PROTO(unsigned long succeeded, unsigned long failed,
		 enum migrate_mode mode, int reason),

	TP_ARGS(succeeded, failed, mode, reason),

	TP_STRUCT__entry(
		__field(	unsigned long,		succeeded)
		__field(	unsigned long,		failed)
		__field(	enum migrate_mode,	mode)
		__field(	int,			reason)
	),

	TP_fast_assign(
		__entry->succeeded	= succeeded;
		__entry->failed		= failed;
		__entry->mode		= mode;
		__entry->reason		= reason;
	),

	TP_printk("nr_succeeded=%lu nr_failed=%lu mode=%s reason=%s",
		__entry->succeeded,
		__entry->failed,
		__print_symbolic(__entry->mode, MIGRATE_MODE),
		__print_symbolic(__entry->reason, MIGRATE_REASON))
);

#endif /* _TRACE_MIGRATE_H */

/* This part must be outside protection */
#include <trace/define_trace.h>
+2 −1
Original line number Diff line number Diff line
@@ -990,7 +990,8 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
		nr_migrate = cc->nr_migratepages;
		err = migrate_pages(&cc->migratepages, compaction_alloc,
				(unsigned long)cc, false,
				cc->sync ? MIGRATE_SYNC_LIGHT : MIGRATE_ASYNC);
				cc->sync ? MIGRATE_SYNC_LIGHT : MIGRATE_ASYNC,
				MR_COMPACTION);
		update_nr_listpages(cc);
		nr_remaining = cc->nr_migratepages;

+2 −1
Original line number Diff line number Diff line
@@ -1558,7 +1558,8 @@ int soft_offline_page(struct page *page, int flags)
					    page_is_file_cache(page));
		list_add(&page->lru, &pagelist);
		ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL,
							false, MIGRATE_SYNC);
							false, MIGRATE_SYNC,
							MR_MEMORY_FAILURE);
		if (ret) {
			putback_lru_pages(&pagelist);
			pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
+2 −1
Original line number Diff line number Diff line
@@ -812,7 +812,8 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
		 * migrate_pages returns # of failed pages.
		 */
		ret = migrate_pages(&source, alloc_migrate_target, 0,
							true, MIGRATE_SYNC);
							true, MIGRATE_SYNC,
							MR_MEMORY_HOTPLUG);
		if (ret)
			putback_lru_pages(&source);
	}
Loading