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

Commit ea0195f3 authored by Liam Mark's avatar Liam Mark
Browse files

mm, page_owner: record time and pid



Collect the time for each allocation recorded in page owner so that
allocation "surges" can be measured.

Record the pid for each allocation recorded in page owner so that
the source of allocation "surges" can be better identified.

Change-Id: I51cad8f088b7eee9f900555680e21b7d1813d111
oldChange-Id: Ifaa7d1e26a858a562b0dfdb177e5a874478684ca
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
parent edf9b17c
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#include <linux/migrate.h>
#include <linux/stackdepot.h>
#include <linux/seq_file.h>
#include <linux/sched.h>
#include <linux/sched/clock.h>

#include "internal.h"

@@ -24,6 +26,8 @@ struct page_owner {
	short last_migrate_reason;
	gfp_t gfp_mask;
	depot_stack_handle_t handle;
	int pid;
	u64 ts_nsec;
};

static bool page_owner_disabled =
@@ -183,6 +187,8 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext,
	page_owner->order = order;
	page_owner->gfp_mask = gfp_mask;
	page_owner->last_migrate_reason = -1;
	page_owner->pid = current->pid;
	page_owner->ts_nsec = local_clock();

	__set_bit(PAGE_EXT_OWNER, &page_ext->flags);
}
@@ -243,6 +249,8 @@ void __copy_page_owner(struct page *oldpage, struct page *newpage)
	new_page_owner->last_migrate_reason =
		old_page_owner->last_migrate_reason;
	new_page_owner->handle = old_page_owner->handle;
	new_page_owner->pid = old_page_owner->pid;
	new_page_owner->ts_nsec = old_page_owner->ts_nsec;

	/*
	 * We don't clear the bit on the oldpage as it's going to be freed
@@ -360,9 +368,10 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn,
		return -ENOMEM;

	ret = snprintf(kbuf, count,
			"Page allocated via order %u, mask %#x(%pGg)\n",
			"Page allocated via order %u, mask %#x(%pGg), pid %d, ts %llu ns\n",
			page_owner->order, page_owner->gfp_mask,
			&page_owner->gfp_mask);
			&page_owner->gfp_mask, page_owner->pid,
			page_owner->ts_nsec);

	if (ret >= count)
		goto err;
@@ -445,8 +454,9 @@ void __dump_page_owner(struct page *page)
	}

	depot_fetch_stack(handle, &trace);
	pr_alert("page allocated via order %u, migratetype %s, gfp_mask %#x(%pGg)\n",
		 page_owner->order, migratetype_names[mt], gfp_mask, &gfp_mask);
	pr_alert("page allocated via order %u, migratetype %s, gfp_mask %#x(%pGg), pid %d, ts %llu ns\n",
		 page_owner->order, migratetype_names[mt], gfp_mask, &gfp_mask,
		 page_owner->pid, page_owner->ts_nsec);
	print_stack_trace(&trace, 0);

	if (page_owner->last_migrate_reason != -1)