projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'for-3.2' of git://linux-nfs.org/~bfields/linux
[firefly-linux-kernel-4.4.55.git]
/
lib
/
percpu_counter.c
diff --git
a/lib/percpu_counter.c
b/lib/percpu_counter.c
index 28f2c33c6b537ac07f5d2692fe08b0d48a8dae91..f8a3f1a829b8a9d767bed39c5138c7015380196b 100644
(file)
--- a/
lib/percpu_counter.c
+++ b/
lib/percpu_counter.c
@@
-10,8
+10,10
@@
#include <linux/module.h>
#include <linux/debugobjects.h>
#include <linux/module.h>
#include <linux/debugobjects.h>
+#ifdef CONFIG_HOTPLUG_CPU
static LIST_HEAD(percpu_counters);
static DEFINE_MUTEX(percpu_counters_lock);
static LIST_HEAD(percpu_counters);
static DEFINE_MUTEX(percpu_counters_lock);
+#endif
#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
@@
-59,13
+61,13
@@
void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
{
int cpu;
{
int cpu;
- spin_lock(&fbc->lock);
+
raw_
spin_lock(&fbc->lock);
for_each_possible_cpu(cpu) {
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
*pcount = 0;
}
fbc->count = amount;
for_each_possible_cpu(cpu) {
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
*pcount = 0;
}
fbc->count = amount;
- spin_unlock(&fbc->lock);
+
raw_
spin_unlock(&fbc->lock);
}
EXPORT_SYMBOL(percpu_counter_set);
}
EXPORT_SYMBOL(percpu_counter_set);
@@
-76,10
+78,10
@@
void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
preempt_disable();
count = __this_cpu_read(*fbc->counters) + amount;
if (count >= batch || count <= -batch) {
preempt_disable();
count = __this_cpu_read(*fbc->counters) + amount;
if (count >= batch || count <= -batch) {
- spin_lock(&fbc->lock);
+
raw_
spin_lock(&fbc->lock);
fbc->count += count;
__this_cpu_write(*fbc->counters, 0);
fbc->count += count;
__this_cpu_write(*fbc->counters, 0);
- spin_unlock(&fbc->lock);
+
raw_
spin_unlock(&fbc->lock);
} else {
__this_cpu_write(*fbc->counters, count);
}
} else {
__this_cpu_write(*fbc->counters, count);
}
@@
-96,13
+98,13
@@
s64 __percpu_counter_sum(struct percpu_counter *fbc)
s64 ret;
int cpu;
s64 ret;
int cpu;
- spin_lock(&fbc->lock);
+
raw_
spin_lock(&fbc->lock);
ret = fbc->count;
for_each_online_cpu(cpu) {
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
ret += *pcount;
}
ret = fbc->count;
for_each_online_cpu(cpu) {
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
ret += *pcount;
}
- spin_unlock(&fbc->lock);
+
raw_
spin_unlock(&fbc->lock);
return ret;
}
EXPORT_SYMBOL(__percpu_counter_sum);
return ret;
}
EXPORT_SYMBOL(__percpu_counter_sum);
@@
-110,7
+112,7
@@
EXPORT_SYMBOL(__percpu_counter_sum);
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
struct lock_class_key *key)
{
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
struct lock_class_key *key)
{
- spin_lock_init(&fbc->lock);
+
raw_
spin_lock_init(&fbc->lock);
lockdep_set_class(&fbc->lock, key);
fbc->count = amount;
fbc->counters = alloc_percpu(s32);
lockdep_set_class(&fbc->lock, key);
fbc->count = amount;
fbc->counters = alloc_percpu(s32);
@@
-173,11
+175,11
@@
static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
s32 *pcount;
unsigned long flags;
s32 *pcount;
unsigned long flags;
- spin_lock_irqsave(&fbc->lock, flags);
+
raw_
spin_lock_irqsave(&fbc->lock, flags);
pcount = per_cpu_ptr(fbc->counters, cpu);
fbc->count += *pcount;
*pcount = 0;
pcount = per_cpu_ptr(fbc->counters, cpu);
fbc->count += *pcount;
*pcount = 0;
- spin_unlock_irqrestore(&fbc->lock, flags);
+
raw_
spin_unlock_irqrestore(&fbc->lock, flags);
}
mutex_unlock(&percpu_counters_lock);
#endif
}
mutex_unlock(&percpu_counters_lock);
#endif