fs/drop_caches: move drop_caches sysctls into its own file
Subsystems (4)
PATCH 1/1 fs/drop_caches: move drop_caches sysctls into its own file
This moves the fs/drop_caches.c respective sysctls to its own file.
--- fs/drop_caches.c | 25 ++++++++++++++++++++++--- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 22 insertions(+), 18 deletions(-)
fs/drop_caches.c +22 -3
@@ -12,8 +12,7 @@#include <linux/gfp.h> #include "internal.h" -/* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches;static void drop_pagecache_sb (struct super_block *sb,void *unused) {
@@ -47,7 +46,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)iput (toput_inode); } -int drop_caches_sysctl_handler (struct ctl_table *table,int write, +static int drop_caches_sysctl_handler (struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;
@@ -75,3 +74,23 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, }return 0 ; } + +static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + }, + {} +}; + +static int __init drop_cache_init (void ) +{ +register_sysctl_init ("vm" , drop_caches_table); +return 0 ; +} +fs_initcall (drop_cache_init);
include/linux/mm.h +0 -6
@@ -3513,12 +3513,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)extern bool process_shares_mm (struct task_struct *p,struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler (struct ctl_table *,int ,void *,size_t *, -loff_t *); -#endif -void drop_slab (void );#ifndef CONFIG_MMU
kernel/sysctl.c +0 -9
@@ -2148,15 +2148,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = lowmem_reserve_ratio_sysctl_handler, }, - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - },#ifdef CONFIG_COMPACTION { .procname = "compact_memory",
Signature · 1 line
2.35.1
Christian Brauner
maintainerQuoted 43 lines · Yangtao Li
This moves the
fs/drop_caches.crespective sysctls to its own file.Signed-off-by Yangtao Li <[email protected]>--- fs/drop_caches.c | 25 ++++++++++++++++++++++--- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 22 insertions(+), 18 deletions(-)fs/drop_caches.c +9
-3@@ -12,8 +12,7 @@#include <linux/gfp.h> #include "internal.h" -/* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches;static void drop_pagecache_sb (struct super_block *sb,void *unused) {@@ -47,7 +46,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)iput (toput_inode); } -int drop_caches_sysctl_handler (struct ctl_table *table,int write, +static int drop_caches_sysctl_handler (struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;@@ -75,3 +74,23 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, }return 0 ; } + +static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 ,
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 93
Quoted 10 lines
fs/drop_caches.c +10
-0+ .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, + {} +}; + +static int __init drop_cache_init (void ) +{ +register_sysctl_init ("vm" , drop_caches_table);
Does this belong under mm/ or fs/?
And is it intended to be moved into a completely separate file? Feels abit wasteful for 20 lines of code...
Quoted 48 lines · Christian Brauner
Quoted 47 lines · Yangtao Li
This moves the
fs/drop_caches.crespective sysctls to its own file.Signed-off-by Yangtao Li <[email protected]>--- fs/drop_caches.c | 25 ++++++++++++++++++++++--- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 22 insertions(+), 18 deletions(-)fs/drop_caches.c +13
-3@@ -12,8 +12,7 @@#include <linux/gfp.h> #include "internal.h" -/* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches;static void drop_pagecache_sb (struct super_block *sb,void *unused) {@@ -47,7 +46,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)iput (toput_inode); } -int drop_caches_sysctl_handler (struct ctl_table *table,int write, +static int drop_caches_sysctl_handler (struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;@@ -75,3 +74,23 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, }return 0 ; } + +static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + },
Quoted 8 lines
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 93
Quoted 6 lines
fs/drop_caches.c +6
-0+ {} +}; + +static int __init drop_cache_init (void ) +{ +register_sysctl_init ("vm" , drop_caches_table);Does this belong under
mm/orfs/?
To not break old userspace it must be kept under "vm" because the patch author is moving it from the kernel/sysctl.c table which used the "vm" table.
Moving it to "fs" would be a highly functional change which should require review from maintainers it would not break existing userspace expecations.
Quoted 1 line
And is it intended to be moved into a completely separate file?
What do you mean by this?
Quoted 1 line
Feels abit wasteful for 20 lines of code...
Not sure what you mean by this either. The commit log sucks, please review got log kernel/sysclt.c for much better commit logs for the rationale of moving sysctls out out kernel/sysctl.c to their own respective places.
Luis
Christian Brauner
maintainerQuoted 58 lines · Luis Chamberlain
Quoted 48 lines · Christian Brauner
Quoted 47 lines · Yangtao Li
This moves the
fs/drop_caches.crespective sysctls to its own file.Signed-off-by Yangtao Li <[email protected]>--- fs/drop_caches.c | 25 ++++++++++++++++++++++--- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 22 insertions(+), 18 deletions(-)fs/drop_caches.c +13
-3@@ -12,8 +12,7 @@#include <linux/gfp.h> #include "internal.h" -/* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches;static void drop_pagecache_sb (struct super_block *sb,void *unused) {@@ -47,7 +46,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)iput (toput_inode); } -int drop_caches_sysctl_handler (struct ctl_table *table,int write, +static int drop_caches_sysctl_handler (struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;@@ -75,3 +74,23 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, }return 0 ; } + +static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + },Quoted 8 lines
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 93
Quoted 6 lines
fs/drop_caches.c +6
-0+ {} +}; + +static int __init drop_cache_init (void ) +{ +register_sysctl_init ("vm" , drop_caches_table);Does this belong under
mm/orfs/?
Quoted 7 lines
To not break old userspace it must be kept under "vm" because the patch author is moving it from the
kernel/sysctl.ctable which used the "vm" table.Moving it to "fs" would be a highly functional change which should require review from maintainers it would not break existing userspace expecations.
No, I was asking whether this belongs under the fs/ or mm/ directory. But I misread the patch. I thought at first, that the patch moved the file from the mm/ to the fs/ directory. But that's obviously not the case... So ignore me.
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 89
Quoted 12 lines · Yangtao Li
fs/drop_caches.c +12
-0+static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + }, + {} +};
Could we avoid doing this until we no longer need an entire zero entry after the last one? Also, please post scripts/bloat-o-meter results for before-and-after.
Quoted 16 lines · Matthew Wilcox
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 89
Quoted 12 lines · Yangtao Li
fs/drop_caches.c +12
-0+static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + }, + {} +};Could we avoid doing this until we no longer need an entire zero entry after the last one?
That may be 2-3 kernel release from now. The way to use ARRAY_SIZE() really is to deprecate the crap APIs that allow messy directory sysctl structures.
Quoted 2 lines
Also, please post
scripts/bloat-o-meterresults
for before-and-after.
It should be one extry ~ ctl_table per move.
Luis
Quoted 18 lines · Luis Chamberlain
Quoted 16 lines · Matthew Wilcox
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 89
Quoted 12 lines · Yangtao Li
fs/drop_caches.c +12
-0+static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + }, + {} +};Could we avoid doing this until we no longer need an entire zero entry after the last one?
Quoted 3 lines
That may be 2-3 kernel release from now. The way to use
ARRAY_SIZE()really is to deprecate the crap APIs that allow messy directory sysctl structures.
I'm OK with waiting another year to commence this cleanup. We've lived with the giant tables for decades already. Better to get the new API right than split the tables now, then have to touch all the places again.
Quoted 19 lines · Matthew Wilcox
Quoted 18 lines · Luis Chamberlain
Quoted 16 lines · Matthew Wilcox
fs/drop_caches.c int drop_caches_sysctl_handler(struct ctl_table *table, int write, · line 89
Quoted 12 lines · Yangtao Li
fs/drop_caches.c +12
-0+static struct ctl_table drop_caches_table[] = { + { + .procname ="drop_caches" , + .data = &sysctl_drop_caches, + .maxlen =sizeof (int ), + .mode =0200 , + .proc_handler = drop_caches_sysctl_handler, + .extra1 =SYSCTL_ONE , + .extra2 =SYSCTL_FOUR , + }, + {} +};Could we avoid doing this until we no longer need an entire zero entry after the last one?
Quoted 8 lines
Quoted 3 lines
That may be 2-3 kernel release from now. The way to use
ARRAY_SIZE()really is to deprecate the crap APIs that allow messy directory sysctl structures.I'm OK with waiting another year to commence this cleanup. We've lived with the giant tables for decades already. Better to get the new API right than split the tables now, then have to touch all the places again.
We can do that sure.
Luis