public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 16:51:48 +0200	[thread overview]
Message-ID: <20111008145147.GA25607@redhat.com> (raw)
In-Reply-To: <4E8F8BE4.2080104@broadcom.com>

On 10/07, Bhanu Prakash Gollapudi wrote:
>
> Ok. I guess I plan to do something like this. This should avoid the race
> condition. I have not compiled or  tested it yet, but will update you
> the progress.

Confused. I was CC'ed in the middle of discussion, I simply do not
understand what are you talking about. And since we discuss this
off-list I can't find the previous messages. I added lkml.

So, what does this patch do? Looks like, it is on top of another patch
which changes the old workqueue code to take get_online_cpus() instead
of cpu_maps_update_begin() in create/destroy.

That previous change was wrong. And how this one can help?

And could you please explain which problem (or problems) you are trying
to solve? I thought that the problem is that work->func() can't use
cpu_hotplug_begin(), in particular this means it can not call
destroy_workqueue().

> @@ -209,6 +220,7 @@ static int __ref _cpu_down(unsigned int cpu, int
> tasks_frozen)
>         if (!cpu_online(cpu))
>                 return -EINVAL;
>
> +       cpu_sync_hotplug_begin();
>         cpu_hotplug_begin();
>         set_cpu_active(cpu, false);
>         err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod,
> @@ -258,6 +270,7 @@ out_release:
>                                             hcpu) == NOTIFY_BAD)
>                         BUG();
>         }
> +       cpu_sync_hotplug_done();
>         return err;
>  }

So, we add another global lock, it covers CPU_POST_DEAD.

> @@ -930,7 +932,9 @@ void destroy_workqueue(struct workqueue_struct *wq)
>         const struct cpumask *cpu_map = wq_cpu_map(wq);
>         int cpu;
>
> +       cpu_sync_hotplug_begin();
>         get_online_cpus();
> +       cpu_sync_hotplug_done();

OK, we are going to flush the pending works. Since we drop _sync_ lock,
a work->func() can take it again.

Seems to work, but it doesn't. Suppose _cpu_down() is called, suppose
that it takes cpu_sync_hotplug_begin() before that work. Deadlock.

Once again. May be I missed something (or even everything ;) but you
should not blame 3da1c84c00c commit, it was always wrong to destroy_
from work->func(). Note that there is another problem, CPU_POST_DEAD
needs to flush the pending works too and we have another obvious source
of deadlock.

Oleg.


       reply	other threads:[~2011-10-08 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1314339850-32666-1-git-send-email-bprakash@broadcom.com>
     [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                   ` Oleg Nesterov [this message]
     [not found]           ` <20111007145102.GA25449@redhat.com>
     [not found]             ` <4E8F8C97.6010804@broadcom.com>
2011-10-08 15:51               ` [PATCH 00/11] Modified workqueue patches for your review Oleg Nesterov

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=20111008145147.GA25607@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox