ACPI: memory hotplug: remove useless message at boot time
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / vmstat.h
blob2d9b1b60798aca15f99c9fe46afe5587f1605b6e
1 #ifndef _LINUX_VMSTAT_H
2 #define _LINUX_VMSTAT_H
4 #include <linux/types.h>
5 #include <linux/percpu.h>
6 #include <linux/config.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 and no critical kernel component
15 * should rely on the counter values.
17 * Counters are handled completely inline. On many platforms the code
18 * generated will simply be the increment of a global address.
21 #define FOR_ALL_ZONES(x) x##_DMA, x##_DMA32, x##_NORMAL, x##_HIGH
23 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
24 FOR_ALL_ZONES(PGALLOC),
25 PGFREE, PGACTIVATE, PGDEACTIVATE,
26 PGFAULT, PGMAJFAULT,
27 FOR_ALL_ZONES(PGREFILL),
28 FOR_ALL_ZONES(PGSTEAL),
29 FOR_ALL_ZONES(PGSCAN_KSWAPD),
30 FOR_ALL_ZONES(PGSCAN_DIRECT),
31 PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
32 PAGEOUTRUN, ALLOCSTALL, PGROTATED,
33 NR_VM_EVENT_ITEMS
36 struct vm_event_state {
37 unsigned long event[NR_VM_EVENT_ITEMS];
40 DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
42 static inline void __count_vm_event(enum vm_event_item item)
44 __get_cpu_var(vm_event_states).event[item]++;
47 static inline void count_vm_event(enum vm_event_item item)
49 get_cpu_var(vm_event_states).event[item]++;
50 put_cpu();
53 static inline void __count_vm_events(enum vm_event_item item, long delta)
55 __get_cpu_var(vm_event_states).event[item] += delta;
58 static inline void count_vm_events(enum vm_event_item item, long delta)
60 get_cpu_var(vm_event_states).event[item] += delta;
61 put_cpu();
64 extern void all_vm_events(unsigned long *);
65 extern void vm_events_fold_cpu(int cpu);
67 #else
69 /* Disable counters */
70 #define get_cpu_vm_events(e) 0L
71 #define count_vm_event(e) do { } while (0)
72 #define count_vm_events(e,d) do { } while (0)
73 #define __count_vm_event(e) do { } while (0)
74 #define __count_vm_events(e,d) do { } while (0)
75 #define vm_events_fold_cpu(x) do { } while (0)
77 #endif /* CONFIG_VM_EVENT_COUNTERS */
79 #define __count_zone_vm_events(item, zone, delta) \
80 __count_vm_events(item##_DMA + zone_idx(zone), delta)
83 * Zone based page accounting with per cpu differentials.
85 extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
87 static inline void zone_page_state_add(long x, struct zone *zone,
88 enum zone_stat_item item)
90 atomic_long_add(x, &zone->vm_stat[item]);
91 atomic_long_add(x, &vm_stat[item]);
94 static inline unsigned long global_page_state(enum zone_stat_item item)
96 long x = atomic_long_read(&vm_stat[item]);
97 #ifdef CONFIG_SMP
98 if (x < 0)
99 x = 0;
100 #endif
101 return x;
104 static inline unsigned long zone_page_state(struct zone *zone,
105 enum zone_stat_item item)
107 long x = atomic_long_read(&zone->vm_stat[item]);
108 #ifdef CONFIG_SMP
109 if (x < 0)
110 x = 0;
111 #endif
112 return x;
115 #ifdef CONFIG_NUMA
117 * Determine the per node value of a stat item. This function
118 * is called frequently in a NUMA machine, so try to be as
119 * frugal as possible.
121 static inline unsigned long node_page_state(int node,
122 enum zone_stat_item item)
124 struct zone *zones = NODE_DATA(node)->node_zones;
126 return
127 #ifndef CONFIG_DMA_IS_NORMAL
128 #if !defined(CONFIG_DMA_IS_DMA32) && BITS_PER_LONG >= 64
129 zone_page_state(&zones[ZONE_DMA32], item) +
130 #endif
131 zone_page_state(&zones[ZONE_NORMAL], item) +
132 #endif
133 #ifdef CONFIG_HIGHMEM
134 zone_page_state(&zones[ZONE_HIGHMEM], item) +
135 #endif
136 zone_page_state(&zones[ZONE_DMA], item);
139 extern void zone_statistics(struct zonelist *, struct zone *);
141 #else
143 #define node_page_state(node, item) global_page_state(item)
144 #define zone_statistics(_zl,_z) do { } while (0)
146 #endif /* CONFIG_NUMA */
148 #define __add_zone_page_state(__z, __i, __d) \
149 __mod_zone_page_state(__z, __i, __d)
150 #define __sub_zone_page_state(__z, __i, __d) \
151 __mod_zone_page_state(__z, __i,-(__d))
153 #define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d)
154 #define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d))
156 static inline void zap_zone_vm_stats(struct zone *zone)
158 memset(zone->vm_stat, 0, sizeof(zone->vm_stat));
161 extern void inc_zone_state(struct zone *, enum zone_stat_item);
163 #ifdef CONFIG_SMP
164 void __mod_zone_page_state(struct zone *, enum zone_stat_item item, int);
165 void __inc_zone_page_state(struct page *, enum zone_stat_item);
166 void __dec_zone_page_state(struct page *, enum zone_stat_item);
168 void mod_zone_page_state(struct zone *, enum zone_stat_item, int);
169 void inc_zone_page_state(struct page *, enum zone_stat_item);
170 void dec_zone_page_state(struct page *, enum zone_stat_item);
172 extern void inc_zone_state(struct zone *, enum zone_stat_item);
174 void refresh_cpu_vm_stats(int);
175 void refresh_vm_stats(void);
177 #else /* CONFIG_SMP */
180 * We do not maintain differentials in a single processor configuration.
181 * The functions directly modify the zone and global counters.
183 static inline void __mod_zone_page_state(struct zone *zone,
184 enum zone_stat_item item, int delta)
186 zone_page_state_add(delta, zone, item);
189 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
191 atomic_long_inc(&zone->vm_stat[item]);
192 atomic_long_inc(&vm_stat[item]);
195 static inline void __inc_zone_page_state(struct page *page,
196 enum zone_stat_item item)
198 __inc_zone_state(page_zone(page), item);
201 static inline void __dec_zone_page_state(struct page *page,
202 enum zone_stat_item item)
204 atomic_long_dec(&page_zone(page)->vm_stat[item]);
205 atomic_long_dec(&vm_stat[item]);
209 * We only use atomic operations to update counters. So there is no need to
210 * disable interrupts.
212 #define inc_zone_page_state __inc_zone_page_state
213 #define dec_zone_page_state __dec_zone_page_state
214 #define mod_zone_page_state __mod_zone_page_state
216 static inline void refresh_cpu_vm_stats(int cpu) { }
217 static inline void refresh_vm_stats(void) { }
218 #endif
220 #endif /* _LINUX_VMSTAT_H */