From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Kacur <jkacur@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
"Luis Claudio R. Goncalves" <lclaudio@uudg.org>,
Josh Cartwright <joshc@ni.com>
Subject: [PATCH RT 03/11] list_bl: fixup bogus lockdep warning
Date: Tue, 12 Jul 2016 12:49:53 -0400 [thread overview]
Message-ID: <20160712165020.207170017@goodmis.org> (raw)
In-Reply-To: 20160712164950.490572026@goodmis.org
[-- Attachment #1: 0003-list_bl-fixup-bogus-lockdep-warning.patch --]
[-- Type: text/plain, Size: 3030 bytes --]
3.12.61-rt82-rc1 stable review patch.
If anyone has any objections, please let me know.
------------------
From: Josh Cartwright <joshc@ni.com>
At first glance, the use of 'static inline' seems appropriate for
INIT_HLIST_BL_HEAD().
However, when a 'static inline' function invocation is inlined by gcc,
all callers share any static local data declared within that inline
function.
This presents a problem for how lockdep classes are setup. raw_spinlocks, for
example, when CONFIG_DEBUG_SPINLOCK,
# define raw_spin_lock_init(lock) \
do { \
static struct lock_class_key __key; \
\
__raw_spin_lock_init((lock), #lock, &__key); \
} while (0)
When this macro is expanded into a 'static inline' caller, like
INIT_HLIST_BL_HEAD():
static inline INIT_HLIST_BL_HEAD(struct hlist_bl_head *h)
{
h->first = NULL;
raw_spin_lock_init(&h->lock);
}
...the static local lock_class_key object is made a function static.
For compilation units which initialize invoke INIT_HLIST_BL_HEAD() more
than once, then, all of the invocations share this same static local
object.
This can lead to some very confusing lockdep splats (example below).
Solve this problem by forcing the INIT_HLIST_BL_HEAD() to be a macro,
which prevents the lockdep class object sharing.
=============================================
[ INFO: possible recursive locking detected ]
4.4.4-rt11 #4 Not tainted
---------------------------------------------
kswapd0/59 is trying to acquire lock:
(&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
but task is already holding lock:
(&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&h->lock#2);
lock(&h->lock#2);
*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by kswapd0/59:
#0: (shrinker_rwsem){+.+...}, at: rt_down_read_trylock
#1: (&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
Reported-by: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Tested-by: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Signed-off-by: Josh Cartwright <joshc@ni.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/list_bl.h | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index d8876a0cf036..017d0f1c1eb4 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -42,13 +42,15 @@ struct hlist_bl_node {
struct hlist_bl_node *next, **pprev;
};
-static inline void INIT_HLIST_BL_HEAD(struct hlist_bl_head *h)
-{
- h->first = NULL;
#ifdef CONFIG_PREEMPT_RT_BASE
- raw_spin_lock_init(&h->lock);
+#define INIT_HLIST_BL_HEAD(h) \
+do { \
+ (h)->first = NULL; \
+ raw_spin_lock_init(&(h)->lock); \
+} while (0)
+#else
+#define INIT_HLIST_BL_HEAD(h) (h)->first = NULL
#endif
-}
static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
{
--
2.8.1
next prev parent reply other threads:[~2016-07-12 16:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 16:49 [PATCH RT 00/11] Linux 3.12.61-rt82-rc1 Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 01/11] kvm, rt: change async pagefault code locking for PREEMPT_RT Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 02/11] net: dev: always take qdiscs busylock in __dev_xmit_skb() Steven Rostedt
2016-07-12 16:49 ` Steven Rostedt [this message]
2016-07-12 16:49 ` [PATCH RT 04/11] ARM: imx: always use TWD on IMX6Q Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 05/11] kernel/printk: Dont try to print from IRQ/NMI region Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 06/11] arm: lazy preempt: correct resched condition Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 07/11] locallock: add local_lock_on() Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 08/11] mm: perform lru_add_drain_all() remotely Steven Rostedt
2016-07-12 16:49 ` [PATCH RT 09/11] trace: correct off by one while recording the trace-event Steven Rostedt
2016-07-12 16:50 ` [PATCH RT 10/11] x86: Fix an RT MCE crash Steven Rostedt
2016-07-12 16:50 ` [PATCH RT 11/11] Linux 3.12.61-rt82-rc1 Steven Rostedt
2016-07-12 23:23 ` Linux 3.12.61-rt82-rc2 Steven Rostedt
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=20160712165020.207170017@goodmis.org \
--to=rostedt@goodmis.org \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=jkacur@redhat.com \
--cc=joshc@ni.com \
--cc=lclaudio@uudg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--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).