Skip to contentSkip to conversation

mm: move page-writeback sysctls to is own file

PATCH Superseded zhanglianjie 3 participants 4 messages Jan 28, 2022 – Feb 2, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: move page-writeback sysctls to is own file

kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.

So move the page-writeback sysctls to its own file.

include/linux/writeback.h +0 -15
index fec248ab1fec..dc2b94e6a94f 100644
@@ -345,28 +345,13 @@ void wb_domain_exit(struct wb_domain *dom);
 extern struct wb_domain global_wb_domain;
 
 /* These are exported to sysctl. */
-extern int dirty_background_ratio;
-extern unsigned long dirty_background_bytes;
-extern int vm_dirty_ratio;
-extern unsigned long vm_dirty_bytes;
 extern unsigned int dirty_writeback_interval;
 extern unsigned int dirty_expire_interval;
 extern unsigned int dirtytime_expire_interval;
-extern int vm_highmem_is_dirtyable;
 extern int laptop_mode;
 
-int dirty_background_ratio_handler(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-int dirty_background_bytes_handler(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-int dirty_ratio_handler(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-int dirty_bytes_handler(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
 int dirtytime_interval_handler(struct ctl_table *table, int write,
 		void *buffer, size_t *lenp, loff_t *ppos);
-int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
 
 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
 unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);
kernel/sysctl.c +0 -69

93 lines not on this page · raw message

mm/page-writeback.c +84 -5

126 lines not on this page · raw message

--
2.20.1

#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi zhanglianjie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.17-rc1 next-20220128]
[cannot apply to hnaz-mm/master linux/master kees/for-next/pstore] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 23a46422c56144939c091c76cf389aa863ce9c18
config: arm64-buildonly-randconfig-r005-20220127 (https://download.01.org/0day-ci/archive/20220129/202201290141.GDKdUC72-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 33b45ee44b1f32ffdbc995e6fec806271b4b3ba4)

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/0day-ci/linux/commit/d24502aa729978894feb2de10481cd139ae5bb42
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052 git checkout d24502aa729978894feb2de10481cd139ae5bb42
# save the config file to linux build tree
mkdir build_dir
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 as appropriate

All warnings (new ones prefixed by >>):

mm/page-writeback.c:509:5: warning: no previous prototype for function 'dirty_background_ratio_handler' [-Wmissing-prototypes] int dirty_background_ratio_handler(struct ctl_table *table, int write,

       ^
   mm/page-writeback.c:509:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dirty_background_ratio_handler(struct ctl_table *table, int write,
   ^
   static 
   mm/page-writeback.c:520:5: warning: no previous prototype for function 'dirty_background_bytes_handler' [-Wmissing-prototypes]
   int dirty_background_bytes_handler(struct ctl_table *table, int write,
       ^
   mm/page-writeback.c:520:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dirty_background_bytes_handler(struct ctl_table *table, int write,
   ^
   static 
   mm/page-writeback.c:531:5: warning: no previous prototype for function 'dirty_ratio_handler' [-Wmissing-prototypes]
   int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
       ^
   mm/page-writeback.c:531:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
   ^
   static 
   mm/page-writeback.c:545:5: warning: no previous prototype for function 'dirty_bytes_handler' [-Wmissing-prototypes]
   int dirty_bytes_handler(struct ctl_table *table, int write,
       ^
   mm/page-writeback.c:545:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dirty_bytes_handler(struct ctl_table *table, int write,
   ^
   static 
   mm/page-writeback.c:2002:5: warning: no previous prototype for function 'dirty_writeback_centisecs_handler' [-Wmissing-prototypes]
   int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
       ^
   mm/page-writeback.c:2002:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
   ^
   static 
>> mm/page-writeback.c:93:28: warning: unused variable 'dirty_bytes_min' [-Wunused-const-variable]
   static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
                              ^

6 warnings generated.

vim +/dirty_bytes_min +93 mm/page-writeback.c

91
92 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */

  > 93	static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
    94	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to zhanglianjie
Thank you for the patch! Perhaps something to improve:

Hi zhanglianjie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.17-rc1 next-20220128]
[cannot apply to hnaz-mm/master linux/master kees/for-next/pstore] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 23a46422c56144939c091c76cf389aa863ce9c18
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20220129/202201290051.7pu9CEMG-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/d24502aa729978894feb2de10481cd139ae5bb42
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052 git checkout d24502aa729978894feb2de10481cd139ae5bb42
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> mm/page-writeback.c:509:5: warning: no previous prototype for 'dirty_background_ratio_handler' [-Wmissing-prototypes]
     509 | int dirty_background_ratio_handler(struct ctl_table *table, int write,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> mm/page-writeback.c:520:5: warning: no previous prototype for 'dirty_background_bytes_handler' [-Wmissing-prototypes]
     520 | int dirty_background_bytes_handler(struct ctl_table *table, int write,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> mm/page-writeback.c:531:5: warning: no previous prototype for 'dirty_ratio_handler' [-Wmissing-prototypes]
     531 | int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
         |     ^~~~~~~~~~~~~~~~~~~
>> mm/page-writeback.c:545:5: warning: no previous prototype for 'dirty_bytes_handler' [-Wmissing-prototypes]
     545 | int dirty_bytes_handler(struct ctl_table *table, int write,
         |     ^~~~~~~~~~~~~~~~~~~
>> mm/page-writeback.c:2002:5: warning: no previous prototype for 'dirty_writeback_centisecs_handler' [-Wmissing-prototypes]

2002 | int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/dirty_background_ratio_handler +509 mm/page-writeback.c

a756cf5908530e Johannes Weiner 2012-01-10 508

2da02997e08d3e David Rientjes    2009-01-06 @509  int dirty_background_ratio_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  510  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  511  {
2da02997e08d3e David Rientjes    2009-01-06  512  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  513  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  514  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  515  	if (ret == 0 && write)
2da02997e08d3e David Rientjes    2009-01-06  516  		dirty_background_bytes = 0;
2da02997e08d3e David Rientjes    2009-01-06  517  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  518  }
2da02997e08d3e David Rientjes    2009-01-06  519  
2da02997e08d3e David Rientjes    2009-01-06 @520  int dirty_background_bytes_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  521  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  522  {
2da02997e08d3e David Rientjes    2009-01-06  523  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  524  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  525  	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  526  	if (ret == 0 && write)
2da02997e08d3e David Rientjes    2009-01-06  527  		dirty_background_ratio = 0;
2da02997e08d3e David Rientjes    2009-01-06  528  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  529  }
2da02997e08d3e David Rientjes    2009-01-06  530  
32927393dc1ccd Christoph Hellwig 2020-04-24 @531  int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
32927393dc1ccd Christoph Hellwig 2020-04-24  532  		size_t *lenp, loff_t *ppos)
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  533  {
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  534  	int old_ratio = vm_dirty_ratio;
2da02997e08d3e David Rientjes    2009-01-06  535  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  536  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  537  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  538  	if (ret == 0 && write && vm_dirty_ratio != old_ratio) {
eb608e3a344b3a Jan Kara          2012-05-24  539  		writeback_set_ratelimit();
2da02997e08d3e David Rientjes    2009-01-06  540  		vm_dirty_bytes = 0;
2da02997e08d3e David Rientjes    2009-01-06  541  	}
2da02997e08d3e David Rientjes    2009-01-06  542  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  543  }
2da02997e08d3e David Rientjes    2009-01-06  544  
2da02997e08d3e David Rientjes    2009-01-06 @545  int dirty_bytes_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  546  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  547  {
fc3501d411d348 Sven Wegener      2009-02-11  548  	unsigned long old_bytes = vm_dirty_bytes;
2da02997e08d3e David Rientjes    2009-01-06  549  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  550  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  551  	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  552  	if (ret == 0 && write && vm_dirty_bytes != old_bytes) {
eb608e3a344b3a Jan Kara          2012-05-24  553  		writeback_set_ratelimit();
2da02997e08d3e David Rientjes    2009-01-06  554  		vm_dirty_ratio = 0;
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  555  	}
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  556  	return ret;
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  557  }
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  558  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Likewise here, these test results are assuming an older kernel. Instead linux-next can be a better target to test for for these patches.

Luis

Quoted 103 lines · kernel test robot

Hi zhanglianjie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.17-rc1 next-20220128]
[cannot apply to hnaz-mm/master linux/master kees/for-next/pstore] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 23a46422c56144939c091c76cf389aa863ce9c18
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20220129/202201290051.7pu9CEMG-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/d24502aa729978894feb2de10481cd139ae5bb42
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review zhanglianjie/mm-move-page-writeback-sysctls-to-is-own-file/20220128-172052 git checkout d24502aa729978894feb2de10481cd139ae5bb42
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

mm/page-writeback.c:509:5: warning: no previous prototype for 'dirty_background_ratio_handler' [-Wmissing-prototypes]

509 | int dirty_background_ratio_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

mm/page-writeback.c:520:5: warning: no previous prototype for 'dirty_background_bytes_handler' [-Wmissing-prototypes]

520 | int dirty_background_bytes_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

mm/page-writeback.c:531:5: warning: no previous prototype for 'dirty_ratio_handler' [-Wmissing-prototypes]

531 | int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
| ^~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

mm/page-writeback.c:545:5: warning: no previous prototype for 'dirty_bytes_handler' [-Wmissing-prototypes]

545 | int dirty_bytes_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

mm/page-writeback.c:2002:5: warning: no previous prototype for 'dirty_writeback_centisecs_handler' [-Wmissing-prototypes]

2002 | int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/dirty_background_ratio_handler +509 mm/page-writeback.c

a756cf5908530e Johannes Weiner 2012-01-10 508

2da02997e08d3e David Rientjes    2009-01-06 @509  int dirty_background_ratio_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  510  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  511  {
2da02997e08d3e David Rientjes    2009-01-06  512  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  513  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  514  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  515  	if (ret == 0 && write)
2da02997e08d3e David Rientjes    2009-01-06  516  		dirty_background_bytes = 0;
2da02997e08d3e David Rientjes    2009-01-06  517  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  518  }
2da02997e08d3e David Rientjes    2009-01-06  519  
2da02997e08d3e David Rientjes    2009-01-06 @520  int dirty_background_bytes_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  521  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  522  {
2da02997e08d3e David Rientjes    2009-01-06  523  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  524  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  525  	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  526  	if (ret == 0 && write)
2da02997e08d3e David Rientjes    2009-01-06  527  		dirty_background_ratio = 0;
2da02997e08d3e David Rientjes    2009-01-06  528  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  529  }
2da02997e08d3e David Rientjes    2009-01-06  530  
32927393dc1ccd Christoph Hellwig 2020-04-24 @531  int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
32927393dc1ccd Christoph Hellwig 2020-04-24  532  		size_t *lenp, loff_t *ppos)
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  533  {
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  534  	int old_ratio = vm_dirty_ratio;
2da02997e08d3e David Rientjes    2009-01-06  535  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  536  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  537  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  538  	if (ret == 0 && write && vm_dirty_ratio != old_ratio) {
eb608e3a344b3a Jan Kara          2012-05-24  539  		writeback_set_ratelimit();
2da02997e08d3e David Rientjes    2009-01-06  540  		vm_dirty_bytes = 0;
2da02997e08d3e David Rientjes    2009-01-06  541  	}
2da02997e08d3e David Rientjes    2009-01-06  542  	return ret;
2da02997e08d3e David Rientjes    2009-01-06  543  }
2da02997e08d3e David Rientjes    2009-01-06  544  
2da02997e08d3e David Rientjes    2009-01-06 @545  int dirty_bytes_handler(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  546  		void *buffer, size_t *lenp, loff_t *ppos)
2da02997e08d3e David Rientjes    2009-01-06  547  {
fc3501d411d348 Sven Wegener      2009-02-11  548  	unsigned long old_bytes = vm_dirty_bytes;
2da02997e08d3e David Rientjes    2009-01-06  549  	int ret;
2da02997e08d3e David Rientjes    2009-01-06  550  
8d65af789f3e2c Alexey Dobriyan   2009-09-23  551  	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
2da02997e08d3e David Rientjes    2009-01-06  552  	if (ret == 0 && write && vm_dirty_bytes != old_bytes) {
eb608e3a344b3a Jan Kara          2012-05-24  553  		writeback_set_ratelimit();
2da02997e08d3e David Rientjes    2009-01-06  554  		vm_dirty_ratio = 0;
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  555  	}
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  556  	return ret;
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  557  }
04fbfdc14e5f48 Peter Zijlstra    2007-10-16  558  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org