aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/percpu_counter.h3
-rw-r--r--lib/percpu_counter.c12
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 {
31#endif 31#endif
32 32
33int percpu_counter_init(struct percpu_counter *fbc, s64 amount); 33int percpu_counter_init(struct percpu_counter *fbc, s64 amount);
34int percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount);
34void percpu_counter_destroy(struct percpu_counter *fbc); 35void percpu_counter_destroy(struct percpu_counter *fbc);
35void percpu_counter_set(struct percpu_counter *fbc, s64 amount); 36void percpu_counter_set(struct percpu_counter *fbc, s64 amount);
36void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch); 37void __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)
84 return 0; 85 return 0;
85} 86}
86 87
88#define percpu_counter_init_irq percpu_counter_init
89
87static inline void percpu_counter_destroy(struct percpu_counter *fbc) 90static inline void percpu_counter_destroy(struct percpu_counter *fbc)
88{ 91{
89} 92}
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)