From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Ming Lei <tom.leiming@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-embedded@vger.kernel.org, a.p.zijlstra@chello.nl,
linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
Date: Sun, 23 May 2010 20:47:46 +0100 [thread overview]
Message-ID: <20100523194746.GE950@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <AANLkTinV9Na9zxYMIfTr893Ynnc0YOk2B6uPKEa9s4R1@mail.gmail.com>
On Sun, May 23, 2010 at 11:07:50PM +0800, Ming Lei wrote:
> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> > On Sun, May 23, 2010 at 09:44:20PM +0800, Ming Lei wrote:
> >> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> >> >> ENTRY(ret_to_user)
> >> >> ret_slow_syscall:
> >> >> - disable_irq @ disable interrupts
> >> >> + disable_irq_notrace @ disable interrupts
> >> >
> >> > I think this one does need to be traced - the pending work functions are
> >> > all C code which could call back into lockdep.
> >>
> >> If there are pending works, schedule will be called to give cpu to it,
> >> I wonder why the work function to be scheduled will be run with irq
> >> disabled. Seems we should enable irq again before calling schedule,
> >> not sure.
> >
> > No. I'm talking about things like do_notify_resume().
> >
> > I think the above should be left as-is, so that as far as lockdep is
> > concerned, IRQs are off while userspace runs. What happens between
> > returning to userspace and re-entering the kernel has no bearing what
> > so ever on lockdep.
> >
>
> Oh, trace_ret_hardirqs_on has to be added before returning to user-space to
> remove the warning, like x86 and mips. If you agree, I'd like to post
> a new version patch.
Let me explain again. We have this series of actions:
- in userspace
- exception happens
- cpu disables interrupts itself
- save state
- enable interrupts, and tell lockdep that IRQs are unmasked
- we process the exception, and ultimately call ret_fast_syscall or
ret_slow_syscall
Now, what was happening in existing kernels is:
POINT A.
- disable interrupts, and tell lockdep that IRQs are masked
- check for any work pending
- if work pending, call function - with IRQs still masked
- go back to point A.
- restore state
- resume userspace, which implicitly re-enables IRQs
This results in a balanced and afaics correct setup. Lockdep doesn't
care about the state of userspace - it only cares about state (and its
code only ever runs) when we're in kernel mode.
With your change above, what's happening is the above is replaced by:
POINT A.
- disable interrupts, but don't tell lockdep that IRQs are masked
- check for any work pending
- if work pending, call function - with IRQs still masked
*but* lockdep believes IRQs are enabled. Therefore, I believe
false warnings are probable from things like the scheduler,
signal handling paths, etc.
- go back to point A.
- restore state
- resume userspace, which implicitly re-enables IRQs
So can you now see why I believe the above change I've quoted is wrong?
Moreover, I put to you that it's utterly pointless - and a waste of CPU
time - telling lockdep about the IRQ masking when an exception occurs,
and it's also pointless telling lockdep about the IRQ unmasking when we
resume userspace.
next prev parent reply other threads:[~2010-05-23 19:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-23 11:48 [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning tom.leiming
2010-05-23 12:38 ` Russell King - ARM Linux
2010-05-23 13:44 ` Ming Lei
2010-05-23 14:13 ` Russell King - ARM Linux
2010-05-23 15:07 ` Ming Lei
2010-05-23 19:47 ` Russell King - ARM Linux [this message]
2010-05-24 3:23 ` Ming Lei
2010-05-24 7:19 ` Russell King - ARM Linux
2010-05-24 10:14 ` Russell King - ARM Linux
2010-05-24 14:20 ` Ming Lei
2010-05-24 14:45 ` Russell King - ARM Linux
2010-05-24 15:19 ` Ming Lei
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=20100523194746.GE950@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.leiming@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 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).