]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: drop_caches: move sysctl to fs/drop_caches.c
authorKaixiong Yu <yukaixiong@huawei.com>
Sat, 11 Jan 2025 07:07:45 +0000 (15:07 +0800)
committerJoel Granados <joel.granados@kernel.org>
Fri, 7 Feb 2025 15:53:04 +0000 (16:53 +0100)
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>
fs/drop_caches.c
include/linux/mm.h
kernel/sysctl.c

index d45ef541d848a73cbd19205e0111c2cab3b73617..019a8b4eaaf99645c1fb178e244ef32c93dea28d 100644 (file)
@@ -14,7 +14,7 @@
 #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)
 {
@@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
        iput(toput_inode);
 }
 
-int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
+static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
                void *buffer, size_t *length, loff_t *ppos)
 {
        int ret;
@@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
        }
        return 0;
 }
+
+static const 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 init_vm_drop_caches_sysctls(void)
+{
+       register_sysctl_init("vm", drop_caches_table);
+       return 0;
+}
+fs_initcall(init_vm_drop_caches_sysctls);
index 1c470e505bd47325ea0e64ee78354b7377c61cc9..f5ba3ed8b44a3755b00763af8a37b100a947f41d 100644 (file)
@@ -3789,12 +3789,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(const struct ctl_table *, int, void *, size_t *,
-               loff_t *);
-#endif
-
 void drop_slab(void);
 
 #ifndef CONFIG_MMU
index 40d68fb54779150649b8ee32d65516da82c40079..b7142ed5c48ddb90c638ef16a9684fd2e42f1e85 100644 (file)
@@ -2014,15 +2014,6 @@ static const struct ctl_table kern_table[] = {
 };
 
 static const struct ctl_table vm_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,
-       },
        {
                .procname       = "vfs_cache_pressure",
                .data           = &sysctl_vfs_cache_pressure,