Commit fbb3d4c1 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Tejun Heo

workqueue: Simplify wq_calc_pod_cpumask() with wq_online_cpumask

Avoid relying on cpu_online_mask for wqattrs changes so that
cpus_read_lock() can be removed from apply_wqattrs_lock().

And with wq_online_cpumask, attrs->__pod_cpumask doesn't need to be
reused as a temporary storage to calculate if the pod have any online
CPUs @attrs wants since @cpu_going_down is not in the wq_online_cpumask.
Signed-off-by: default avatarLai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 8d84baf7
...@@ -5146,20 +5146,14 @@ static void wq_calc_pod_cpumask(struct workqueue_attrs *attrs, int cpu, ...@@ -5146,20 +5146,14 @@ static void wq_calc_pod_cpumask(struct workqueue_attrs *attrs, int cpu,
const struct wq_pod_type *pt = wqattrs_pod_type(attrs); const struct wq_pod_type *pt = wqattrs_pod_type(attrs);
int pod = pt->cpu_pod[cpu]; int pod = pt->cpu_pod[cpu];
/* does @pod have any online CPUs @attrs wants? */ /* calculate possible CPUs in @pod that @attrs wants */
cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask); cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask);
cpumask_and(attrs->__pod_cpumask, attrs->__pod_cpumask, cpu_online_mask); /* does @pod have any online CPUs @attrs wants? */
if (cpu_going_down >= 0) if (!cpumask_intersects(attrs->__pod_cpumask, wq_online_cpumask)) {
cpumask_clear_cpu(cpu_going_down, attrs->__pod_cpumask);
if (cpumask_empty(attrs->__pod_cpumask)) {
cpumask_copy(attrs->__pod_cpumask, attrs->cpumask); cpumask_copy(attrs->__pod_cpumask, attrs->cpumask);
return; return;
} }
/* yeap, return possible CPUs in @pod that @attrs wants */
cpumask_and(attrs->__pod_cpumask, attrs->cpumask, pt->pod_cpus[pod]);
if (cpumask_empty(attrs->__pod_cpumask)) if (cpumask_empty(attrs->__pod_cpumask))
pr_warn_once("WARNING: workqueue cpumask: online intersect > " pr_warn_once("WARNING: workqueue cpumask: online intersect > "
"possible intersect\n"); "possible intersect\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment