linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Sebastian Sewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Wanpeng Li <kernellwp@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	Engleder Gerhard <eg@keba.com>
Subject: Re: [PATCH RT v2] futex/rtmutex: Cure RT double blocking issue
Date: Thu, 11 May 2017 11:54:47 -0400	[thread overview]
Message-ID: <20170511115447.7622712d@gandalf.local.home> (raw)
In-Reply-To: <20170511152054.bpgik7etss7umxzq@linutronix.de>

On Thu, 11 May 2017 17:20:54 +0200
Sebastian Sewior <bigeasy@linutronix.de> wrote:

This is the same patch that Thomas wrote, right? Shouldn't this start
with:

From: Thomas Gleixner <tglx@linutronix.de>

?

-- Steve


> RT has a problem when the wait on a futex/rtmutex got interrupted by a
> timeout or a signal. task->pi_blocked_on is still set when returning from
> rt_mutex_wait_proxy_lock(). The task must acquire the hash bucket lock
> after this.
> 
> If the hash bucket lock is contended then the
> BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in
> task_blocks_on_rt_mutex() will trigger.
> 
> This can be avoided by clearing task->pi_blocked_on in the return path of
> rt_mutex_wait_proxy_lock() which removes the task from the boosting chain
> of the rtmutex. That's correct because the task is not longer blocked on
> it.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Reported-by: Engleder Gerhard <eg@keba.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  v1…v2: reset ->pi_blocked_on only in the error case.
> 
>  kernel/locking/rtmutex.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index 314fc65a35b1..4675f1197f33 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -2400,6 +2400,7 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock,
>  			       struct hrtimer_sleeper *to,
>  			       struct rt_mutex_waiter *waiter)
>  {
> +	struct task_struct *tsk = current;
>  	int ret;
>  
>  	raw_spin_lock_irq(&lock->wait_lock);
> @@ -2409,6 +2410,24 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock,
>  	/* sleep on the mutex */
>  	ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter, NULL);
>  
> +	/*
> +	 * RT has a problem here when the wait got interrupted by a timeout
> +	 * or a signal. task->pi_blocked_on is still set. The task must
> +	 * acquire the hash bucket lock when returning from this function.
> +	 *
> +	 * If the hash bucket lock is contended then the
> +	 * BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in
> +	 * task_blocks_on_rt_mutex() will trigger. This can be avoided by
> +	 * clearing task->pi_blocked_on which removes the task from the
> +	 * boosting chain of the rtmutex. That's correct because the task
> +	 * is not longer blocked on it.
> +	 */
> +	if (ret) {
> +		raw_spin_lock(&tsk->pi_lock);
> +		tsk->pi_blocked_on = NULL;
> +		raw_spin_unlock(&tsk->pi_lock);
> +	}
> +
>  	raw_spin_unlock_irq(&lock->wait_lock);
>  
>  	return ret;

  reply	other threads:[~2017-05-11 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 15:11 [PATCH RT] futex/rtmutex: Cure RT double blocking issue Thomas Gleixner
2017-05-09 15:49 ` Steven Rostedt
2017-05-11  2:25 ` Wanpeng Li
2017-05-11  7:31   ` Thomas Gleixner
2017-05-11 15:20     ` [PATCH RT v2] " Sebastian Sewior
2017-05-11 15:54       ` Steven Rostedt [this message]
2017-05-11 16:05         ` Sebastian Sewior

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=20170511115447.7622712d@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=bigeasy@linutronix.de \
    --cc=eg@keba.com \
    --cc=kernellwp@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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).