[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220727125508.5154-1-quic_yingangl@quicinc.com>
Date: Wed, 27 Jul 2022 20:55:08 +0800
From: Kassey Li <quic_yingangl@...cinc.com>
To: akpm@...ux-foundation.org, vbabka@...nel.org
Cc: minchan@...nel.org, iamjoonsoo.kim@....com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
quic_yingangl@...cinc.com
Subject: [PATCH v2] mm/page_owner.c: add llseek for page_owner
There is usage to dump a given cma region page_owner
instead of all page's.
This change allows to specify a ppos as start_pfn
by fseek.
Any invalid ppos will be skipped, so it did not
broken the origin dump feature.
Signed-off-by: Kassey Li <quic_yingangl@...cinc.com>
---
mm/page_owner.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index e4c6f3f1695b..f0bc75421de0 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -497,8 +497,8 @@ 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 = *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)
pfn++;
@@ -561,7 +561,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 + 1;
return print_page_owner(buf, count, pfn, page,
page_owner, handle);
@@ -570,6 +570,21 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
return 0;
}
+loff_t llseek_page_owner(struct file *file, loff_t offset, int whence)
+{
+ loff_t retval = 0;
+ switch (whence) {
+ case SEEK_CUR:
+ case SEEK_SET:
+ file->f_pos = offset;
+ break;
+ default:
+ retval = -ENXIO;
+ }
+
+ return retval;
+}
+
static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
{
unsigned long pfn = zone->zone_start_pfn;
@@ -658,8 +673,11 @@ static void init_early_allocated_pages(void)
init_zones_in_node(pgdat);
}
+
+
static const struct file_operations proc_page_owner_operations = {
.read = read_page_owner,
+ .llseek = llseek_page_owner,
};
static int __init pageowner_init(void)
--
2.17.1
Powered by blists - more mailing lists