Skip to content

Commit b8974b8

Browse files
yukaixiongJoelgranados
authored andcommitted
mm: vmstat: move sysctls to mm/vmstat.c
This moves all vmstat related sysctls to its own file, removes useless extern variable declarations, and do some related clean-ups. To avoid compiler warnings when CONFIG_PROC_FS is not defined, add the macro definition CONFIG_PROC_FS ahead CONFIG_NUMA in vmstat.c. Signed-off-by: Kaixiong Yu <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 7347586 commit b8974b8

File tree

3 files changed

+40
-43
lines changed

3 files changed

+40
-43
lines changed

include/linux/vmstat.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@
1010
#include <linux/static_key.h>
1111
#include <linux/mmdebug.h>
1212

13-
extern int sysctl_stat_interval;
14-
1513
#ifdef CONFIG_NUMA
16-
#define ENABLE_NUMA_STAT 1
17-
#define DISABLE_NUMA_STAT 0
18-
extern int sysctl_vm_numa_stat;
1914
DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
20-
int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
21-
void *buffer, size_t *length, loff_t *ppos);
2215
#endif
2316

2417
struct reclaim_stat {
@@ -304,10 +297,6 @@ void quiet_vmstat(void);
304297
void cpu_vm_stats_fold(int cpu);
305298
void refresh_zone_stat_thresholds(void);
306299

307-
struct ctl_table;
308-
int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
309-
loff_t *ppos);
310-
311300
void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);
312301

313302
int calculate_pressure_threshold(struct zone *zone);

kernel/sysctl.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include <linux/limits.h>
5050
#include <linux/dcache.h>
5151
#include <linux/syscalls.h>
52-
#include <linux/vmstat.h>
5352
#include <linux/nfs_fs.h>
5453
#include <linux/acpi.h>
5554
#include <linux/reboot.h>
@@ -2071,17 +2070,6 @@ static const struct ctl_table vm_table[] = {
20712070
.extra1 = SYSCTL_ZERO,
20722071
.extra2 = SYSCTL_TWO_HUNDRED,
20732072
},
2074-
#ifdef CONFIG_NUMA
2075-
{
2076-
.procname = "numa_stat",
2077-
.data = &sysctl_vm_numa_stat,
2078-
.maxlen = sizeof(int),
2079-
.mode = 0644,
2080-
.proc_handler = sysctl_vm_numa_stat_handler,
2081-
.extra1 = SYSCTL_ZERO,
2082-
.extra2 = SYSCTL_ONE,
2083-
},
2084-
#endif
20852073
{
20862074
.procname = "drop_caches",
20872075
.data = &sysctl_drop_caches,
@@ -2147,22 +2135,6 @@ static const struct ctl_table vm_table[] = {
21472135
.extra1 = SYSCTL_ZERO,
21482136
},
21492137
#endif
2150-
#ifdef CONFIG_SMP
2151-
{
2152-
.procname = "stat_interval",
2153-
.data = &sysctl_stat_interval,
2154-
.maxlen = sizeof(sysctl_stat_interval),
2155-
.mode = 0644,
2156-
.proc_handler = proc_dointvec_jiffies,
2157-
},
2158-
{
2159-
.procname = "stat_refresh",
2160-
.data = NULL,
2161-
.maxlen = 0,
2162-
.mode = 0600,
2163-
.proc_handler = vmstat_refresh,
2164-
},
2165-
#endif
21662138
#ifdef CONFIG_MMU
21672139
{
21682140
.procname = "mmap_min_addr",

mm/vmstat.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131

3232
#include "internal.h"
3333

34+
#ifdef CONFIG_PROC_FS
3435
#ifdef CONFIG_NUMA
35-
int sysctl_vm_numa_stat = ENABLE_NUMA_STAT;
36+
#define ENABLE_NUMA_STAT 1
37+
static int sysctl_vm_numa_stat = ENABLE_NUMA_STAT;
3638

3739
/* zero numa counters within a zone */
3840
static void zero_zone_numa_counters(struct zone *zone)
@@ -74,7 +76,7 @@ static void invalid_numa_statistics(void)
7476

7577
static DEFINE_MUTEX(vm_numa_stat_lock);
7678

77-
int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
79+
static int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
7880
void *buffer, size_t *length, loff_t *ppos)
7981
{
8082
int ret, oldval;
@@ -102,6 +104,7 @@ int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
102104
return ret;
103105
}
104106
#endif
107+
#endif /* CONFIG_PROC_FS */
105108

106109
#ifdef CONFIG_VM_EVENT_COUNTERS
107110
DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
@@ -1938,7 +1941,7 @@ static const struct seq_operations vmstat_op = {
19381941

19391942
#ifdef CONFIG_SMP
19401943
static DEFINE_PER_CPU(struct delayed_work, vmstat_work);
1941-
int sysctl_stat_interval __read_mostly = HZ;
1944+
static int sysctl_stat_interval __read_mostly = HZ;
19421945
static int vmstat_late_init_done;
19431946

19441947
#ifdef CONFIG_PROC_FS
@@ -1947,7 +1950,7 @@ static void refresh_vm_stats(struct work_struct *work)
19471950
refresh_cpu_vm_stats(true);
19481951
}
19491952

1950-
int vmstat_refresh(const struct ctl_table *table, int write,
1953+
static int vmstat_refresh(const struct ctl_table *table, int write,
19511954
void *buffer, size_t *lenp, loff_t *ppos)
19521955
{
19531956
long val;
@@ -2196,6 +2199,38 @@ static int __init vmstat_late_init(void)
21962199
late_initcall(vmstat_late_init);
21972200
#endif
21982201

2202+
#ifdef CONFIG_PROC_FS
2203+
static const struct ctl_table vmstat_table[] = {
2204+
#ifdef CONFIG_SMP
2205+
{
2206+
.procname = "stat_interval",
2207+
.data = &sysctl_stat_interval,
2208+
.maxlen = sizeof(sysctl_stat_interval),
2209+
.mode = 0644,
2210+
.proc_handler = proc_dointvec_jiffies,
2211+
},
2212+
{
2213+
.procname = "stat_refresh",
2214+
.data = NULL,
2215+
.maxlen = 0,
2216+
.mode = 0600,
2217+
.proc_handler = vmstat_refresh,
2218+
},
2219+
#endif
2220+
#ifdef CONFIG_NUMA
2221+
{
2222+
.procname = "numa_stat",
2223+
.data = &sysctl_vm_numa_stat,
2224+
.maxlen = sizeof(int),
2225+
.mode = 0644,
2226+
.proc_handler = sysctl_vm_numa_stat_handler,
2227+
.extra1 = SYSCTL_ZERO,
2228+
.extra2 = SYSCTL_ONE,
2229+
},
2230+
#endif
2231+
};
2232+
#endif
2233+
21992234
struct workqueue_struct *mm_percpu_wq;
22002235

22012236
void __init init_mm_internals(void)
@@ -2227,6 +2262,7 @@ void __init init_mm_internals(void)
22272262
proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op);
22282263
proc_create_seq("vmstat", 0444, NULL, &vmstat_op);
22292264
proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op);
2265+
register_sysctl_init("vm", vmstat_table);
22302266
#endif
22312267
}
22322268

0 commit comments

Comments
 (0)