From: Liu Ye <liuye@xxxxxxxxxx>
The function kpageflags_read and kpagecgroup_read is quite similar
to kpagecount_read. Consider refactoring common code into a helper
function to reduce code duplication.
Signed-off-by: Liu Ye <liuye@xxxxxxxxxx>
---
fs/proc/page.c | 158 ++++++++++++++++---------------------------------
1 file changed, 50 insertions(+), 108 deletions(-)
diff --git a/fs/proc/page.c b/fs/proc/page.c
index a55f5acefa97..f413016ebe67 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -37,19 +37,17 @@ static inline unsigned long get_max_dump_pfn(void)
#endif
}
-/* /proc/kpagecount - an array exposing page mapcounts
- *
- * Each entry is a u64 representing the corresponding
- * physical page mapcount.
- */
-static ssize_t kpagecount_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t kpage_read(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos,
+ u64 (*get_page_info)(struct page *))