Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_VMSTAT_H |
| 2 | #define _LINUX_VMSTAT_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include <linux/percpu.h> |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 6 | #include <linux/mmzone.h> |
Andrew Morton | f042e70 | 2011-05-26 16:25:24 -0700 | [diff] [blame] | 7 | #include <linux/vm_event_item.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 8 | #include <linux/atomic.h> |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 9 | |
Adrian Bunk | c748e13 | 2008-07-23 21:27:03 -0700 | [diff] [blame] | 10 | extern int sysctl_stat_interval; |
| 11 | |
Andrew Morton | 780a065 | 2007-02-10 01:44:41 -0800 | [diff] [blame] | 12 | #ifdef CONFIG_VM_EVENT_COUNTERS |
| 13 | /* |
| 14 | * Light weight per cpu counter implementation. |
| 15 | * |
| 16 | * Counters should only be incremented and no critical kernel component |
| 17 | * should rely on the counter values. |
| 18 | * |
| 19 | * Counters are handled completely inline. On many platforms the code |
| 20 | * generated will simply be the increment of a global address. |
| 21 | */ |
| 22 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 23 | struct vm_event_state { |
| 24 | unsigned long event[NR_VM_EVENT_ITEMS]; |
| 25 | }; |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 26 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 27 | DECLARE_PER_CPU(struct vm_event_state, vm_event_states); |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 28 | |
Christoph Lameter | 293b6a4 | 2014-04-07 15:39:43 -0700 | [diff] [blame] | 29 | /* |
| 30 | * vm counters are allowed to be racy. Use raw_cpu_ops to avoid the |
| 31 | * local_irq_disable overhead. |
| 32 | */ |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 33 | static inline void __count_vm_event(enum vm_event_item item) |
| 34 | { |
Christoph Lameter | 293b6a4 | 2014-04-07 15:39:43 -0700 | [diff] [blame] | 35 | raw_cpu_inc(vm_event_states.event[item]); |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 36 | } |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 37 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 38 | static inline void count_vm_event(enum vm_event_item item) |
| 39 | { |
Rusty Russell | dd17c8f | 2009-10-29 22:34:15 +0900 | [diff] [blame] | 40 | this_cpu_inc(vm_event_states.event[item]); |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 41 | } |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 42 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 43 | static inline void __count_vm_events(enum vm_event_item item, long delta) |
| 44 | { |
Christoph Lameter | 293b6a4 | 2014-04-07 15:39:43 -0700 | [diff] [blame] | 45 | raw_cpu_add(vm_event_states.event[item], delta); |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 46 | } |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 47 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 48 | static inline void count_vm_events(enum vm_event_item item, long delta) |
| 49 | { |
Rusty Russell | dd17c8f | 2009-10-29 22:34:15 +0900 | [diff] [blame] | 50 | this_cpu_add(vm_event_states.event[item], delta); |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 51 | } |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 52 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 53 | extern void all_vm_events(unsigned long *); |
Yijing Wang | f1cb087 | 2013-04-29 15:08:14 -0700 | [diff] [blame] | 54 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 55 | extern void vm_events_fold_cpu(int cpu); |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 56 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 57 | #else |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 58 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 59 | /* Disable counters */ |
Andrew Morton | 780a065 | 2007-02-10 01:44:41 -0800 | [diff] [blame] | 60 | static inline void count_vm_event(enum vm_event_item item) |
| 61 | { |
| 62 | } |
| 63 | static inline void count_vm_events(enum vm_event_item item, long delta) |
| 64 | { |
| 65 | } |
| 66 | static inline void __count_vm_event(enum vm_event_item item) |
| 67 | { |
| 68 | } |
| 69 | static inline void __count_vm_events(enum vm_event_item item, long delta) |
| 70 | { |
| 71 | } |
| 72 | static inline void all_vm_events(unsigned long *ret) |
| 73 | { |
| 74 | } |
| 75 | static inline void vm_events_fold_cpu(int cpu) |
| 76 | { |
| 77 | } |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 78 | |
Christoph Lameter | f8891e5 | 2006-06-30 01:55:45 -0700 | [diff] [blame] | 79 | #endif /* CONFIG_VM_EVENT_COUNTERS */ |
| 80 | |
Mel Gorman | 03c5a6e | 2012-11-02 14:52:48 +0000 | [diff] [blame] | 81 | #ifdef CONFIG_NUMA_BALANCING |
| 82 | #define count_vm_numa_event(x) count_vm_event(x) |
| 83 | #define count_vm_numa_events(x, y) count_vm_events(x, y) |
| 84 | #else |
| 85 | #define count_vm_numa_event(x) do {} while (0) |
Mel Gorman | 3c0ff46 | 2013-02-22 16:34:29 -0800 | [diff] [blame] | 86 | #define count_vm_numa_events(x, y) do { (void)(y); } while (0) |
Mel Gorman | 03c5a6e | 2012-11-02 14:52:48 +0000 | [diff] [blame] | 87 | #endif /* CONFIG_NUMA_BALANCING */ |
| 88 | |
Mel Gorman | ec65993 | 2014-01-21 14:33:16 -0800 | [diff] [blame] | 89 | #ifdef CONFIG_DEBUG_TLBFLUSH |
| 90 | #define count_vm_tlb_event(x) count_vm_event(x) |
| 91 | #define count_vm_tlb_events(x, y) count_vm_events(x, y) |
| 92 | #else |
| 93 | #define count_vm_tlb_event(x) do {} while (0) |
| 94 | #define count_vm_tlb_events(x, y) do { (void)(y); } while (0) |
| 95 | #endif |
| 96 | |
Davidlohr Bueso | 4f11514 | 2014-06-04 16:06:46 -0700 | [diff] [blame] | 97 | #ifdef CONFIG_DEBUG_VM_VMACACHE |
| 98 | #define count_vm_vmacache_event(x) count_vm_event(x) |
| 99 | #else |
| 100 | #define count_vm_vmacache_event(x) do {} while (0) |
| 101 | #endif |
| 102 | |
Mel Gorman | 16709d1 | 2016-07-28 15:46:56 -0700 | [diff] [blame] | 103 | #define __count_zid_vm_events(item, zid, delta) \ |
| 104 | __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta) |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 105 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 106 | /* |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 107 | * Zone and node-based page accounting with per cpu differentials. |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 108 | */ |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 109 | extern atomic_long_t vm_zone_stat[NR_VM_ZONE_STAT_ITEMS]; |
Kemi Wang | 3a321d2 | 2017-09-08 16:12:48 -0700 | [diff] [blame^] | 110 | extern atomic_long_t vm_numa_stat[NR_VM_NUMA_STAT_ITEMS]; |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 111 | extern atomic_long_t vm_node_stat[NR_VM_NODE_STAT_ITEMS]; |
Christoph Lameter | f6ac235 | 2006-06-30 01:55:32 -0700 | [diff] [blame] | 112 | |
Kemi Wang | 3a321d2 | 2017-09-08 16:12:48 -0700 | [diff] [blame^] | 113 | #ifdef CONFIG_NUMA |
| 114 | static inline void zone_numa_state_add(long x, struct zone *zone, |
| 115 | enum numa_stat_item item) |
| 116 | { |
| 117 | atomic_long_add(x, &zone->vm_numa_stat[item]); |
| 118 | atomic_long_add(x, &vm_numa_stat[item]); |
| 119 | } |
| 120 | |
| 121 | static inline unsigned long global_numa_state(enum numa_stat_item item) |
| 122 | { |
| 123 | long x = atomic_long_read(&vm_numa_stat[item]); |
| 124 | |
| 125 | return x; |
| 126 | } |
| 127 | |
| 128 | static inline unsigned long zone_numa_state(struct zone *zone, |
| 129 | enum numa_stat_item item) |
| 130 | { |
| 131 | long x = atomic_long_read(&zone->vm_numa_stat[item]); |
| 132 | |
| 133 | return x; |
| 134 | } |
| 135 | #endif /* CONFIG_NUMA */ |
| 136 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 137 | static inline void zone_page_state_add(long x, struct zone *zone, |
| 138 | enum zone_stat_item item) |
| 139 | { |
| 140 | atomic_long_add(x, &zone->vm_stat[item]); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 141 | atomic_long_add(x, &vm_zone_stat[item]); |
| 142 | } |
| 143 | |
| 144 | static inline void node_page_state_add(long x, struct pglist_data *pgdat, |
| 145 | enum node_stat_item item) |
| 146 | { |
| 147 | atomic_long_add(x, &pgdat->vm_stat[item]); |
| 148 | atomic_long_add(x, &vm_node_stat[item]); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Michal Hocko | c41f012 | 2017-09-06 16:23:36 -0700 | [diff] [blame] | 151 | static inline unsigned long global_zone_page_state(enum zone_stat_item item) |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 152 | { |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 153 | long x = atomic_long_read(&vm_zone_stat[item]); |
| 154 | #ifdef CONFIG_SMP |
| 155 | if (x < 0) |
| 156 | x = 0; |
| 157 | #endif |
| 158 | return x; |
| 159 | } |
| 160 | |
| 161 | static inline unsigned long global_node_page_state(enum node_stat_item item) |
| 162 | { |
| 163 | long x = atomic_long_read(&vm_node_stat[item]); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 164 | #ifdef CONFIG_SMP |
| 165 | if (x < 0) |
| 166 | x = 0; |
| 167 | #endif |
| 168 | return x; |
| 169 | } |
| 170 | |
| 171 | static inline unsigned long zone_page_state(struct zone *zone, |
| 172 | enum zone_stat_item item) |
| 173 | { |
| 174 | long x = atomic_long_read(&zone->vm_stat[item]); |
| 175 | #ifdef CONFIG_SMP |
| 176 | if (x < 0) |
| 177 | x = 0; |
| 178 | #endif |
| 179 | return x; |
| 180 | } |
| 181 | |
Christoph Lameter | aa45484 | 2010-09-09 16:38:17 -0700 | [diff] [blame] | 182 | /* |
| 183 | * More accurate version that also considers the currently pending |
| 184 | * deltas. For that we need to loop over all cpus to find the current |
| 185 | * deltas. There is no synchronization so the result cannot be |
| 186 | * exactly accurate either. |
| 187 | */ |
| 188 | static inline unsigned long zone_page_state_snapshot(struct zone *zone, |
| 189 | enum zone_stat_item item) |
| 190 | { |
| 191 | long x = atomic_long_read(&zone->vm_stat[item]); |
| 192 | |
| 193 | #ifdef CONFIG_SMP |
| 194 | int cpu; |
| 195 | for_each_online_cpu(cpu) |
| 196 | x += per_cpu_ptr(zone->pageset, cpu)->vm_stat_diff[item]; |
| 197 | |
| 198 | if (x < 0) |
| 199 | x = 0; |
| 200 | #endif |
| 201 | return x; |
| 202 | } |
| 203 | |
Mel Gorman | 599d0c9 | 2016-07-28 15:45:31 -0700 | [diff] [blame] | 204 | static inline unsigned long node_page_state_snapshot(pg_data_t *pgdat, |
| 205 | enum node_stat_item item) |
| 206 | { |
| 207 | long x = atomic_long_read(&pgdat->vm_stat[item]); |
| 208 | |
| 209 | #ifdef CONFIG_SMP |
| 210 | int cpu; |
| 211 | for_each_online_cpu(cpu) |
| 212 | x += per_cpu_ptr(pgdat->per_cpu_nodestats, cpu)->vm_node_stat_diff[item]; |
| 213 | |
| 214 | if (x < 0) |
| 215 | x = 0; |
| 216 | #endif |
| 217 | return x; |
| 218 | } |
| 219 | |
| 220 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 221 | #ifdef CONFIG_NUMA |
Kemi Wang | 3a321d2 | 2017-09-08 16:12:48 -0700 | [diff] [blame^] | 222 | extern void __inc_numa_state(struct zone *zone, enum numa_stat_item item); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 223 | extern unsigned long sum_zone_node_page_state(int node, |
Kemi Wang | 3a321d2 | 2017-09-08 16:12:48 -0700 | [diff] [blame^] | 224 | enum zone_stat_item item); |
| 225 | extern unsigned long sum_zone_numa_state(int node, enum numa_stat_item item); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 226 | extern unsigned long node_page_state(struct pglist_data *pgdat, |
| 227 | enum node_stat_item item); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 228 | #else |
Michal Hocko | c41f012 | 2017-09-06 16:23:36 -0700 | [diff] [blame] | 229 | #define sum_zone_node_page_state(node, item) global_zone_page_state(item) |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 230 | #define node_page_state(node, item) global_node_page_state(item) |
Christoph Lameter | ca889e6 | 2006-06-30 01:55:44 -0700 | [diff] [blame] | 231 | #endif /* CONFIG_NUMA */ |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 232 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 233 | #define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d) |
| 234 | #define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d)) |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 235 | #define add_node_page_state(__p, __i, __d) mod_node_page_state(__p, __i, __d) |
| 236 | #define sub_node_page_state(__p, __i, __d) mod_node_page_state(__p, __i, -(__d)) |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 237 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 238 | #ifdef CONFIG_SMP |
Heiko Carstens | 6cdb18a | 2015-12-29 14:54:32 -0800 | [diff] [blame] | 239 | void __mod_zone_page_state(struct zone *, enum zone_stat_item item, long); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 240 | void __inc_zone_page_state(struct page *, enum zone_stat_item); |
| 241 | void __dec_zone_page_state(struct page *, enum zone_stat_item); |
| 242 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 243 | void __mod_node_page_state(struct pglist_data *, enum node_stat_item item, long); |
| 244 | void __inc_node_page_state(struct page *, enum node_stat_item); |
| 245 | void __dec_node_page_state(struct page *, enum node_stat_item); |
| 246 | |
Heiko Carstens | 6cdb18a | 2015-12-29 14:54:32 -0800 | [diff] [blame] | 247 | void mod_zone_page_state(struct zone *, enum zone_stat_item, long); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 248 | void inc_zone_page_state(struct page *, enum zone_stat_item); |
| 249 | void dec_zone_page_state(struct page *, enum zone_stat_item); |
| 250 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 251 | void mod_node_page_state(struct pglist_data *, enum node_stat_item, long); |
| 252 | void inc_node_page_state(struct page *, enum node_stat_item); |
| 253 | void dec_node_page_state(struct page *, enum node_stat_item); |
| 254 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 255 | extern void inc_node_state(struct pglist_data *, enum node_stat_item); |
Christoph Lameter | c878538 | 2007-02-10 01:43:01 -0800 | [diff] [blame] | 256 | extern void __inc_zone_state(struct zone *, enum zone_stat_item); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 257 | extern void __inc_node_state(struct pglist_data *, enum node_stat_item); |
Christoph Lameter | c878538 | 2007-02-10 01:43:01 -0800 | [diff] [blame] | 258 | extern void dec_zone_state(struct zone *, enum zone_stat_item); |
| 259 | extern void __dec_zone_state(struct zone *, enum zone_stat_item); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 260 | extern void __dec_node_state(struct pglist_data *, enum node_stat_item); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 261 | |
Christoph Lameter | 0eb77e9 | 2016-01-14 15:21:40 -0800 | [diff] [blame] | 262 | void quiet_vmstat(void); |
Christoph Lameter | 2bb921e | 2013-09-11 14:21:30 -0700 | [diff] [blame] | 263 | void cpu_vm_stats_fold(int cpu); |
KOSAKI Motohiro | a6cccdc | 2011-05-24 17:11:33 -0700 | [diff] [blame] | 264 | void refresh_zone_stat_thresholds(void); |
Mel Gorman | b44129b | 2011-01-13 15:45:43 -0800 | [diff] [blame] | 265 | |
Hugh Dickins | 52b6f46 | 2016-05-19 17:12:50 -0700 | [diff] [blame] | 266 | struct ctl_table; |
| 267 | int vmstat_refresh(struct ctl_table *, int write, |
| 268 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| 269 | |
Minchan Kim | 5a88381 | 2012-10-08 16:33:39 -0700 | [diff] [blame] | 270 | void drain_zonestat(struct zone *zone, struct per_cpu_pageset *); |
| 271 | |
Mel Gorman | b44129b | 2011-01-13 15:45:43 -0800 | [diff] [blame] | 272 | int calculate_pressure_threshold(struct zone *zone); |
| 273 | int calculate_normal_threshold(struct zone *zone); |
| 274 | void set_pgdat_percpu_threshold(pg_data_t *pgdat, |
| 275 | int (*calculate_pressure)(struct zone *)); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 276 | #else /* CONFIG_SMP */ |
| 277 | |
| 278 | /* |
| 279 | * We do not maintain differentials in a single processor configuration. |
| 280 | * The functions directly modify the zone and global counters. |
| 281 | */ |
| 282 | static inline void __mod_zone_page_state(struct zone *zone, |
Heiko Carstens | 6cdb18a | 2015-12-29 14:54:32 -0800 | [diff] [blame] | 283 | enum zone_stat_item item, long delta) |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 284 | { |
| 285 | zone_page_state_add(delta, zone, item); |
| 286 | } |
| 287 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 288 | static inline void __mod_node_page_state(struct pglist_data *pgdat, |
| 289 | enum node_stat_item item, int delta) |
| 290 | { |
| 291 | node_page_state_add(delta, pgdat, item); |
| 292 | } |
| 293 | |
Christoph Lameter | 7f4599e | 2006-07-10 04:44:30 -0700 | [diff] [blame] | 294 | static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item) |
| 295 | { |
| 296 | atomic_long_inc(&zone->vm_stat[item]); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 297 | atomic_long_inc(&vm_zone_stat[item]); |
| 298 | } |
| 299 | |
| 300 | static inline void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item) |
| 301 | { |
| 302 | atomic_long_inc(&pgdat->vm_stat[item]); |
| 303 | atomic_long_inc(&vm_node_stat[item]); |
Christoph Lameter | 7f4599e | 2006-07-10 04:44:30 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Christoph Lameter | c878538 | 2007-02-10 01:43:01 -0800 | [diff] [blame] | 306 | static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item) |
| 307 | { |
| 308 | atomic_long_dec(&zone->vm_stat[item]); |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 309 | atomic_long_dec(&vm_zone_stat[item]); |
| 310 | } |
| 311 | |
| 312 | static inline void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item) |
| 313 | { |
| 314 | atomic_long_dec(&pgdat->vm_stat[item]); |
| 315 | atomic_long_dec(&vm_node_stat[item]); |
Christoph Lameter | c878538 | 2007-02-10 01:43:01 -0800 | [diff] [blame] | 316 | } |
| 317 | |
Johannes Weiner | 6a3ed21 | 2014-04-03 14:47:34 -0700 | [diff] [blame] | 318 | static inline void __inc_zone_page_state(struct page *page, |
| 319 | enum zone_stat_item item) |
| 320 | { |
| 321 | __inc_zone_state(page_zone(page), item); |
| 322 | } |
| 323 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 324 | static inline void __inc_node_page_state(struct page *page, |
| 325 | enum node_stat_item item) |
| 326 | { |
| 327 | __inc_node_state(page_pgdat(page), item); |
| 328 | } |
| 329 | |
| 330 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 331 | static inline void __dec_zone_page_state(struct page *page, |
| 332 | enum zone_stat_item item) |
| 333 | { |
Uwe Kleine-König | 57ce36f | 2008-02-25 16:45:03 +0100 | [diff] [blame] | 334 | __dec_zone_state(page_zone(page), item); |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 337 | static inline void __dec_node_page_state(struct page *page, |
| 338 | enum node_stat_item item) |
| 339 | { |
| 340 | __dec_node_state(page_pgdat(page), item); |
| 341 | } |
| 342 | |
| 343 | |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 344 | /* |
| 345 | * We only use atomic operations to update counters. So there is no need to |
| 346 | * disable interrupts. |
| 347 | */ |
| 348 | #define inc_zone_page_state __inc_zone_page_state |
| 349 | #define dec_zone_page_state __dec_zone_page_state |
| 350 | #define mod_zone_page_state __mod_zone_page_state |
| 351 | |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 352 | #define inc_node_page_state __inc_node_page_state |
| 353 | #define dec_node_page_state __dec_node_page_state |
| 354 | #define mod_node_page_state __mod_node_page_state |
| 355 | |
Johannes Weiner | 6a3ed21 | 2014-04-03 14:47:34 -0700 | [diff] [blame] | 356 | #define inc_zone_state __inc_zone_state |
Mel Gorman | 75ef718 | 2016-07-28 15:45:24 -0700 | [diff] [blame] | 357 | #define inc_node_state __inc_node_state |
Johannes Weiner | 6a3ed21 | 2014-04-03 14:47:34 -0700 | [diff] [blame] | 358 | #define dec_zone_state __dec_zone_state |
| 359 | |
Mel Gorman | b44129b | 2011-01-13 15:45:43 -0800 | [diff] [blame] | 360 | #define set_pgdat_percpu_threshold(pgdat, callback) { } |
Mel Gorman | 88f5acf | 2011-01-13 15:45:41 -0800 | [diff] [blame] | 361 | |
KOSAKI Motohiro | a6cccdc | 2011-05-24 17:11:33 -0700 | [diff] [blame] | 362 | static inline void refresh_zone_stat_thresholds(void) { } |
Christoph Lameter | 2bb921e | 2013-09-11 14:21:30 -0700 | [diff] [blame] | 363 | static inline void cpu_vm_stats_fold(int cpu) { } |
Christoph Lameter | 0eb77e9 | 2016-01-14 15:21:40 -0800 | [diff] [blame] | 364 | static inline void quiet_vmstat(void) { } |
KOSAKI Motohiro | a6cccdc | 2011-05-24 17:11:33 -0700 | [diff] [blame] | 365 | |
Minchan Kim | 5a88381 | 2012-10-08 16:33:39 -0700 | [diff] [blame] | 366 | static inline void drain_zonestat(struct zone *zone, |
| 367 | struct per_cpu_pageset *pset) { } |
KOSAKI Motohiro | fa25c50 | 2011-05-24 17:11:28 -0700 | [diff] [blame] | 368 | #endif /* CONFIG_SMP */ |
| 369 | |
Bartlomiej Zolnierkiewicz | d1ce749 | 2012-10-08 16:32:02 -0700 | [diff] [blame] | 370 | static inline void __mod_zone_freepage_state(struct zone *zone, int nr_pages, |
| 371 | int migratetype) |
| 372 | { |
| 373 | __mod_zone_page_state(zone, NR_FREE_PAGES, nr_pages); |
| 374 | if (is_migrate_cma(migratetype)) |
| 375 | __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, nr_pages); |
| 376 | } |
| 377 | |
KOSAKI Motohiro | fa25c50 | 2011-05-24 17:11:28 -0700 | [diff] [blame] | 378 | extern const char * const vmstat_text[]; |
Christoph Lameter | 2244b95 | 2006-06-30 01:55:33 -0700 | [diff] [blame] | 379 | |
| 380 | #endif /* _LINUX_VMSTAT_H */ |