[PATCH] mm/page_owner.c: allow page_owner with given start_pfn/count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



by default, page_owner iterates all page from min_low_pfn to
max_pfn, this cost too much time if we want an alternative pfn range.

with this patch it allows user to set pfn range to dump the page_onwer.

Signed-off-by: Kassey Li <quic_yingangl@xxxxxxxxxxx>
---
 mm/page_owner.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index e4c6f3f1695b..79c634d11ee6 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -41,6 +41,39 @@ static depot_stack_handle_t dummy_handle;
 static depot_stack_handle_t failure_handle;
 static depot_stack_handle_t early_handle;
 
+static u64 start_pfn;
+static u64 end_pfn;
+
+static int debugfs_start_pfn_u64_set(void *data, u64 val)
+{
+	if (val < min_low_pfn || val > max_pfn)
+		return -EINVAL;
+	start_pfn = val;
+	return 0;
+}
+static int debugfs_start_pfn_u64_get(void *data, u64 *val)
+{
+	*val = start_pfn;
+	return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_start_pfn, debugfs_start_pfn_u64_get,
+	debugfs_start_pfn_u64_set, "%lld\n");
+
+static int debugfs_end_pfn_u64_set(void *data, u64 val)
+{
+	if (val > max_pfn || val < start_pfn)
+		return -EINVAL;
+	end_pfn = val;
+	return 0;
+}
+static int debugfs_end_pfn_u64_get(void *data, u64 *val)
+{
+	*val = end_pfn;
+	return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_end_pfn, debugfs_end_pfn_u64_get,
+	debugfs_end_pfn_u64_set, "%lld\n");
+
 static void init_early_allocated_pages(void);
 
 static int __init early_page_owner_param(char *buf)
@@ -497,7 +530,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		return -EINVAL;
 
 	page = NULL;
-	pfn = min_low_pfn + *ppos;
+	pfn = start_pfn + *ppos;
 
 	/* Find a valid PFN or the start of a MAX_ORDER_NR_PAGES area */
 	while (!pfn_valid(pfn) && (pfn & (MAX_ORDER_NR_PAGES - 1)) != 0)
@@ -506,7 +539,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	drain_all_pages(NULL);
 
 	/* Find an allocated page */
-	for (; pfn < max_pfn; pfn++) {
+	for (; pfn < end_pfn; pfn++) {
 		/*
 		 * If the new page is in a new MAX_ORDER_NR_PAGES area,
 		 * validate the area as existing, skip it if not
@@ -561,7 +594,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			continue;
 
 		/* Record the next PFN to read in the file offset */
-		*ppos = (pfn - min_low_pfn) + 1;
+		*ppos = (pfn - start_pfn) + 1;
 
 		return print_page_owner(buf, count, pfn, page,
 				page_owner, handle);
@@ -671,6 +704,12 @@ static int __init pageowner_init(void)
 
 	debugfs_create_file("page_owner", 0400, NULL, NULL,
 			    &proc_page_owner_operations);
+	debugfs_create_file("page_owner_start_pfn", 0644, NULL, NULL,
+				&fops_start_pfn);
+	debugfs_create_file("page_owner_end_pfn", 0644, NULL, NULL,
+				&fops_end_pfn);
+	start_pfn = min_low_pfn;
+	end_pfn = max_pfn;
 
 	return 0;
 }
-- 
2.17.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux