Message ID | 20190725212505.15055-4-daniel.m.jordan@oracle.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Herbert Xu |
Headers | show |
Series | padata: use unbound workqueues for parallel jobs | expand |
On Thu, Jul 25, 2019 at 05:24:59PM -0400, Daniel Jordan wrote: > Change the calling convention for apply_workqueue_attrs to require CPU > hotplug read exclusion. > > Avoids lockdep complaints about nested calls to get_online_cpus in a > future patch where padata calls apply_workqueue_attrs when changing > other CPU-hotplug-sensitive data structures with the CPU read lock > already held. > > Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com> Acked-by: Tejun Heo <tj@kernel.org> Please feel free to route with the rest of the patchset. Thanks.
On Mon, Jul 29, 2019 at 12:47:21PM -0700, Tejun Heo wrote: > On Thu, Jul 25, 2019 at 05:24:59PM -0400, Daniel Jordan wrote: > > Change the calling convention for apply_workqueue_attrs to require CPU > > hotplug read exclusion. > > > > Avoids lockdep complaints about nested calls to get_online_cpus in a > > future patch where padata calls apply_workqueue_attrs when changing > > other CPU-hotplug-sensitive data structures with the CPU read lock > > already held. > > > > Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com> > > Acked-by: Tejun Heo <tj@kernel.org> Thanks, Tejun!
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f53705ff3ff1..bc2e09a8ea61 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4030,6 +4030,8 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, * * Performs GFP_KERNEL allocations. * + * Assumes caller has CPU hotplug read exclusion, i.e. get_online_cpus(). + * * Return: 0 on success and -errno on failure. */ int apply_workqueue_attrs(struct workqueue_struct *wq, @@ -4037,9 +4039,11 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, { int ret; - apply_wqattrs_lock(); + lockdep_assert_cpus_held(); + + mutex_lock(&wq_pool_mutex); ret = apply_workqueue_attrs_locked(wq, attrs); - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); return ret; } @@ -4152,16 +4156,21 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) mutex_unlock(&wq->mutex); } return 0; - } else if (wq->flags & __WQ_ORDERED) { + } + + get_online_cpus(); + if (wq->flags & __WQ_ORDERED) { ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]); /* there should only be single pwq for ordering guarantee */ WARN(!ret && (wq->pwqs.next != &wq->dfl_pwq->pwqs_node || wq->pwqs.prev != &wq->dfl_pwq->pwqs_node), "ordering guarantee broken for workqueue %s\n", wq->name); - return ret; } else { - return apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); + ret = apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); } + put_online_cpus(); + + return ret; } static int wq_clamp_max_active(int max_active, unsigned int flags,
Change the calling convention for apply_workqueue_attrs to require CPU hotplug read exclusion. Avoids lockdep complaints about nested calls to get_online_cpus in a future patch where padata calls apply_workqueue_attrs when changing other CPU-hotplug-sensitive data structures with the CPU read lock already held. Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com> --- kernel/workqueue.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)