History

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.

Lai Jiangshan committed 2 years ago

Commit fbb3d4c1 parent 8d84baf1 file · +3 −9Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+3−9
@@ -5146,20 +5146,14 @@ static void wq_calc_pod_cpumask(struct workqueue_attrs *attrs, int cpu, · 5145 unmodified lines
5146 const struct wq_pod_type *pt = wqattrs_pod_type(attrs);5146 const struct wq_pod_type *pt = wqattrs_pod_type(attrs);
5147 int pod = pt->cpu_pod[cpu];5147 int pod = pt->cpu_pod[cpu];
5148 5148
5149 /* does @pod have any online CPUs @attrs wants? */5149 /* calculate possible CPUs in @pod that @attrs wants */
5150 cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask);5150 cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask);
5151 cpumask_and(attrs->__pod_cpumask, attrs->__pod_cpumask, cpu_online_mask);5151 /* does @pod have any online CPUs @attrs wants? */
5152 if (cpu_going_down >= 0)5152 if (!cpumask_intersects(attrs->__pod_cpumask, wq_online_cpumask)) {
5153 cpumask_clear_cpu(cpu_going_down, attrs->__pod_cpumask);
5154
5155 if (cpumask_empty(attrs->__pod_cpumask)) {
5156 cpumask_copy(attrs->__pod_cpumask, attrs->cpumask);5153 cpumask_copy(attrs->__pod_cpumask, attrs->cpumask);
5157 return;5154 return;
5158 }5155 }
5159 5156
5160 /* yeap, return possible CPUs in @pod that @attrs wants */
5161 cpumask_and(attrs->__pod_cpumask, attrs->cpumask, pt->pod_cpus[pod]);
5162
5163 if (cpumask_empty(attrs->__pod_cpumask))5157 if (cpumask_empty(attrs->__pod_cpumask))
5164 pr_warn_once("WARNING: workqueue cpumask: online intersect > "5158 pr_warn_once("WARNING: workqueue cpumask: online intersect > "
5165 "possible intersect\n");5159 "possible intersect\n");