diff mbox series

[v2] mm/page_owner.c: add llseek for page_owner

Message ID 20220727125508.5154-1-quic_yingangl@quicinc.com (mailing list archive)
State New
Headers show
Series [v2] mm/page_owner.c: add llseek for page_owner | expand

Commit Message

Kassey Li July 27, 2022, 12:55 p.m. UTC
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@quicinc.com>
---
 mm/page_owner.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Comments

kernel test robot July 28, 2022, 12:57 p.m. UTC | #1
Hi Kassey,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Kassey-Li/mm-page_owner-c-add-llseek-for-page_owner/20220727-205617
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: arm64-randconfig-r025-20220727 (https://download.01.org/0day-ci/archive/20220728/202207282029.T2NTavCf-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 8dfaecc4c24494337933aff9d9166486ca0949f1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/5533df4120ec1703df71542154e8c5b0b21ddb10
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kassey-Li/mm-page_owner-c-add-llseek-for-page_owner/20220727-205617
        git checkout 5533df4120ec1703df71542154e8c5b0b21ddb10
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> mm/page_owner.c:573:8: warning: no previous prototype for function 'llseek_page_owner' [-Wmissing-prototypes]
   loff_t llseek_page_owner(struct file *file, loff_t offset, int whence)
          ^
   mm/page_owner.c:573:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   loff_t llseek_page_owner(struct file *file, loff_t offset, int whence)
   ^
   static 
   1 warning generated.


vim +/llseek_page_owner +573 mm/page_owner.c

   572	
 > 573	loff_t llseek_page_owner(struct file *file, loff_t offset, int whence)
   574	{
   575		loff_t retval = 0;
   576		switch (whence) {
   577			case SEEK_CUR:
   578			case SEEK_SET:
   579				file->f_pos = offset;
   580				break;
   581			default:
   582				retval = -ENXIO;
   583		}
   584	
   585		return retval;
   586	}
   587
diff mbox series

Patch

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)