Skip to content

Commit d87aae2

Browse files
author
Al Viro
committed
switch the protection of percpu_counter list to spinlock
... making percpu_counter_destroy() non-blocking Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 4a55c10 commit d87aae2

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎lib/percpu_counter.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#ifdef CONFIG_HOTPLUG_CPU
1414
static LIST_HEAD(percpu_counters);
15-
static DEFINE_MUTEX(percpu_counters_lock);
15+
static DEFINE_SPINLOCK(percpu_counters_lock);
1616
#endif
1717

1818
#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
@@ -123,9 +123,9 @@ int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
123123

124124
#ifdef CONFIG_HOTPLUG_CPU
125125
INIT_LIST_HEAD(&fbc->list);
126-
mutex_lock(&percpu_counters_lock);
126+
spin_lock(&percpu_counters_lock);
127127
list_add(&fbc->list, &percpu_counters);
128-
mutex_unlock(&percpu_counters_lock);
128+
spin_unlock(&percpu_counters_lock);
129129
#endif
130130
return 0;
131131
}
@@ -139,9 +139,9 @@ void percpu_counter_destroy(struct percpu_counter *fbc)
139139
debug_percpu_counter_deactivate(fbc);
140140

141141
#ifdef CONFIG_HOTPLUG_CPU
142-
mutex_lock(&percpu_counters_lock);
142+
spin_lock(&percpu_counters_lock);
143143
list_del(&fbc->list);
144-
mutex_unlock(&percpu_counters_lock);
144+
spin_unlock(&percpu_counters_lock);
145145
#endif
146146
free_percpu(fbc->counters);
147147
fbc->counters = NULL;
@@ -170,7 +170,7 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
170170
return NOTIFY_OK;
171171

172172
cpu = (unsigned long)hcpu;
173-
mutex_lock(&percpu_counters_lock);
173+
spin_lock(&percpu_counters_lock);
174174
list_for_each_entry(fbc, &percpu_counters, list) {
175175
s32 *pcount;
176176
unsigned long flags;
@@ -181,7 +181,7 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
181181
*pcount = 0;
182182
raw_spin_unlock_irqrestore(&fbc->lock, flags);
183183
}
184-
mutex_unlock(&percpu_counters_lock);
184+
spin_unlock(&percpu_counters_lock);
185185
#endif
186186
return NOTIFY_OK;
187187
}

0 commit comments

Comments
 (0)