Commit fe00c037 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] uninline mod_page_state(offset, delta)

Introduces a __mod_page_state(offset, delta) function and converts
mod_page_state() to use it.

Unexports and staticizes page_states per cpu variable.

   text    data     bss     dec     hex filename
1818704  615884       0 2434588  25261c vmlinux-old
1817632  615884       0 2433516  2521ec vmlinux-new

1072 bytes. (Adds 64 bytes without CONFIG_SMP).
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e17b53b0
...@@ -133,23 +133,16 @@ struct page_state { ...@@ -133,23 +133,16 @@ struct page_state {
unsigned long pgrotated; /* pages rotated to tail of the LRU */ unsigned long pgrotated; /* pages rotated to tail of the LRU */
}; };
DECLARE_PER_CPU(struct page_state, page_states);
extern void get_page_state(struct page_state *ret); extern void get_page_state(struct page_state *ret);
extern void get_full_page_state(struct page_state *ret); extern void get_full_page_state(struct page_state *ret);
extern unsigned long __read_page_state(unsigned offset); extern unsigned long __read_page_state(unsigned offset);
extern void __mod_page_state(unsigned offset, unsigned long delta);
#define read_page_state(member) \ #define read_page_state(member) \
__read_page_state(offsetof(struct page_state, member)) __read_page_state(offsetof(struct page_state, member))
#define mod_page_state(member, delta) \ #define mod_page_state(member, delta) \
do { \ __mod_page_state(offsetof(struct page_state, member), (delta))
unsigned long flags; \
local_irq_save(flags); \
__get_cpu_var(page_states).member += (delta); \
local_irq_restore(flags); \
} while (0)
#define inc_page_state(member) mod_page_state(member, 1UL) #define inc_page_state(member) mod_page_state(member, 1UL)
#define dec_page_state(member) mod_page_state(member, 0UL - 1) #define dec_page_state(member) mod_page_state(member, 0UL - 1)
...@@ -158,15 +151,14 @@ extern unsigned long __read_page_state(unsigned offset); ...@@ -158,15 +151,14 @@ extern unsigned long __read_page_state(unsigned offset);
#define mod_page_state_zone(zone, member, delta) \ #define mod_page_state_zone(zone, member, delta) \
do { \ do { \
unsigned long flags; \ unsigned offset; \
local_irq_save(flags); \
if (is_highmem(zone)) \ if (is_highmem(zone)) \
__get_cpu_var(page_states).member##_high += (delta);\ offset = offsetof(struct page_state, member##_high); \
else if (is_normal(zone)) \ else if (is_normal(zone)) \
__get_cpu_var(page_states).member##_normal += (delta);\ offset = offsetof(struct page_state, member##_normal); \
else \ else \
__get_cpu_var(page_states).member##_dma += (delta);\ offset = offsetof(struct page_state, member##_dma); \
local_irq_restore(flags); \ __mod_page_state(offset, (delta)); \
} while (0) } while (0)
/* /*
......
...@@ -984,8 +984,7 @@ static void show_node(struct zone *zone) ...@@ -984,8 +984,7 @@ static void show_node(struct zone *zone)
* The result is unavoidably approximate - it can change * The result is unavoidably approximate - it can change
* during and after execution of this function. * during and after execution of this function.
*/ */
DEFINE_PER_CPU(struct page_state, page_states) = {0}; static DEFINE_PER_CPU(struct page_state, page_states) = {0};
EXPORT_PER_CPU_SYMBOL(page_states);
atomic_t nr_pagecache = ATOMIC_INIT(0); atomic_t nr_pagecache = ATOMIC_INIT(0);
EXPORT_SYMBOL(nr_pagecache); EXPORT_SYMBOL(nr_pagecache);
...@@ -1045,6 +1044,19 @@ unsigned long __read_page_state(unsigned offset) ...@@ -1045,6 +1044,19 @@ unsigned long __read_page_state(unsigned offset)
return ret; return ret;
} }
void __mod_page_state(unsigned offset, unsigned long delta)
{
unsigned long flags;
void* ptr;
local_irq_save(flags);
ptr = &__get_cpu_var(page_states);
*(unsigned long*)(ptr + offset) += delta;
local_irq_restore(flags);
}
EXPORT_SYMBOL(__mod_page_state);
void __get_zone_counts(unsigned long *active, unsigned long *inactive, void __get_zone_counts(unsigned long *active, unsigned long *inactive,
unsigned long *free, struct pglist_data *pgdat) unsigned long *free, struct pglist_data *pgdat)
{ {
......
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