Skip to content

Commit f5d64ae

Browse files
yukaixiongJoelgranados
authored andcommitted
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 <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 94eed61 commit f5d64ae

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

fs/drop_caches.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "internal.h"
1515

1616
/* A global variable is a bit ugly, but it keeps the code simple */
17-
int sysctl_drop_caches;
17+
static int sysctl_drop_caches;
1818

1919
static void drop_pagecache_sb(struct super_block *sb, void *unused)
2020
{
@@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
4848
iput(toput_inode);
4949
}
5050

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,
5252
void *buffer, size_t *length, loff_t *ppos)
5353
{
5454
int ret;
@@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
7777
}
7878
return 0;
7979
}
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);

include/linux/mm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,12 +3789,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)
37893789

37903790
extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm);
37913791

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-
37983792
void drop_slab(void);
37993793

38003794
#ifndef CONFIG_MMU

kernel/sysctl.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,15 +2014,6 @@ static const struct ctl_table kern_table[] = {
20142014
};
20152015

20162016
static const struct ctl_table vm_table[] = {
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-
},
20262017
{
20272018
.procname = "vfs_cache_pressure",
20282019
.data = &sysctl_vfs_cache_pressure,

0 commit comments

Comments
 (0)