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
51465146 const struct wq_pod_type *pt = wqattrs_pod_type(attrs);
51475147 int pod = pt->cpu_pod[cpu];
51485148
5149− /* does @pod have any online CPUs @attrs wants? */
5149+ /* calculate possible CPUs in @pod that @attrs wants */
51505150 cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask);
5151− cpumask_and(attrs->__pod_cpumask, attrs->__pod_cpumask, cpu_online_mask);
5152− if (cpu_going_down >= 0)
5153− cpumask_clear_cpu(cpu_going_down, attrs->__pod_cpumask);
5154−
5155− if (cpumask_empty(attrs->__pod_cpumask)) {
5151+ /* does @pod have any online CPUs @attrs wants? */
5152+ if (!cpumask_intersects(attrs->__pod_cpumask, wq_online_cpumask)) {
51565153 cpumask_copy(attrs->__pod_cpumask, attrs->cpumask);
51575154 return;
51585155 }
51595156
5160− /* yeap, return possible CPUs in @pod that @attrs wants */
5161− cpumask_and(attrs->__pod_cpumask, attrs->cpumask, pt->pod_cpus[pod]);
5162−
51635157 if (cpumask_empty(attrs->__pod_cpumask))
51645158 pr_warn_once("WARNING: workqueue cpumask: online intersect > "
51655159 "possible intersect\n");