Index: linux-2.6.16-lv/include/linux/percpu_counter.h =================================================================== --- linux-2.6.16-lv.orig/include/linux/percpu_counter.h 2006-03-27 15:47:03.000000000 +0200 +++ linux-2.6.16-lv/include/linux/percpu_counter.h 2006-03-27 15:47:14.000000000 +0200 @@ -16,8 +16,13 @@ struct percpu_counter { spinlock_t lock; +#ifdef CONFIG_LBD + long long count; + long long *counters; +#else long count; long *counters; +#endif }; #if NR_CPUS >= 16 @@ -30,7 +35,11 @@ static inline void percpu_counter_init(s { spin_lock_init(&fbc->lock); fbc->count = 0; +#ifdef CONFIG_LBD + fbc->counters = alloc_percpu(long long); +#else fbc->counters = alloc_percpu(long); +#endif } static inline void percpu_counter_destroy(struct percpu_counter *fbc) @@ -38,10 +47,17 @@ static inline void percpu_counter_destro free_percpu(fbc->counters); } +#ifdef CONFIG_LBD +void percpu_counter_mod(struct percpu_counter *fbc, long long amount); +long long percpu_counter_sum(struct percpu_counter *fbc); + +static inline long long percpu_counter_read(struct percpu_counter *fbc) +#else void percpu_counter_mod(struct percpu_counter *fbc, long amount); long percpu_counter_sum(struct percpu_counter *fbc); static inline long percpu_counter_read(struct percpu_counter *fbc) +#endif { return fbc->count; } @@ -50,9 +66,15 @@ static inline long percpu_counter_read(s * It is possible for the percpu_counter_read() to return a small negative * number for some counter which should never be negative. */ +#ifdef CONFIG_LBD +static inline long long percpu_counter_read_positive(struct percpu_counter *fbc) +{ + long long ret = fbc->count; +#else static inline long percpu_counter_read_positive(struct percpu_counter *fbc) { long ret = fbc->count; +#endif barrier(); /* Prevent reloads of fbc->count */ if (ret > 0) @@ -63,7 +85,11 @@ static inline long percpu_counter_read_p #else struct percpu_counter { +#ifdef CONFIG_LBD + long long count; +#else long count; +#endif }; static inline void percpu_counter_init(struct percpu_counter *fbc) @@ -76,24 +102,40 @@ static inline void percpu_counter_destro } static inline void +#ifdef CONFIG_LBD +percpu_counter_mod(struct percpu_counter *fbc, long long amount) +#else percpu_counter_mod(struct percpu_counter *fbc, long amount) +#endif { preempt_disable(); fbc->count += amount; preempt_enable(); } +#ifdef CONFIG_LBD +static inline long long percpu_counter_read(struct percpu_counter *fbc) +#else static inline long percpu_counter_read(struct percpu_counter *fbc) +#endif { return fbc->count; } +#ifdef CONFIG_LBD +static inline long long percpu_counter_read_positive(struct percpu_counter *fbc) +#else static inline long percpu_counter_read_positive(struct percpu_counter *fbc) +#endif { return fbc->count; } +#ifdef CONFIG_LBD +static inline long long percpu_counter_sum(struct percpu_counter *fbc) +#else static inline long percpu_counter_sum(struct percpu_counter *fbc) +#endif { return percpu_counter_read_positive(fbc); } Index: linux-2.6.16-lv/mm/swap.c =================================================================== --- linux-2.6.16-lv.orig/mm/swap.c 2006-03-27 15:47:03.000000000 +0200 +++ linux-2.6.16-lv/mm/swap.c 2006-03-27 15:47:14.000000000 +0200 @@ -479,10 +479,17 @@ static int cpu_swap_callback(struct noti #endif /* CONFIG_SMP */ #ifdef CONFIG_SMP +#ifdef CONFIG_LBD +void percpu_counter_mod(struct percpu_counter *fbc, long long amount) +{ + long long count; + long long *pcount; +#else void percpu_counter_mod(struct percpu_counter *fbc, long amount) { long count; long *pcount; +#endif int cpu = get_cpu(); pcount = per_cpu_ptr(fbc->counters, cpu); @@ -503,15 +510,26 @@ EXPORT_SYMBOL(percpu_counter_mod); * Add up all the per-cpu counts, return the result. This is a more accurate * but much slower version of percpu_counter_read_positive() */ +#ifdef CONFIG_LBD +long long percpu_counter_sum(struct percpu_counter *fbc) +{ + long long ret; +#else long percpu_counter_sum(struct percpu_counter *fbc) { long ret; +#endif int cpu; spin_lock(&fbc->lock); ret = fbc->count; for_each_cpu(cpu) { - long *pcount = per_cpu_ptr(fbc->counters, cpu); +#ifdef CONFIG_LBD + long long *pcount; +#else + long *pcount; +#endif + pcount = per_cpu_ptr(fbc->counters, cpu); ret += *pcount; } spin_unlock(&fbc->lock);