From afce7191a73f632a138f5511cbe245d39c526331 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 29 Oct 2002 23:32:18 -0800 Subject: [PATCH] percpu: convert global page accounting Convert global page state accounting to use per-cpu storage (I think this code remains a little buggy, btw. Note how I do per_cpu(page_states, cpu).member += (delta); This gets done at interrupt time and hence is assuming that the "+=" operation on a ulong is atomic wrt interrupts on all architectures. How do we feel about that assumption?) --- include/linux/gfp.h | 2 ++ include/linux/page-flags.h | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 939f16910233..c340b447a963 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -86,4 +86,6 @@ extern void FASTCALL(free_pages(unsigned long addr, unsigned int order)); #define __free_page(page) __free_pages((page), 0) #define free_page(addr) free_pages((addr),0) +void page_alloc_init(void); + #endif /* __LINUX_GFP_H */ diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 5c770f49787a..282902bb9816 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -5,6 +5,8 @@ #ifndef PAGE_FLAGS_H #define PAGE_FLAGS_H +#include + /* * Various page->flags bits: * @@ -73,7 +75,7 @@ * Global page accounting. One instance per CPU. Only unsigned longs are * allowed. */ -extern struct page_state { +struct page_state { unsigned long nr_dirty; unsigned long nr_writeback; unsigned long nr_pagecache; @@ -103,7 +105,9 @@ extern struct page_state { unsigned long kswapd_steal; unsigned long pageoutrun; unsigned long allocstall; -} ____cacheline_aligned_in_smp page_states[NR_CPUS]; +}; + +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); @@ -111,7 +115,7 @@ extern void get_full_page_state(struct page_state *ret); #define mod_page_state(member, delta) \ do { \ int cpu = get_cpu(); \ - page_states[cpu].member += (delta); \ + per_cpu(page_states, cpu).member += (delta); \ put_cpu(); \ } while (0) -- cgit v1.2.3