From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: "Ilia, Kolominsky" <iliak@ti.com>
Cc: Peter Hurley <peter@hurleysoftware.com>,
linux-bluetooth <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH] Bluetooth: Fix hidp disconnect deadlock
Date: Thu, 30 Jun 2011 14:47:33 -0300 [thread overview]
Message-ID: <20110630174733.GB25602@joana> (raw)
In-Reply-To: <AC090B9732AB2B4DB7FF476E907FE66001316415C9@dnce02.ent.ti.com>
* Ilia, Kolominsky <iliak@ti.com> [2011-06-30 16:55:52 +0200]:
> > -----Original Message-----
> > From: Peter Hurley [mailto:peter@hurleysoftware.com]
> > Sent: Thursday, June 30, 2011 5:35 PM
> > To: Gustavo F. Padovan
> > Cc: Ilia, Kolominsky; linux-bluetooth
> > Subject: Re: [PATCH] Bluetooth: Fix hidp disconnect deadlock
> >
> > On Wed, 2011-06-29 at 16:52 -0400, Gustavo F. Padovan wrote:
> > > * Gustavo F. Padovan <padovan@profusion.mobi> [2011-06-29 17:24:56 -
> > 0300]:
> > >
> > > > * Ilia, Kolominsky <iliak@ti.com> [2011-06-26 09:16:58 +0200]:
> > > >
> > > > > Hi!
> > > > > IMHO the fix isnt good due to possible race condition which
> > > > > will destroy session/task objects - either by a call to
> > kthread_stop
> > > > > from the timer func or reentry to hidp_del_connection() on
> > > > > smp platforms.
> > ....
> > > This should fix the timer issue. Please test.
> > >
> > > Gustavo
> >
> > Hi Ilia & Gustavo,
> >
> > After Ilia pointed out the problem with the timer function, I went back
> > and reviewed *all* the synchronization code relevant to the hid session
> > thread.
> >
> > A number of problems were introduced with commit aabf6f89 - when the
> > session thread was converted from a kernel_thread to a kthread.
> > Although
> > a kthread is a better choice for representing the session thread, the
> > naive conversion of atomic/wakeup to kthread_stop() was inappropriate.
> >
> > kthread_stop() has usage semantics that different significantly from
> > atomic/wakeup. As we already know, because kthread_stop() blocks on
> > thread completion, it can introduce deadlocks in code that already uses
> > exclusion mechanisms. Even with Ilia's new patch, consider the
> > following
> > sequence:
> >
> > Thread 0 Thread 1 Thread 2
> > in hidp_del_connection in hidp session
> > claim r/w sem .
> > timer triggers .
> > kthread_stop() --------->.
> > *blocks on thread 2* exits loop
> > *blocks for r/w
>
> Guys, as far as I know - it is not possible to use kthread_stop from
> The timer func - since it may sleep and we are in soft_irq...
> What I did is added kthread_stop_async in the kthread use it in both
> Timer func and hidp_del_connection(). I am still polishing the code
> though...
Yes, you right, we really can't call kthread_stop there.
> Gustavo, is adding the new api to kthread feasible?
> How to upstream such change?
I don't know the kthread internals to tell you if this is feasible or not. You
have to send the patch to the maintainer of kthread
(./scripts/get_maintainer.pl tells you the maintainer) and explain why you
need this to him.
But we also need a solution in the short term, this week, in order to fix this
in the up coming 3.0 release.
Gustavo
next prev parent reply other threads:[~2011-06-30 17:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-25 21:32 [PATCH] Bluetooth: Fix hidp disconnect deadlock Peter Hurley
2011-06-26 7:16 ` Ilia, Kolominsky
2011-06-29 20:24 ` Gustavo F. Padovan
2011-06-29 20:52 ` Gustavo F. Padovan
2011-06-30 14:34 ` Peter Hurley
2011-06-30 14:46 ` gene heskett
2011-06-30 14:55 ` Ilia, Kolominsky
2011-06-30 17:47 ` Gustavo F. Padovan [this message]
2011-06-30 17:40 ` Gustavo F. Padovan
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=20110630174733.GB25602@joana \
--to=padovan@profusion.mobi \
--cc=iliak@ti.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=peter@hurleysoftware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).