From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
To: agrover@redhat.com
Cc: stgt@vger.kernel.org
Subject: Re: [PATCH 1/3] Fix race on thread shutdown causing deadlock
Date: Wed, 30 Apr 2014 23:29:06 +0900 [thread overview]
Message-ID: <20140430231940U.fujita.tomonori@lab.ntt.co.jp> (raw)
In-Reply-To: <1398736282-1193-1-git-send-email-agrover@redhat.com>
On Mon, 28 Apr 2014 18:51:20 -0700
Andy Grover <agrover@redhat.com> wrote:
> This patch and the next are somewhat a revert of 318e9f2, but the previous
> fix didn't quite close the race. This only happens when we create threads
> for a backstore that turns out to be invalid, which we then tear down.
>
> See https://bugzilla.redhat.com/show_bug.cgi?id=848585 .
>
> This is occurring because there's still a window where a thread misses
> seeing info->stop == 1 but is not yet in cond_wait so it misses the
> broadcast:
>
> thread_close: thread_worker_fn:
> info->stop is seen as 0
> info->stop = 1
> pthread_cond_broadcast -- misses broadcast
> pthread_cond_wait
> pthread_join (hangs)
>
> I believe the solution is to go back to using pthread_cancel. We can call
> it before pthread_cond_wait is called (or after) and it will do the right
> thing: pop out and exit. The only tricky bit is we need to use the
> pthread_cleanup_push mechanism to properly release info->pending_lock.
>
> Signed-off-by: Andy Grover <agrover@redhat.com>
> ---
> usr/bs.c | 25 ++++++++++++++-----------
> usr/bs_thread.h | 2 --
> 2 files changed, 14 insertions(+), 13 deletions(-)
Thanks a lot for the fixes and detailed explanation. Surely, looks
like there is a race. The whole patchset looks good. Applied, thanks!
prev parent reply other threads:[~2014-04-30 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-29 1:51 [PATCH 1/3] Fix race on thread shutdown causing deadlock Andy Grover
2014-04-29 1:51 ` [PATCH 2/3] Remove startup_lock Andy Grover
2014-04-29 1:51 ` [PATCH 3/3] Replace if()/goto with while() Andy Grover
2014-04-30 14:29 ` FUJITA Tomonori [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=20140430231940U.fujita.tomonori@lab.ntt.co.jp \
--to=fujita.tomonori@lab.ntt.co.jp \
--cc=agrover@redhat.com \
--cc=stgt@vger.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).