provide a way to init percpu_counters that are supposed to be used from irq safe contexts. Signed-off-by: Peter Zijlstra --- include/linux/percpu_counter.h | 4 ++++ lib/percpu_counter.c | 8 ++++++++ 2 files changed, 12 insertions(+) Index: linux-2.6/include/linux/percpu_counter.h =================================================================== --- linux-2.6.orig/include/linux/percpu_counter.h +++ linux-2.6/include/linux/percpu_counter.h @@ -31,6 +31,8 @@ struct percpu_counter { #endif void percpu_counter_init(struct percpu_counter *fbc, s64 amount); +void percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount); + void percpu_counter_destroy(struct percpu_counter *fbc); void percpu_counter_set(struct percpu_counter *fbc, s64 amount); void __percpu_counter_mod(struct percpu_counter *fbc, s32 amount, s32 batch); @@ -89,6 +91,8 @@ static inline void percpu_counter_init(s fbc->count = amount; } +#define percpu_counter_init_irq percpu_counter_init + static inline void percpu_counter_destroy(struct percpu_counter *fbc) { } Index: linux-2.6/lib/percpu_counter.c =================================================================== --- linux-2.6.orig/lib/percpu_counter.c +++ linux-2.6/lib/percpu_counter.c @@ -87,6 +87,8 @@ s64 __percpu_counter_sum(struct percpu_c } EXPORT_SYMBOL(__percpu_counter_sum); +static struct lock_class_key percpu_counter_irqsafe; + void percpu_counter_init(struct percpu_counter *fbc, s64 amount) { spin_lock_init(&fbc->lock); @@ -100,6 +102,12 @@ void percpu_counter_init(struct percpu_c } EXPORT_SYMBOL(percpu_counter_init); +void percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount) +{ + percpu_counter_init(fbc, amount); + lockdep_set_class(&fbc->lock, &percpu_counter_irqsafe); +} + void percpu_counter_destroy(struct percpu_counter *fbc) { free_percpu(fbc->counters); -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/