aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percpu_counter.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2007-10-17 02:25:46 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:44 -0400
commitdc62a30e274d003a4d08fb888f1520add4b21373 (patch)
tree15835cabc7b9fbc6b213be6f7c0fa5003e44fdb3 /lib/percpu_counter.c
parent833f4077bf7c2dcff6e31526e03ec2ad91c88581 (diff)
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>
Diffstat (limited to 'lib/percpu_counter.c')
-rw-r--r--lib/percpu_counter.c12
1 files changed, 12 insertions, 0 deletions
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)
68} 68}
69EXPORT_SYMBOL(__percpu_counter_sum); 69EXPORT_SYMBOL(__percpu_counter_sum);
70 70
71static struct lock_class_key percpu_counter_irqsafe;
72
71int percpu_counter_init(struct percpu_counter *fbc, s64 amount) 73int percpu_counter_init(struct percpu_counter *fbc, s64 amount)
72{ 74{
73 spin_lock_init(&fbc->lock); 75 spin_lock_init(&fbc->lock);
@@ -84,6 +86,16 @@ int percpu_counter_init(struct percpu_counter *fbc, s64 amount)
84} 86}
85EXPORT_SYMBOL(percpu_counter_init); 87EXPORT_SYMBOL(percpu_counter_init);
86 88
89int percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount)
90{
91 int err;
92
93 err = percpu_counter_init(fbc, amount);
94 if (!err)
95 lockdep_set_class(&fbc->lock, &percpu_counter_irqsafe);
96 return err;
97}
98
87void percpu_counter_destroy(struct percpu_counter *fbc) 99void percpu_counter_destroy(struct percpu_counter *fbc)
88{ 100{
89 if (!fbc->counters) 101 if (!fbc->counters)