diff options
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r-- | mm/vmstat.c | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c index 4bb13e72ac97..40b2db6db6b1 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -32,6 +32,77 @@ | |||
32 | 32 | ||
33 | #define NUMA_STATS_THRESHOLD (U16_MAX - 2) | 33 | #define NUMA_STATS_THRESHOLD (U16_MAX - 2) |
34 | 34 | ||
35 | #ifdef CONFIG_NUMA | ||
36 | int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; | ||
37 | |||
38 | /* zero numa counters within a zone */ | ||
39 | static void zero_zone_numa_counters(struct zone *zone) | ||
40 | { | ||
41 | int item, cpu; | ||
42 | |||
43 | for (item = 0; item < NR_VM_NUMA_STAT_ITEMS; item++) { | ||
44 | atomic_long_set(&zone->vm_numa_stat[item], 0); | ||
45 | for_each_online_cpu(cpu) | ||
46 | per_cpu_ptr(zone->pageset, cpu)->vm_numa_stat_diff[item] | ||
47 | = 0; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /* zero numa counters of all the populated zones */ | ||
52 | static void zero_zones_numa_counters(void) | ||
53 | { | ||
54 | struct zone *zone; | ||
55 | |||
56 | for_each_populated_zone(zone) | ||
57 | zero_zone_numa_counters(zone); | ||
58 | } | ||
59 | |||
60 | /* zero global numa counters */ | ||
61 | static void zero_global_numa_counters(void) | ||
62 | { | ||
63 | int item; | ||
64 | |||
65 | for (item = 0; item < NR_VM_NUMA_STAT_ITEMS; item++) | ||
66 | atomic_long_set(&vm_numa_stat[item], 0); | ||
67 | } | ||
68 | |||
69 | static void invalid_numa_statistics(void) | ||
70 | { | ||
71 | zero_zones_numa_counters(); | ||
72 | zero_global_numa_counters(); | ||
73 | } | ||
74 | |||
75 | static DEFINE_MUTEX(vm_numa_stat_lock); | ||
76 | |||
77 | int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, | ||
78 | void __user *buffer, size_t *length, loff_t *ppos) | ||
79 | { | ||
80 | int ret, oldval; | ||
81 | |||
82 | mutex_lock(&vm_numa_stat_lock); | ||
83 | if (write) | ||
84 | oldval = sysctl_vm_numa_stat; | ||
85 | ret = proc_dointvec_minmax(table, write, buffer, length, ppos); | ||
86 | if (ret || !write) | ||
87 | goto out; | ||
88 | |||
89 | if (oldval == sysctl_vm_numa_stat) | ||
90 | goto out; | ||
91 | else if (sysctl_vm_numa_stat == ENABLE_NUMA_STAT) { | ||
92 | static_branch_enable(&vm_numa_stat_key); | ||
93 | pr_info("enable numa statistics\n"); | ||
94 | } else { | ||
95 | static_branch_disable(&vm_numa_stat_key); | ||
96 | invalid_numa_statistics(); | ||
97 | pr_info("disable numa statistics, and clear numa counters\n"); | ||
98 | } | ||
99 | |||
100 | out: | ||
101 | mutex_unlock(&vm_numa_stat_lock); | ||
102 | return ret; | ||
103 | } | ||
104 | #endif | ||
105 | |||
35 | #ifdef CONFIG_VM_EVENT_COUNTERS | 106 | #ifdef CONFIG_VM_EVENT_COUNTERS |
36 | DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; | 107 | DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; |
37 | EXPORT_PER_CPU_SYMBOL(vm_event_states); | 108 | EXPORT_PER_CPU_SYMBOL(vm_event_states); |
@@ -1564,11 +1635,9 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, | |||
1564 | } | 1635 | } |
1565 | seq_printf(m, | 1636 | seq_printf(m, |
1566 | "\n node_unreclaimable: %u" | 1637 | "\n node_unreclaimable: %u" |
1567 | "\n start_pfn: %lu" | 1638 | "\n start_pfn: %lu", |
1568 | "\n node_inactive_ratio: %u", | ||
1569 | pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES, | 1639 | pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES, |
1570 | zone->zone_start_pfn, | 1640 | zone->zone_start_pfn); |
1571 | zone->zone_pgdat->inactive_ratio); | ||
1572 | seq_putc(m, '\n'); | 1641 | seq_putc(m, '\n'); |
1573 | } | 1642 | } |
1574 | 1643 | ||