mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Daniel J Blueman <daniel.blueman@gmail.com>,
	torvalds@linux-foundation.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	mingo <mingo@elte.hu>
Subject: Re: [2.6.27-rc5] inotify_read's ev_mutex vs do_page_fault's mmap_sem...
Date: Wed, 10 Sep 2008 18:03:19 +1000	[thread overview]
Message-ID: <200809101803.20758.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <1221033455.31904.1221.camel@twins.programming.kicks-ass.net>

On Wednesday 10 September 2008 17:57, Peter Zijlstra wrote:
> On Wed, 2008-09-10 at 14:07 +1000, Nick Piggin wrote:
> > On Wednesday 10 September 2008 07:03, Daniel J Blueman wrote:
> > > I observed this locking violation [1] while gnome-panel was loading;
> > > this was previously reported at
> > > http://uwsg.iu.edu/hypermail/linux/kernel/0806.3/2881.html .
> > >
> > > Let me know for more information/config/testing. Thanks!
> >
> > Thanks for the report. I've attached a patch you could test. It compiles
> > (and boots a UML here) but I don't think I've actually tested the inotify
> > path at all, so it may explode on you.
> >
> > Peter, this copy_*_user stuff is quite a nightmare... Well actually it
> > isn't, if the code is designed with it in mind from the start, but it is
> > easy for people to forget it can take mmap_sem and filesystem locks... Is
> > there a way to annotate it and say "might take mmap_sem for read" for
> > example? So that these LORs will _always_ trigger rather than just once
> > in a million times when the reclaim gods frown on us?
>
> Sure, how about the below - untested - uncompiled, might eat kittens,
> etc..
>
> Just sprinkle something like:
>
>   might_lock_read(&mm->mmap_sem);
>
> in the right places.

Ahh, very nice, thanks! I'll give that a try...


> ---
> Subject: lockdep: might_lock annotation
>
> useful to establish a lock dependency in case the actual dependency is
> rare or hard to trigger.
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
> index 331e5f1..0aa657a 100644
> --- a/include/linux/lockdep.h
> +++ b/include/linux/lockdep.h
> @@ -480,4 +480,22 @@ static inline void print_irqtrace_events(struct
> task_struct *curr) # define lock_map_release(l)			do { } while (0)
>  #endif
>
> +#ifdef CONFIG_PROVE_LOCKING
> +# define might_lock(lock) 						\
> +do {									\
> +	typecheck(struct lockdep_map *, &(lock)->dep_map);		\
> +	lock_acquire(&(lock)->dep_map, 0, 0, 0, 2, NULL, _THIS_IP_);	\
> +	lock_release(&(lock)->dep_map, 0, _THIS_IP_);			\
> +} while (0)
> +# define might_lock_read(lock) 						\
> +do {									\
> +	typecheck(struct lockdep_map *, &(lock)->dep_map);		\
> +	lock_acquire(&(lock)->dep_map, 0, 0, 1, 2, NULL, _THIS_IP_);	\
> +	lock_release(&(lock)->dep_map, 0, _THIS_IP_);			\
> +} while (0)
> +#else
> +# define might_lock(lock) do { } while (0)
> +# define might_lock_read(lock) do { } while (0)
> +#endif
> +
>  #endif /* __LINUX_LOCKDEP_H */

  reply	other threads:[~2008-09-10  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09 21:03 Daniel J Blueman
2008-09-10  4:07 ` Nick Piggin
2008-09-10  7:57   ` Peter Zijlstra
2008-09-10  8:03     ` Nick Piggin [this message]
2008-09-10  8:37       ` Ingo Molnar
2008-09-10  9:50         ` Nick Piggin
2008-09-10  9:59           ` Peter Zijlstra
2008-09-10 20:11             ` Nick Piggin
2008-09-10 20:12   ` Nick Piggin
2008-09-10 20:10     ` Daniel J Blueman

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=200809101803.20758.nickpiggin@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.blueman@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®