From dc62a30e274d003a4d08fb888f1520add4b21373 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 16 Oct 2007 23:25:46 -0700 Subject: lib: percpu_counter_init_irq provide a way to tell lockdep about percpu_counters that are supposed to be used from irq safe contexts. Signed-off-by: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/percpu_counter.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/percpu_counter.c') diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index 3a59d84b2d1e..9659eabffc31 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c @@ -68,6 +68,8 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc) } EXPORT_SYMBOL(__percpu_counter_sum); +static struct lock_class_key percpu_counter_irqsafe; + int percpu_counter_init(struct percpu_counter *fbc, s64 amount) { spin_lock_init(&fbc->lock); @@ -84,6 +86,16 @@ int percpu_counter_init(struct percpu_counter *fbc, s64 amount) } EXPORT_SYMBOL(percpu_counter_init); +int percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount) +{ + int err; + + err = percpu_counter_init(fbc, amount); + if (!err) + lockdep_set_class(&fbc->lock, &percpu_counter_irqsafe); + return err; +} + void percpu_counter_destroy(struct percpu_counter *fbc) { if (!fbc->counters) -- cgit v1.2.3