From: Thomas Gleixner <tglx@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-s390@vger.kernel.org, Stefan Liebler <stli@linux.ibm.com>,
Sebastian Sewior <bigeasy@linutronix.de>
Subject: Re: WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggered
Date: Mon, 28 Jan 2019 16:53:19 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1901281650310.1582@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20190128135804.GB28878@hirez.programming.kicks-ass.net>
On Mon, 28 Jan 2019, Peter Zijlstra wrote:
> On Mon, Jan 28, 2019 at 02:44:10PM +0100, Peter Zijlstra wrote:
> > On Thu, Nov 29, 2018 at 12:23:21PM +0100, Heiko Carstens wrote:
> >
> > > And indeed, if I run only this test case in an endless loop and do
> > > some parallel work (like kernel compile) it currently seems to be
> > > possible to reproduce the warning:
> > >
> > > while true; do time ./testrun.sh nptl/tst-robustpi8 --direct ; done
> > >
> > > within the build directory of glibc (2.28).
> >
> > Right; so that reproduces for me.
> >
> > After staring at all that for a while; trying to remember how it all
> > worked (or supposed to work rather), I became suspiscous of commit:
> >
> > 56222b212e8e ("futex: Drop hb->lock before enqueueing on the rtmutex")
> >
> > And indeed, when I revert that; the above reproducer no longer works (as
> > in, it no longer triggers in minutes and has -- so far -- held up for an
> > hour+ or so).
Right after staring long enough at it, the commit simply forgot to give
__rt_mutex_start_proxy_lock() the same treatment as it gave to
rt_mutex_wait_proxy_lock().
Patch below cures that.
Thanks,
tglx
8<----------------
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2845,7 +2845,7 @@ static int futex_lock_pi(u32 __user *uad
ret = rt_mutex_futex_trylock(&q.pi_state->pi_mutex);
/* Fixup the trylock return value: */
ret = ret ? 0 : -EWOULDBLOCK;
- goto no_block;
+ goto cleanup;
}
rt_mutex_init_waiter(&rt_waiter);
@@ -2870,17 +2870,15 @@ static int futex_lock_pi(u32 __user *uad
if (ret) {
if (ret == 1)
ret = 0;
-
- spin_lock(q.lock_ptr);
goto no_block;
}
-
if (unlikely(to))
hrtimer_start_expires(&to->timer, HRTIMER_MODE_ABS);
ret = rt_mutex_wait_proxy_lock(&q.pi_state->pi_mutex, to, &rt_waiter);
+no_block:
spin_lock(q.lock_ptr);
/*
* If we failed to acquire the lock (signal/timeout), we must
@@ -2894,7 +2892,7 @@ static int futex_lock_pi(u32 __user *uad
if (ret && !rt_mutex_cleanup_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter))
ret = 0;
-no_block:
+cleanup:
/*
* Fixup the pi_state owner and possibly acquire the lock if we
* haven't already.
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1749,9 +1749,6 @@ int __rt_mutex_start_proxy_lock(struct r
ret = 0;
}
- if (unlikely(ret))
- remove_waiter(lock, waiter);
-
debug_rt_mutex_print_deadlock(waiter);
return ret;
@@ -1778,6 +1775,8 @@ int rt_mutex_start_proxy_lock(struct rt_
raw_spin_lock_irq(&lock->wait_lock);
ret = __rt_mutex_start_proxy_lock(lock, waiter, task);
+ if (unlikely(ret))
+ remove_waiter(lock, waiter);
raw_spin_unlock_irq(&lock->wait_lock);
return ret;
next prev parent reply other threads:[~2019-01-28 15:53 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 8:11 WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggered Heiko Carstens
2018-11-28 14:32 ` Thomas Gleixner
2018-11-29 11:23 ` Heiko Carstens
2019-01-21 12:21 ` Heiko Carstens
2019-01-21 13:12 ` Thomas Gleixner
2019-01-22 21:14 ` Thomas Gleixner
2019-01-23 9:24 ` Heiko Carstens
2019-01-23 12:33 ` Thomas Gleixner
2019-01-23 12:40 ` Heiko Carstens
2019-01-28 13:44 ` Peter Zijlstra
2019-01-28 13:58 ` Peter Zijlstra
2019-01-28 15:53 ` Thomas Gleixner [this message]
2019-01-29 8:49 ` Peter Zijlstra
2019-01-29 22:15 ` [PATCH] futex: Handle early deadlock return correctly Thomas Gleixner
2019-01-30 12:01 ` Thomas Gleixner
2019-02-08 12:05 ` [tip:locking/urgent] " tip-bot for Thomas Gleixner
2019-01-29 9:01 ` WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggered Heiko Carstens
2019-01-29 9:33 ` Peter Zijlstra
2019-01-29 9:45 ` Thomas Gleixner
2019-01-29 10:24 ` Heiko Carstens
2019-01-29 10:35 ` Peter Zijlstra
2019-01-29 13:03 ` Thomas Gleixner
2019-01-29 13:23 ` Heiko Carstens
[not found] ` <20190129151058.GG26906@osiris>
2019-01-29 17:16 ` Sebastian Sewior
2019-01-29 21:45 ` Thomas Gleixner
[not found] ` <20190130094913.GC5299@osiris>
2019-01-30 12:15 ` Thomas Gleixner
[not found] ` <20190130125955.GD5299@osiris>
2019-01-30 13:24 ` Sebastian Sewior
2019-01-30 13:29 ` Thomas Gleixner
2019-01-30 14:33 ` Thomas Gleixner
2019-01-30 17:56 ` Thomas Gleixner
2019-01-30 21:07 ` Sebastian Sewior
2019-01-30 23:13 ` WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggerede Thomas Gleixner
2019-01-30 23:35 ` Paul E. McKenney
2019-01-30 23:55 ` Thomas Gleixner
2019-01-31 0:27 ` Thomas Gleixner
2019-01-31 1:45 ` Paul E. McKenney
2019-01-31 16:52 ` Heiko Carstens
2019-01-31 17:06 ` Sebastian Sewior
2019-01-31 20:42 ` Heiko Carstens
2019-02-01 16:12 ` Heiko Carstens
2019-02-01 21:59 ` Thomas Gleixner
[not found] ` <20190202091043.GA3381@osiris>
2019-02-02 10:14 ` Thomas Gleixner
2019-02-02 11:20 ` Heiko Carstens
2019-02-03 16:30 ` Thomas Gleixner
2019-02-04 11:40 ` Heiko Carstens
2019-01-31 1:44 ` Paul E. McKenney
2019-01-30 13:25 ` WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggered Thomas Gleixner
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=alpine.DEB.2.21.1901281650310.1582@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=schwidefsky@de.ibm.com \
--cc=stli@linux.ibm.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).