linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_owner.c: allow page_owner with given start_pfn/count
@ 2022-07-22 15:08 Kassey Li
  2022-07-22 15:38 ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Kassey Li @ 2022-07-22 15:08 UTC (permalink / raw)
  To: akpm; +Cc: Kassey Li, minchan, iamjoonsoo.kim, linux-kernel, linux-mm

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@quicinc.com>
---
 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-27 12:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-22 15:08 [PATCH] mm/page_owner.c: allow page_owner with given start_pfn/count Kassey Li
2022-07-22 15:38 ` Matthew Wilcox
2022-07-25  8:39   ` Kassey Li
2022-07-26 14:03     ` Vlastimil Babka (SUSE)
2022-07-27  7:44       ` Kassey Li
2022-07-27 10:59         ` Vlastimil Babka (SUSE)
2022-07-27 12:58           ` Kassey Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).