1 #ifndef _LINUX_VMSTAT_H
2 #define _LINUX_VMSTAT_H
4 #include <linux/types.h>
5 #include <linux/percpu.h>
7 #include <linux/mmzone.h>
8 #include <asm/atomic.h>
10 #ifdef CONFIG_VM_EVENT_COUNTERS
12 * Light weight per cpu counter implementation.
14 * Counters should only be incremented. You need to set EMBEDDED
15 * to disable VM_EVENT_COUNTERS. Things like procps (vmstat,
16 * top, etc) use /proc/vmstat and depend on these counters.
18 * Counters are handled completely inline. On many platforms the code
19 * generated will simply be the increment of a global address.
22 #ifdef CONFIG_ZONE_DMA
23 #define DMA_ZONE(xx) xx##_DMA,
28 #ifdef CONFIG_ZONE_DMA32
29 #define DMA32_ZONE(xx) xx##_DMA32,
31 #define DMA32_ZONE(xx)
35 #define HIGHMEM_ZONE(xx) , xx##_HIGH
37 #define HIGHMEM_ZONE(xx)
40 #define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx)
42 enum vm_event_item
{ PGPGIN
, PGPGOUT
, PSWPIN
, PSWPOUT
,
43 FOR_ALL_ZONES(PGALLOC
),
44 PGFREE
, PGACTIVATE
, PGDEACTIVATE
,
46 FOR_ALL_ZONES(PGREFILL
),
47 FOR_ALL_ZONES(PGSTEAL
),
48 FOR_ALL_ZONES(PGSCAN_KSWAPD
),
49 FOR_ALL_ZONES(PGSCAN_DIRECT
),
50 PGINODESTEAL
, SLABS_SCANNED
, KSWAPD_STEAL
, KSWAPD_INODESTEAL
,
51 PAGEOUTRUN
, ALLOCSTALL
, PGROTATED
,
55 struct vm_event_state
{
56 unsigned long event
[NR_VM_EVENT_ITEMS
];
59 DECLARE_PER_CPU(struct vm_event_state
, vm_event_states
);
61 static inline void __count_vm_event(enum vm_event_item item
)
63 __get_cpu_var(vm_event_states
).event
[item
]++;
66 static inline void count_vm_event(enum vm_event_item item
)
68 get_cpu_var(vm_event_states
).event
[item
]++;
72 static inline void __count_vm_events(enum vm_event_item item
, long delta
)
74 __get_cpu_var(vm_event_states
).event
[item
] += delta
;
77 static inline void count_vm_events(enum vm_event_item item
, long delta
)
79 get_cpu_var(vm_event_states
).event
[item
] += delta
;
83 extern void all_vm_events(unsigned long *);
85 extern void vm_events_fold_cpu(int cpu
);
87 static inline void vm_events_fold_cpu(int cpu
)
94 /* Disable counters */
95 #define get_cpu_vm_events(e) 0L
96 #define count_vm_event(e) do { } while (0)
97 #define count_vm_events(e,d) do { } while (0)
98 #define __count_vm_event(e) do { } while (0)
99 #define __count_vm_events(e,d) do { } while (0)
100 #define vm_events_fold_cpu(x) do { } while (0)
102 #endif /* CONFIG_VM_EVENT_COUNTERS */
104 #define __count_zone_vm_events(item, zone, delta) \
105 __count_vm_events(item##_NORMAL - ZONE_NORMAL + \
106 zone_idx(zone), delta)
109 * Zone based page accounting with per cpu differentials.
111 extern atomic_long_t vm_stat
[NR_VM_ZONE_STAT_ITEMS
];
113 static inline void zone_page_state_add(long x
, struct zone
*zone
,
114 enum zone_stat_item item
)
116 atomic_long_add(x
, &zone
->vm_stat
[item
]);
117 atomic_long_add(x
, &vm_stat
[item
]);
120 static inline unsigned long global_page_state(enum zone_stat_item item
)
122 long x
= atomic_long_read(&vm_stat
[item
]);
130 static inline unsigned long zone_page_state(struct zone
*zone
,
131 enum zone_stat_item item
)
133 long x
= atomic_long_read(&zone
->vm_stat
[item
]);
143 * Determine the per node value of a stat item. This function
144 * is called frequently in a NUMA machine, so try to be as
145 * frugal as possible.
147 static inline unsigned long node_page_state(int node
,
148 enum zone_stat_item item
)
150 struct zone
*zones
= NODE_DATA(node
)->node_zones
;
153 #ifdef CONFIG_ZONE_DMA
154 zone_page_state(&zones
[ZONE_DMA
], item
) +
156 #ifdef CONFIG_ZONE_DMA32
157 zone_page_state(&zones
[ZONE_DMA32
], item
) +
159 #ifdef CONFIG_HIGHMEM
160 zone_page_state(&zones
[ZONE_HIGHMEM
], item
) +
162 zone_page_state(&zones
[ZONE_NORMAL
], item
);
165 extern void zone_statistics(struct zonelist
*, struct zone
*);
169 #define node_page_state(node, item) global_page_state(item)
170 #define zone_statistics(_zl,_z) do { } while (0)
172 #endif /* CONFIG_NUMA */
174 #define __add_zone_page_state(__z, __i, __d) \
175 __mod_zone_page_state(__z, __i, __d)
176 #define __sub_zone_page_state(__z, __i, __d) \
177 __mod_zone_page_state(__z, __i,-(__d))
179 #define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d)
180 #define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d))
182 static inline void zap_zone_vm_stats(struct zone
*zone
)
184 memset(zone
->vm_stat
, 0, sizeof(zone
->vm_stat
));
187 extern void inc_zone_state(struct zone
*, enum zone_stat_item
);
190 void __mod_zone_page_state(struct zone
*, enum zone_stat_item item
, int);
191 void __inc_zone_page_state(struct page
*, enum zone_stat_item
);
192 void __dec_zone_page_state(struct page
*, enum zone_stat_item
);
194 void mod_zone_page_state(struct zone
*, enum zone_stat_item
, int);
195 void inc_zone_page_state(struct page
*, enum zone_stat_item
);
196 void dec_zone_page_state(struct page
*, enum zone_stat_item
);
198 extern void inc_zone_state(struct zone
*, enum zone_stat_item
);
199 extern void __inc_zone_state(struct zone
*, enum zone_stat_item
);
200 extern void dec_zone_state(struct zone
*, enum zone_stat_item
);
201 extern void __dec_zone_state(struct zone
*, enum zone_stat_item
);
203 void refresh_cpu_vm_stats(int);
204 void refresh_vm_stats(void);
206 #else /* CONFIG_SMP */
209 * We do not maintain differentials in a single processor configuration.
210 * The functions directly modify the zone and global counters.
212 static inline void __mod_zone_page_state(struct zone
*zone
,
213 enum zone_stat_item item
, int delta
)
215 zone_page_state_add(delta
, zone
, item
);
218 static inline void __inc_zone_state(struct zone
*zone
, enum zone_stat_item item
)
220 atomic_long_inc(&zone
->vm_stat
[item
]);
221 atomic_long_inc(&vm_stat
[item
]);
224 static inline void __inc_zone_page_state(struct page
*page
,
225 enum zone_stat_item item
)
227 __inc_zone_state(page_zone(page
), item
);
230 static inline void __dec_zone_state(struct zone
*zone
, enum zone_stat_item item
)
232 atomic_long_dec(&zone
->vm_stat
[item
]);
233 atomic_long_dec(&vm_stat
[item
]);
236 static inline void __dec_zone_page_state(struct page
*page
,
237 enum zone_stat_item item
)
239 atomic_long_dec(&page_zone(page
)->vm_stat
[item
]);
240 atomic_long_dec(&vm_stat
[item
]);
244 * We only use atomic operations to update counters. So there is no need to
245 * disable interrupts.
247 #define inc_zone_page_state __inc_zone_page_state
248 #define dec_zone_page_state __dec_zone_page_state
249 #define mod_zone_page_state __mod_zone_page_state
251 static inline void refresh_cpu_vm_stats(int cpu
) { }
252 static inline void refresh_vm_stats(void) { }
255 #endif /* _LINUX_VMSTAT_H */
This page took 0.047436 seconds and 5 git commands to generate.