All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, heiko.carstens@de.ibm.com,
	borntraeger@de.ibm.com, rafael.j.wysocki@intel.com,
	paulmck@linux.vnet.ibm.com, peterz@infradead.org, bp@suse.de,
	jkosina@suse.cz
Subject: Re: [PATCH v4] CPU hotplug: active_writer not woken up in some cases - deadlock
Date: Sun, 14 Dec 2014 20:20:48 +0100	[thread overview]
Message-ID: <20141214192048.GA6372@redhat.com> (raw)
In-Reply-To: <20141212094636.754ab1f8@thinkpad-w530>

On 12/12, David Hildenbrand wrote:
>
> > This is subjective, but how about
> >
> > 	static bool xxx(void)
> > 	{
> > 		mutex_lock(&cpu_hotplug.lock);
> > 		if (atomic_read(&cpu_hotplug.refcount) == 0)
> > 			return true;
> > 		mutex_unlock(&cpu_hotplug.lock);
> > 		return false;
> > 	}
> >
> > 	void cpu_hotplug_begin(void)
> > 	{
> > 		cpu_hotplug.active_writer = current;
> >
> > 		cpuhp_lock_acquire();
> > 		wait_event(&cpu_hotplug.wq, xxx());
> > 	}
> >
> > instead?
> >
> > Oleg.
> >
>
> [   50.662459] do not call blocking ops when !TASK_RUNNING; state=2 set at [<000000000017340e>] prepare_to_wait_event+0x7a/0x124
> [   50.662472] ------------[ cut here ]------------
> [   50.662475] WARNING: at kernel/sched/core.c:7301
> [   50.662477] Modules linked in:
> [   50.662482] CPU: 5 PID: 225 Comm: cpu_start_stop. Not tainted 3.18.0+ #59
> [   50.662485] task: 0000000001f94b20 ti: 0000000001ffc000 task.ti: 0000000001ffc000
> ...
>
> Looks like your suggestion won't work. We can only set the task to
> TASK_UNINTERRUPTIBLE after taking the lock.

Yeees, this warning (and wait_woken() helpers) was specially added
to catch/fix the problem like this, sorry for confusion.

Easy to fix, just

	-	mutex_lock(&cpu_hotplug.lock);
	+	if (!mutex_trylock(&cpu_hotplug.lock))
	+		return false;

If .lock is locked then it is hold by get_online_cpus(), and it is going
to increment the counter.

I would like to say that this is what I actually meant but now I can not
recall if this is true ;)

But please ignore. Your next version looks simple/clear enough.

Oleg.


      reply	other threads:[~2014-12-14 19:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 13:22 [PATCH v4] CPU hotplug: active_writer not woken up in some cases - deadlock David Hildenbrand
2014-12-10 13:26 ` David Hildenbrand
2014-12-10 16:00   ` Paul E. McKenney
2014-12-10 19:23     ` David Hildenbrand
2014-12-10 17:50 ` Oleg Nesterov
2014-12-10 19:21   ` David Hildenbrand
2014-12-11  9:56   ` David Hildenbrand
2014-12-12  8:46   ` David Hildenbrand
2014-12-14 19:20     ` 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=20141214192048.GA6372@redhat.com \
    --to=oleg@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=bp@suse.de \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    /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.