mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
locking, percpu_counter: Annotate ::lock as raw
The percpu_counter::lock can be taken in atomic context and therefore cannot be preempted on -rt - annotate it. In mainline this change documents the low level nature of the lock - otherwise there's no functional difference. Lockdep and Sparse checking will work as usual. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
ec484608c5
commit
f032a45081
2 changed files with 10 additions and 10 deletions
|
@ -16,7 +16,7 @@
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
|
||||||
struct percpu_counter {
|
struct percpu_counter {
|
||||||
spinlock_t lock;
|
raw_spinlock_t lock;
|
||||||
s64 count;
|
s64 count;
|
||||||
#ifdef CONFIG_HOTPLUG_CPU
|
#ifdef CONFIG_HOTPLUG_CPU
|
||||||
struct list_head list; /* All percpu_counters are on a list */
|
struct list_head list; /* All percpu_counters are on a list */
|
||||||
|
|
|
@ -59,13 +59,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) {
|
for_each_possible_cpu(cpu) {
|
||||||
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
|
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
|
||||||
*pcount = 0;
|
*pcount = 0;
|
||||||
}
|
}
|
||||||
fbc->count = amount;
|
fbc->count = amount;
|
||||||
spin_unlock(&fbc->lock);
|
raw_spin_unlock(&fbc->lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(percpu_counter_set);
|
EXPORT_SYMBOL(percpu_counter_set);
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
|
||||||
preempt_disable();
|
preempt_disable();
|
||||||
count = __this_cpu_read(*fbc->counters) + amount;
|
count = __this_cpu_read(*fbc->counters) + amount;
|
||||||
if (count >= batch || count <= -batch) {
|
if (count >= batch || count <= -batch) {
|
||||||
spin_lock(&fbc->lock);
|
raw_spin_lock(&fbc->lock);
|
||||||
fbc->count += count;
|
fbc->count += count;
|
||||||
__this_cpu_write(*fbc->counters, 0);
|
__this_cpu_write(*fbc->counters, 0);
|
||||||
spin_unlock(&fbc->lock);
|
raw_spin_unlock(&fbc->lock);
|
||||||
} else {
|
} else {
|
||||||
__this_cpu_write(*fbc->counters, count);
|
__this_cpu_write(*fbc->counters, count);
|
||||||
}
|
}
|
||||||
|
@ -96,13 +96,13 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
|
||||||
s64 ret;
|
s64 ret;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
spin_lock(&fbc->lock);
|
raw_spin_lock(&fbc->lock);
|
||||||
ret = fbc->count;
|
ret = fbc->count;
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
|
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
|
||||||
ret += *pcount;
|
ret += *pcount;
|
||||||
}
|
}
|
||||||
spin_unlock(&fbc->lock);
|
raw_spin_unlock(&fbc->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__percpu_counter_sum);
|
EXPORT_SYMBOL(__percpu_counter_sum);
|
||||||
|
@ -110,7 +110,7 @@ EXPORT_SYMBOL(__percpu_counter_sum);
|
||||||
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
|
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
|
||||||
struct lock_class_key *key)
|
struct lock_class_key *key)
|
||||||
{
|
{
|
||||||
spin_lock_init(&fbc->lock);
|
raw_spin_lock_init(&fbc->lock);
|
||||||
lockdep_set_class(&fbc->lock, key);
|
lockdep_set_class(&fbc->lock, key);
|
||||||
fbc->count = amount;
|
fbc->count = amount;
|
||||||
fbc->counters = alloc_percpu(s32);
|
fbc->counters = alloc_percpu(s32);
|
||||||
|
@ -173,11 +173,11 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
|
||||||
s32 *pcount;
|
s32 *pcount;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&fbc->lock, flags);
|
raw_spin_lock_irqsave(&fbc->lock, flags);
|
||||||
pcount = per_cpu_ptr(fbc->counters, cpu);
|
pcount = per_cpu_ptr(fbc->counters, cpu);
|
||||||
fbc->count += *pcount;
|
fbc->count += *pcount;
|
||||||
*pcount = 0;
|
*pcount = 0;
|
||||||
spin_unlock_irqrestore(&fbc->lock, flags);
|
raw_spin_unlock_irqrestore(&fbc->lock, flags);
|
||||||
}
|
}
|
||||||
mutex_unlock(&percpu_counters_lock);
|
mutex_unlock(&percpu_counters_lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue