Commit 0c7d503f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Implement read_page_state

struct page_state is large (148 bytes) and we put them on the stack in awkward
code paths (page reclaim...)

So implement a simple read_page_state() which can be used to pluck out a
single member from the all-cpus page_state accumulators.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 72a9defa
......@@ -139,6 +139,10 @@ DECLARE_PER_CPU(struct page_state, page_states);
extern void get_page_state(struct page_state *ret);
extern void get_full_page_state(struct page_state *ret);
extern unsigned long __read_page_state(unsigned offset);
#define read_page_state(member) \
__read_page_state(offsetof(struct page_state, member))
#define mod_page_state(member, delta) \
do { \
......
......@@ -988,6 +988,23 @@ void get_full_page_state(struct page_state *ret)
__get_page_state(ret, sizeof(*ret) / sizeof(unsigned long));
}
unsigned long __read_page_state(unsigned offset)
{
unsigned long ret = 0;
int cpu;
for (cpu = 0; cpu < NR_CPUS; cpu++) {
unsigned long in;
if (!cpu_possible(cpu))
continue;
in = (unsigned long)&per_cpu(page_states, cpu) + offset;
ret += *((unsigned long *)in);
}
return ret;
}
void get_zone_counts(unsigned long *active,
unsigned long *inactive, unsigned long *free)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment