]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] page accounting atomicity fix
authorAndrew Morton <akpm@digeo.com>
Fri, 1 Nov 2002 04:01:38 +0000 (20:01 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 1 Nov 2002 04:01:38 +0000 (20:01 -0800)
The global page accounting functions are currently using "+=" against a
ulong.  But this can happen at interrupt time as well, and "+=" is not
atomic against interrupt-time modification of the same word.

Change it to use local_irq_save()

include/linux/page-flags.h

index 282902bb9816f8fa655808d0d5e6cd91974e59e3..9b3496e2aac54890579ef3c47d91c2c0deee0308 100644 (file)
@@ -114,9 +114,10 @@ extern void get_full_page_state(struct page_state *ret);
 
 #define mod_page_state(member, delta)                                  \
        do {                                                            \
-               int cpu = get_cpu();                                    \
-               per_cpu(page_states, cpu).member += (delta);            \
-               put_cpu();                                              \
+               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)