Skip to content

Commit ffd8bea

Browse files
Sebastian Andrzej Siewiorhtejun
authored andcommitted
workqueue: Replace deprecated CPU-hotplug functions.
The functions get_online_cpus() and put_online_cpus() have been deprecated during the CPU hotplug rework. They map directly to cpus_read_lock() and cpus_read_unlock(). Replace deprecated CPU-hotplug functions with the official version. The behavior remains unchanged. Cc: Tejun Heo <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent e441b56 commit ffd8bea

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

kernel/workqueue.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,7 +3292,7 @@ int schedule_on_each_cpu(work_func_t func)
32923292
if (!works)
32933293
return -ENOMEM;
32943294

3295-
get_online_cpus();
3295+
cpus_read_lock();
32963296

32973297
for_each_online_cpu(cpu) {
32983298
struct work_struct *work = per_cpu_ptr(works, cpu);
@@ -3304,7 +3304,7 @@ int schedule_on_each_cpu(work_func_t func)
33043304
for_each_online_cpu(cpu)
33053305
flush_work(per_cpu_ptr(works, cpu));
33063306

3307-
put_online_cpus();
3307+
cpus_read_unlock();
33083308
free_percpu(works);
33093309
return 0;
33103310
}
@@ -4015,14 +4015,14 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx)
40154015
static void apply_wqattrs_lock(void)
40164016
{
40174017
/* CPUs should stay stable across pwq creations and installations */
4018-
get_online_cpus();
4018+
cpus_read_lock();
40194019
mutex_lock(&wq_pool_mutex);
40204020
}
40214021

40224022
static void apply_wqattrs_unlock(void)
40234023
{
40244024
mutex_unlock(&wq_pool_mutex);
4025-
put_online_cpus();
4025+
cpus_read_unlock();
40264026
}
40274027

40284028
static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
@@ -4067,7 +4067,7 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
40674067
*
40684068
* Performs GFP_KERNEL allocations.
40694069
*
4070-
* Assumes caller has CPU hotplug read exclusion, i.e. get_online_cpus().
4070+
* Assumes caller has CPU hotplug read exclusion, i.e. cpus_read_lock().
40714071
*
40724072
* Return: 0 on success and -errno on failure.
40734073
*/
@@ -4195,7 +4195,7 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
41954195
return 0;
41964196
}
41974197

4198-
get_online_cpus();
4198+
cpus_read_lock();
41994199
if (wq->flags & __WQ_ORDERED) {
42004200
ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]);
42014201
/* there should only be single pwq for ordering guarantee */
@@ -4205,7 +4205,7 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
42054205
} else {
42064206
ret = apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]);
42074207
}
4208-
put_online_cpus();
4208+
cpus_read_unlock();
42094209

42104210
return ret;
42114211
}
@@ -5167,10 +5167,10 @@ long work_on_cpu_safe(int cpu, long (*fn)(void *), void *arg)
51675167
{
51685168
long ret = -ENODEV;
51695169

5170-
get_online_cpus();
5170+
cpus_read_lock();
51715171
if (cpu_online(cpu))
51725172
ret = work_on_cpu(cpu, fn, arg);
5173-
put_online_cpus();
5173+
cpus_read_unlock();
51745174
return ret;
51755175
}
51765176
EXPORT_SYMBOL_GPL(work_on_cpu_safe);
@@ -5442,7 +5442,7 @@ static ssize_t wq_pool_ids_show(struct device *dev,
54425442
const char *delim = "";
54435443
int node, written = 0;
54445444

5445-
get_online_cpus();
5445+
cpus_read_lock();
54465446
rcu_read_lock();
54475447
for_each_node(node) {
54485448
written += scnprintf(buf + written, PAGE_SIZE - written,
@@ -5452,7 +5452,7 @@ static ssize_t wq_pool_ids_show(struct device *dev,
54525452
}
54535453
written += scnprintf(buf + written, PAGE_SIZE - written, "\n");
54545454
rcu_read_unlock();
5455-
put_online_cpus();
5455+
cpus_read_unlock();
54565456

54575457
return written;
54585458
}

0 commit comments

Comments
 (0)