From: Oleg Nesterov <oleg@redhat.com>
To: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Cc: Tejun Heo <tj@kernel.org>, Mike Christie <michaelc@cs.wisc.edu>,
Michael Chan <mchan@broadcom.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/11] Modified workqueue patches for your review
Date: Sat, 8 Oct 2011 17:51:32 +0200 [thread overview]
Message-ID: <20111008155132.GA28854@redhat.com> (raw)
In-Reply-To: <4E8F8C97.6010804@broadcom.com>
On 10/07, Bhanu Prakash Gollapudi wrote:
>
> On 10/7/2011 7:51 AM, Oleg Nesterov wrote:
>> On 10/06, Bhanu Prakash Gollapudi wrote:
>>>
>>> On 10/6/2011 5:48 PM, Tejun Heo wrote:
>>>>
>>>>> Reviewing the patch, I agree that we cannot rely on
>>>>> get_online_cpus() any longer. But I'm also not convinced that
>>>>> cpu_add_remove_lock should be used instead, as it shows up some
>>>>> other deadlocks in destroy_workqueue context because of this global
>>>>> lock.
>>
>> Which deadlocks? work->func() must not use cpu_maps_update_begin/end
>> and thus it can't create/destroy !singlethread workqueue.
>
> Oleg, I attached the stack traces leading to deadlock in my previous
> email.
Yes, I didn't read it to the end... But you could save me some time and
explain ;)
OK. Afaics, it is easy to fix this particular problem... First of all,
scsi_host_dev_release() destroys the single-threaded wq. In this case
we do not actually need the locking/list_del, the code was written this
way just for consistency. See the patch below.
But, it seems, we could change scsi_host_dev_release() instead? It could
probably schedule_work() a work which actually does destroy_workqueue().
destroy/flush under the lock shared with work->func's is always dangerous.
> Based on Tejun's suggestion I sent a prototype patch that should fix the
> deadlock due to cpu_add_remove_lock, and avoid the race condition. I'm
> yet to test it.
Doesn't look right...
But once again, I didn't see the whole discussion, I have no idea what
I have missed.
Oleg.
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -930,14 +930,19 @@ void destroy_workqueue(struct workqueue_
const struct cpumask *cpu_map = wq_cpu_map(wq);
int cpu;
- cpu_maps_update_begin();
- spin_lock(&workqueue_lock);
- list_del(&wq->list);
- spin_unlock(&workqueue_lock);
-
- for_each_cpu(cpu, cpu_map)
- cleanup_workqueue_thread(per_cpu_ptr(wq->cpu_wq, cpu));
- cpu_maps_update_done();
+ if (is_wq_single_threaded(wq)) {
+ cleanup_workqueue_thread(per_cpu_ptr(wq->cpu_wq,
+ singlethread_cpu));
+ } else {
+ cpu_maps_update_begin();
+ spin_lock(&workqueue_lock);
+ list_del(&wq->list);
+ spin_unlock(&workqueue_lock);
+
+ for_each_cpu(cpu, cpu_map)
+ cleanup_workqueue_thread(per_cpu_ptr(wq->cpu_wq, cpu));
+ cpu_maps_update_done();
+ }
free_percpu(wq->cpu_wq);
kfree(wq);
prev parent reply other threads:[~2011-10-08 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1314339850-32666-1-git-send-email-bprakash@broadcom.com>
2011-08-26 6:24 ` [PATCH 02/11] ivtv: use kthread_worker instead of workqueue Bhanu Prakash Gollapudi
[not found] ` <20110826085457.GC2632@htj.dyndns.org>
[not found] ` <4E58138A.5050702@broadcom.com>
[not found] ` <4E8E378B.30907@broadcom.com>
[not found] ` <20111007004824.GA5458@google.com>
[not found] ` <4E8E5493.5010804@broadcom.com>
[not found] ` <20111007014534.GC5458@google.com>
[not found] ` <4E8E6660.8070502@broadcom.com>
[not found] ` <20111007062635.GA18562@dhcp-172-17-108-109.mtv.corp.google.com>
[not found] ` <4E8F8BE4.2080104@broadcom.com>
2011-10-08 14:51 ` [PATCH 00/11] Modified workqueue patches for your review Oleg Nesterov
[not found] ` <20111007145102.GA25449@redhat.com>
[not found] ` <4E8F8C97.6010804@broadcom.com>
2011-10-08 15:51 ` Oleg Nesterov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111008155132.GA28854@redhat.com \
--to=oleg@redhat.com \
--cc=bprakash@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=michaelc@cs.wisc.edu \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.