All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	git-commits-head@vger.kernel.org
Subject: Re: Exiting with locks still held (was Re: [PATCH] kmemleak: Fix scheduling-while-atomic bug)
Date: Fri, 3 Jul 2009 09:04:56 +0200	[thread overview]
Message-ID: <20090703070456.GD32687@elte.hu> (raw)
In-Reply-To: <1246538899.13320.86.camel@pc1117.cambridge.arm.com>


* Catalin Marinas <catalin.marinas@arm.com> wrote:

> Hi Ingo,
> 
> On Wed, 2009-07-01 at 13:04 +0200, Ingo Molnar wrote:
> > * Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > Since we are at locking, I just noticed this on my x86 laptop when
> > > running cat /sys/kernel/debug/kmemleak (I haven't got it on an ARM
> > > board):
> > > 
> > > ================================================
> > > [ BUG: lock held when returning to user space! ]
> > > ------------------------------------------------
> > > cat/3687 is leaving the kernel with locks still held!
> > > 1 lock held by cat/3687:
> > > #0:  (scan_mutex){+.+.+.}, at: [<c01e0c5c>] kmemleak_open+0x3c/0x70
> > > 
> > > kmemleak_open() acquires scan_mutex and unconditionally releases 
> > > it in kmemleak_release(). The mutex seems to be released as a 
> > > subsequent acquiring works fine.
> > > 
> > > Is this caused just because cat may have exited without closing 
> > > the file descriptor (which should be done automatically anyway)?
> > 
> > This lockdep warning has a 0% false positives track record so 
> > far: all previous cases it triggered showed some real (and 
> > fatal) bug in the underlying code.
> 
> In this particular case, there is no fatal problem as the mutex is 
> released shortly after this message.

Maybe - but holding locks in user-space is almost always bad.

What happens if user-space opens a second file descriptor before 
closing the first one? We either lock up (which is bad and fatal) or 
you already have some _other_ exclusion mechanism that prevents this 
case, which calls into question the need to hold this particular 
mutex in user-space to begin with.

I've yet to see a valid 'need to hold this kernel lock in 
user-space' case, and this does not seem to be such a case either.

	Ingo

  parent reply	other threads:[~2009-07-03  7:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200907010300.n6130rRf026194@hera.kernel.org>
2009-07-01  7:53 ` [PATCH] kmemleak: Fix scheduling-while-atomic bug Ingo Molnar
2009-07-01  8:10   ` Pekka Enberg
2009-07-01  9:18   ` Catalin Marinas
2009-07-01  9:30     ` Ingo Molnar
2009-07-01  9:46       ` Catalin Marinas
2009-07-01 11:04         ` Ingo Molnar
2009-07-02 12:48           ` Exiting with locks still held (was Re: [PATCH] kmemleak: Fix scheduling-while-atomic bug) Catalin Marinas
2009-07-02 12:54             ` Pekka Enberg
2009-07-02 13:06               ` Catalin Marinas
2009-07-02 14:13               ` Catalin Marinas
2009-07-02 17:39                 ` Linus Torvalds
2009-07-03 10:18                   ` Catalin Marinas
2009-07-03  7:04             ` Ingo Molnar [this message]
2009-07-02  9:48       ` [PATCH] kmemleak: Fix scheduling-while-atomic bug Catalin Marinas
2009-07-03  7:00         ` [PATCH] kmemleak: Mark nice +10 Ingo Molnar
2009-07-03  8:09           ` Catalin Marinas
2009-07-08 13:33       ` [PATCH] kmemleak: Fix scheduling-while-atomic bug Catalin Marinas
2009-08-23  2:48         ` Ming Lei
2009-08-23 14:59           ` Catalin Marinas
2009-08-24  0:10             ` Ming Lei
2009-08-24 10:02               ` ACPI scheduling while atomic (was: Re: [PATCH] kmemleak: Fix scheduling-while-atomic bug) Catalin Marinas

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=20090703070456.GD32687@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=git-commits-head@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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.