From: Jiri Kosina <jkosina@suse.cz>
To: Tejun Heo <tj@kernel.org>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
cl@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: irq lock inversion
Date: Thu, 5 Nov 2009 15:31:48 +0100 (CET) [thread overview]
Message-ID: <alpine.LSU.2.00.0911051502060.9988@wotan.suse.de> (raw)
In-Reply-To: <4AF28D7A.6020209@kernel.org>
[ added LKML to CC so that the lockdep message is at least indexed by
search engines in archives ]
On Thu, 5 Nov 2009, Tejun Heo wrote:
> > lockdep only considers a lock irq-safe if it was used from an irq
> > context before.
> >
> > _irqsave() API usage alone does not trigger this.
>
> Thanks for the explanation. It's about the same tho. sched_init() is
> calling it with irq disabled but that's an exception to might_sleep()
> rule. Maybe making lockdep recognize the same exception as
> might_sleep() so that lockdep doesn't consider a lock irq-safe if it's
> called with irq off but before system_state is set to SYSTEM_RUNNING
> works around the problem?
Hmm, I wonder why I don't see this lockdep warning myself with
head on 1836d9592, even though I have
CONFIG_PROVE_LOCKING=y
CONFIG_TRACE_IRQFLAGS=y
... ?
Anyway, how about something like this? (I can't verify myself that it even
fixes the warning, as I don't see it for some odd reason)
From: Jiri Kosina <jkosina@suse.cz>
Subject: lockdep: avoid false positives about irq-safety
Commit 403a91b1 ("percpu: allow pcpu_alloc() to be called
with IRQs off") introduced this warning:
=========================================================
[ INFO: possible irq lock inversion dependency detected ]
2.6.32-rc5-tip-04815-g12f0f93-dirty #745
---------------------------------------------------------
hub 1-3:1.0: state 7 ports 2 chg 0000 evt 0004
ksoftirqd/65/199 just changed the state of lock:
(pcpu_lock){..-...}, at: [<ffffffff81130e04>] free_percpu+0x38/0x104
but this lock took another, SOFTIRQ-unsafe lock in the past:
(vmap_area_lock){+.+...}
and interrupts could create inverse lock ordering between them.
This warning is bogus -- sched_init() is being called very early with IRQs
disabled, and the irqsave/restore code paths in pcpu_alloc() are only for early
init. The path can never be called from irq context once the early init
finishes. Rationale for this is explained in changelog of the commit mentioned
above.
This problem can be encountered generally in any other early code running
with IRQs off and using irqsave/irqrestore.
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
kernel/lockdep.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 9af5672..996b395 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2487,6 +2487,14 @@ void lockdep_trace_alloc(gfp_t gfp_mask)
static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock)
{
+ /*
+ * This is exception similar to the might_sleep() one.
+ * We don't care about irq-safety of the locks this early, as
+ * it will produce false positives (sched_init() is called with
+ * irqs off, but needs to use irqsave/irqrestore API)
+ */
+ if (system_state != SYSTEM_RUNNING)
+ return 1;
/*
* If non-trylock use in a hardirq or softirq context, then
* mark the lock as used in these contexts:
next parent reply other threads:[~2009-11-05 14:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <86802c440911041008q4969b9bdk15b4598c40bb84bd@mail.gmail.com>
[not found] ` <4AF25FC7.4000502@kernel.org>
[not found] ` <20091105082102.GA2870@elte.hu>
[not found] ` <4AF28D7A.6020209@kernel.org>
2009-11-05 14:31 ` Jiri Kosina [this message]
2009-11-06 5:53 ` irq lock inversion Tejun Heo
2009-11-06 7:17 ` Ingo Molnar
2009-11-06 7:45 ` Tejun Heo
2009-11-06 7:58 ` Ingo Molnar
2009-11-06 8:24 ` Tejun Heo
2009-11-06 8:40 ` Ingo Molnar
2009-11-06 8:52 ` Tejun Heo
2009-11-06 16:08 ` Christoph Lameter
2009-11-06 16:38 ` Tejun Heo
2009-11-06 17:03 ` Christoph Lameter
2009-11-07 16:13 ` Peter Zijlstra
2009-11-09 5:46 ` [PATCH percpu#for-linus] percpu: fix possible deadlock via " Tejun Heo
2009-11-06 9:59 ` Jens Axboe
2009-11-08 9:38 ` Ingo Molnar
2009-11-09 15:34 ` Jens Axboe
2009-11-09 15:45 ` Ingo Molnar
2009-11-09 15:49 ` Jens Axboe
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.LSU.2.00.0911051502060.9988@wotan.suse.de \
--to=jkosina@suse.cz \
--cc=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=yhlu.kernel@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 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.