Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: drop_caches: move sysctl to fs/drop_caches.c

The sysctl_drop_caches to fs/drop_caches.c, move it to
fs/drop_caches.c from /kernel/sysctl.c. And remove the
useless extern variable declaration from include/linux/mm.h

Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>

authored by

Kaixiong Yu and committed by
Joel Granados
f5d64ae3 94eed61d

+21 -17
+21 -2
fs/drop_caches.c
··· 14 14 #include "internal.h" 15 15 16 16 /* A global variable is a bit ugly, but it keeps the code simple */ 17 - int sysctl_drop_caches; 17 + static int sysctl_drop_caches; 18 18 19 19 static void drop_pagecache_sb(struct super_block *sb, void *unused) 20 20 { ··· 48 48 iput(toput_inode); 49 49 } 50 50 51 - int drop_caches_sysctl_handler(const struct ctl_table *table, int write, 51 + static int drop_caches_sysctl_handler(const struct ctl_table *table, int write, 52 52 void *buffer, size_t *length, loff_t *ppos) 53 53 { 54 54 int ret; ··· 77 77 } 78 78 return 0; 79 79 } 80 + 81 + static const struct ctl_table drop_caches_table[] = { 82 + { 83 + .procname = "drop_caches", 84 + .data = &sysctl_drop_caches, 85 + .maxlen = sizeof(int), 86 + .mode = 0200, 87 + .proc_handler = drop_caches_sysctl_handler, 88 + .extra1 = SYSCTL_ONE, 89 + .extra2 = SYSCTL_FOUR, 90 + }, 91 + }; 92 + 93 + static int __init init_vm_drop_caches_sysctls(void) 94 + { 95 + register_sysctl_init("vm", drop_caches_table); 96 + return 0; 97 + } 98 + fs_initcall(init_vm_drop_caches_sysctls);
-6
include/linux/mm.h
··· 3789 3789 3790 3790 extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); 3791 3791 3792 - #ifdef CONFIG_SYSCTL 3793 - extern int sysctl_drop_caches; 3794 - int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *, 3795 - loff_t *); 3796 - #endif 3797 - 3798 3792 void drop_slab(void); 3799 3793 3800 3794 #ifndef CONFIG_MMU
-9
kernel/sysctl.c
··· 2015 2015 2016 2016 static const struct ctl_table vm_table[] = { 2017 2017 { 2018 - .procname = "drop_caches", 2019 - .data = &sysctl_drop_caches, 2020 - .maxlen = sizeof(int), 2021 - .mode = 0200, 2022 - .proc_handler = drop_caches_sysctl_handler, 2023 - .extra1 = SYSCTL_ONE, 2024 - .extra2 = SYSCTL_FOUR, 2025 - }, 2026 - { 2027 2018 .procname = "vfs_cache_pressure", 2028 2019 .data = &sysctl_vfs_cache_pressure, 2029 2020 .maxlen = sizeof(sysctl_vfs_cache_pressure),