All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Luca Tettamanti <kronos.it@gmail.com>
Cc: linux-kernel@vger.kernel.org, john@johnmccutchan.com,
	rlove@rlove.org, Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH] Fix inconsistent lock state in inotify
Date: Tue, 14 Apr 2009 16:13:29 -0700	[thread overview]
Message-ID: <20090414161329.094b977c.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090410192533.GA24345@dreamland.darkstar.lan>

On Fri, 10 Apr 2009 21:25:33 +0200
Luca Tettamanti <kronos.it@gmail.com> wrote:

> Hello,
> in current -git lockdep generates the following warning:
> 
>  =================================
>  [ INFO: inconsistent lock state ]
>  2.6.30-rc1-kgdb #182
>  ---------------------------------
>  inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-W} usage.
>  kswapd0/419 [HC0[0]:SC0[0]:HE1:SE1] takes:
>   (&inode->inotify_mutex){+.+.?.}, at: [<ffffffff802c7036>] inotify_inode_is_dead+0x30/0x94
>  {RECLAIM_FS-ON-W} state was registered at:
>    [<ffffffff80259621>] mark_held_locks+0x4d/0x6b
>    [<ffffffff802596e3>] lockdep_trace_alloc+0xa4/0xbd
>    [<ffffffff8029ac2e>] __kmalloc+0x51/0xe6
>    [<ffffffff802c7ea2>] kernel_event+0xa7/0x10e
>    [<ffffffff802c7fdc>] inotify_dev_queue_event+0xd3/0x14b
>    [<ffffffff802c6f56>] inotify_inode_queue_event+0xab/0xe0
>    [<ffffffff802a6d83>] vfs_create+0xb1/0xc0
>    [<ffffffff802a975a>] do_filp_open+0x240/0x842
>    [<ffffffff8029cb1e>] do_sys_open+0x53/0xda
>    [<ffffffff802d0a62>] compat_sys_open+0x15/0x17
>    [<ffffffff80228e14>] sysenter_dispatch+0x7/0x30
>    [<ffffffffffffffff>] 0xffffffffffffffff
>  irq event stamp: 30075
>  hardirqs last  enabled at (30075): [<ffffffff802712cf>] call_rcu+0x5d/0x6a
>  hardirqs last disabled at (30074): [<ffffffff80271296>] call_rcu+0x24/0x6a
>  softirqs last  enabled at (27584): [<ffffffff8023d151>] __do_softirq+0x115/0x124
>  softirqs last disabled at (27573): [<ffffffff8020c13c>] call_softirq+0x1c/0x28
>  
>  other info that might help us debug this:
>  2 locks held by kswapd0/419:
>   #0:  (shrinker_rwsem){++++..}, at: [<ffffffff8027dd86>] shrink_slab+0x38/0x188
>   #1:  (&type->s_umount_key#16){++++..}, at: [<ffffffff802ad8c9>] shrink_dcache_memory+0xb9/0x193
>  
>  stack backtrace:
>  Pid: 419, comm: kswapd0 Not tainted 2.6.30-rc1-kgdb #182
>  Call Trace:
>   [<ffffffff8025906c>] print_usage_bug+0x1b6/0x1c7
>   [<ffffffff80259c54>] ? check_usage_forwards+0x0/0xa1
>   [<ffffffff8025938f>] mark_lock+0x312/0x557
>   [<ffffffff8025ad03>] __lock_acquire+0x7b7/0x1668
>   [<ffffffff802c7036>] ? inotify_inode_is_dead+0x30/0x94
>   [<ffffffff8025bc09>] lock_acquire+0x55/0x71
>   [<ffffffff802c7036>] ? inotify_inode_is_dead+0x30/0x94
>   [<ffffffff80442ec8>] mutex_lock_nested+0x5a/0x2fa
>   [<ffffffff802c7036>] ? inotify_inode_is_dead+0x30/0x94
>   [<ffffffff80259621>] ? mark_held_locks+0x4d/0x6b
>   [<ffffffff802712cf>] ? call_rcu+0x5d/0x6a
>   [<ffffffff802c7036>] inotify_inode_is_dead+0x30/0x94
>   [<ffffffff802ad3f1>] dentry_iput+0x82/0xc1
>   [<ffffffff802ad4f9>] d_kill+0x24/0x45
>   [<ffffffff802ad778>] __shrink_dcache_sb+0x25e/0x2f6
>   [<ffffffff802ad901>] shrink_dcache_memory+0xf1/0x193
>   [<ffffffff8027de2d>] shrink_slab+0xdf/0x188
>   [<ffffffff8027e3be>] kswapd+0x4e8/0x6a3
>   [<ffffffff80232d0c>] ? finish_task_switch+0x3b/0x10c
>   [<ffffffff8027bec4>] ? isolate_pages_global+0x0/0x26f
>   [<ffffffff8024becf>] ? autoremove_wake_function+0x0/0x38
>   [<ffffffff802598d6>] ? trace_hardirqs_on+0xd/0xf
>   [<ffffffff80444a41>] ? _spin_unlock_irqrestore+0x4c/0x68
>   [<ffffffff8027ded6>] ? kswapd+0x0/0x6a3
>   [<ffffffff8027ded6>] ? kswapd+0x0/0x6a3
>   [<ffffffff8024bb80>] kthread+0x49/0x76
>   [<ffffffff8020c03a>] child_rip+0xa/0x20
>   [<ffffffff8020ba00>] ? restore_args+0x0/0x30
>   [<ffffffff8024bb37>] ? kthread+0x0/0x76
>   [<ffffffff8020c030>] ? child_rip+0x0/0x20
> 
> The cause is a call to kmalloc with GFP_KERNEL; the following patch
> changes the flag to GFP_NOFS, which is also consistent with an earlier
> call to kmem_cache_alloc in the same function.
> 
> Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
> ---
> 
>  fs/notify/inotify/inotify_user.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index bed766e..1634319 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -220,7 +220,7 @@ static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
>  				rem = 0;
>  		}
>  
> -		kevent->name = kmalloc(len + rem, GFP_KERNEL);
> +		kevent->name = kmalloc(len + rem, GFP_NOFS);
>  		if (unlikely(!kevent->name)) {
>  			kmem_cache_free(event_cachep, kevent);
>  			return NULL;

Thanks.

This is in fact a false positive and we plan to fix it via lockdep
annotation.

(where "we" == eparis@redhat.com ;))

  reply	other threads:[~2009-04-14 23:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-10 19:25 [PATCH] Fix inconsistent lock state in inotify Luca Tettamanti
2009-04-14 23:13 ` Andrew Morton [this message]
2009-04-15 11:59   ` Luca Tettamanti
2009-04-15 19:25     ` Andrew Morton
2009-04-15 19:31       ` Eric Paris
2009-04-15 20:31         ` Andrew Morton

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=20090414161329.094b977c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=john@johnmccutchan.com \
    --cc=kronos.it@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rlove@rlove.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.