From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>,
linux-kernel@vger.kernel.org, Sami Farin <sami.farin@gmail.com>,
Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH 0/1] Fix hang report
Date: Wed, 11 Dec 2013 21:11:57 -0500 [thread overview]
Message-ID: <1386814318-5868-1-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <20131124210539.3fclaxkopszlgkxh@m.safari.iki.fi>
Greg,
I know it's late in the -rc cycle but I'd like to get this fix into 3.13.
Although it's only likely to happen at shutdown/reboot, the hang frequency
could be as often as 1 in 10000.
The patch fixes the count value returned when the cmpxchg() has
successfully changed the count. Only one code path checks the
returned count when the cmpxchg() is successful; down_read_failed().
After failed down_read attempt is reversed but before the reader waits
for the lock, the new count is checked to ensure _someone_ has the lock:
/* if there are no active locks, wake the new lock owner(s) */
if ((count & LDSEM_ACTIVE_MASK) == 0)
__ldsem_wake(sem);
Because ldsem_cmpxchg() was returning the _old_ value on success, this
was checking the wrong count value.
No other code paths are impacted by the patch. The equivalent diff below
also fixes the problem; however, I feel the intent is less clear.
| diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c
| index 22fad8a..29d9e7c 100644
| --- a/drivers/tty/tty_ldsem.c
| +++ b/drivers/tty/tty_ldsem.c
| @@ -222,7 +222,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
| get_task_struct(tsk);
|
| /* if there are no active locks, wake the new lock owner(s) */
| - if ((count & LDSEM_ACTIVE_MASK) == 0)
| + if ((count + adjust & LDSEM_ACTIVE_MASK) == 0)
| __ldsem_wake(sem);
|
| raw_spin_unlock_irq(&sem->wait_lock);
Regards,
Peter Hurley (1):
tty: Fix hang at ldsem_down_read()
drivers/tty/tty_ldsem.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--
1.8.1.2
next parent reply other threads:[~2013-12-12 2:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20131124210539.3fclaxkopszlgkxh@m.safari.iki.fi>
2013-12-12 2:11 ` Peter Hurley [this message]
2013-12-12 2:11 ` [PATCH 1/1] tty: Fix hang at ldsem_down_read() Peter Hurley
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=1386814318-5868-1-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=sami.farin@gmail.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
all inboxes | Powered by JetHome®