From: Oleg Nesterov <oleg@redhat.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org
Subject: lock_task_sighand() && rcu_boost()
Date: Sat, 3 May 2014 18:11:33 +0200 [thread overview]
Message-ID: <20140503161133.GA8838@redhat.com> (raw)
Paul,
I just noticed by accident that __lock_task_sighand() looks ugly and
mysterious ;) And I am puzzled.
a841796f11c90d53 "signal: align __lock_task_sighand() irq disabling and RCU"
says:
The __lock_task_sighand() function calls rcu_read_lock() with interrupts
and preemption enabled, but later calls rcu_read_unlock() with interrupts
disabled. It is therefore possible that this RCU read-side critical
section will be preempted and later RCU priority boosted, which means that
rcu_read_unlock() will call rt_mutex_unlock() in order to deboost itself, but
with interrupts disabled. This results in lockdep splats ...
OK, if we can't rcu_read_unlock() with irqs disabled, then we can at least
cleanup it (and document the problem). Say,
struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
unsigned long *flags)
{
struct sighand_struct *sighand;
rcu_read_lock();
for (;;) {
sighand = rcu_dereference(tsk->sighand);
if (unlikely(sighand == NULL))
break;
spin_lock_irqsave(&sighand->siglock, *flags);
/*
* We delay rcu_read_unlock() till unlock_task_sighand()
* to avoid rt_mutex_unlock(current->rcu_boost_mutex) with
* irqs disabled.
*/
if (likely(sighand == tsk->sighand))
return sighand;
spin_unlock_irqrestore(&sighand->siglock, *flags);
}
rcu_read_unlock();
return sighand; /* NULL */
}
and add rcu_read_unlock() into unlock_task_sighand().
But. I simply can't understand why lockdep should complain? Why it is bad
to lock/unlock ->wait_lock with irqs disabled?
wakeup_next_waiter() and rt_mutex_adjust_prio() should be fine, they start
with _irqsave().
The changelog also says:
It is quite possible that a better long-term fix is to make rt_mutex_unlock()
disable irqs when acquiring the rt_mutex structure's ->wait_lock.
and if it is actually bad, then how the change above can fix the problem?
Help!
Oleg.
next reply other threads:[~2014-05-03 16:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-03 16:11 Oleg Nesterov [this message]
2014-05-04 18:01 ` lock_task_sighand() && rcu_boost() Paul E. McKenney
2014-05-04 19:17 ` Oleg Nesterov
2014-05-04 22:38 ` Paul E. McKenney
2014-05-05 13:26 ` Oleg Nesterov
2014-05-05 15:26 ` Paul E. McKenney
2014-05-05 16:47 ` Oleg Nesterov
2014-05-05 18:53 ` [PATCH] signal: Simplify __lock_task_sighand() Oleg Nesterov
2014-05-05 19:55 ` Oleg Nesterov
2014-05-05 20:56 ` Paul E. McKenney
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=20140503161133.GA8838@redhat.com \
--to=oleg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.