diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-10-16 23:25:46 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 08:42:44 -0700 |
commit | dc62a30e274d003a4d08fb888f1520add4b21373 (patch) | |
tree | 15835cabc7b9fbc6b213be6f7c0fa5003e44fdb3 | |
parent | 833f4077bf7c2dcff6e31526e03ec2ad91c88581 (diff) | |
download | linux-dc62a30e274d003a4d08fb888f1520add4b21373.tar.gz linux-dc62a30e274d003a4d08fb888f1520add4b21373.tar.bz2 linux-dc62a30e274d003a4d08fb888f1520add4b21373.zip |
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 <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/percpu_counter.h | 3 | ||||
-rw-r--r-- | lib/percpu_counter.c | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index f7ecd38d7e9c..9007ccdfc112 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h @@ -31,6 +31,7 @@ struct percpu_counter { #endif int percpu_counter_init(struct percpu_counter *fbc, s64 amount); +int 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_add(struct percpu_counter *fbc, s64 amount, s32 batch); @@ -84,6 +85,8 @@ static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount) return 0; } +#define percpu_counter_init_irq percpu_counter_init + static inline void percpu_counter_destroy(struct percpu_counter *fbc) { } 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) |