2008-08-12 00:17:53

by Max Krasnyansky

[permalink] [raw]
Subject: Circular vma locking with kvm, seems to be mmu notifiers related

Got this on the latest mainline git.
There are already a couple of lockdep/kvm threads. So maybe it's known.

=============================================
[ INFO: possible recursive locking detected ]
2.6.27-rc2 #36
---------------------------------------------
qemu-system-x86/3445 is trying to acquire lock:
(&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0

but task is already holding lock:
(&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0

other info that might help us debug this:
4 locks held by qemu-system-x86/3445:
#0: (&mm->mmap_sem){----}, at: [<ffffffff802b2009>]
do_mmu_notifier_register+0xe9/0x140
#1: (mm_all_locks_mutex){--..}, at: [<ffffffff8029f7e7>]
mm_take_all_locks+0x27/0xf0
#2: (&inode->i_data.i_mmap_lock){--..}, at: [<ffffffff8029f877>]
mm_take_all_locks+0xb7/0xf0
#3: (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>]
mm_take_all_locks+0x8d/0xf0

stack backtrace:
Pid: 3445, comm: qemu-kvm Not tainted 2.6.27-rc2 #36

Call Trace:
[<ffffffff80261ddf>] __lock_acquire+0x92f/0x1020
[<ffffffff80260c3d>] ? mark_held_locks+0x4d/0x90
[<ffffffff80260de1>] ? trace_hardirqs_on_caller+0xe1/0x100
[<ffffffff8026252b>] lock_acquire+0x5b/0x80
[<ffffffff8029f84d>] ? mm_take_all_locks+0x8d/0xf0
[<ffffffff8053348f>] _spin_lock+0x2f/0x40
[<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
[<ffffffff802b1f75>] do_mmu_notifier_register+0x55/0x140
[<ffffffff802b207e>] mmu_notifier_register+0xe/0x10
[<ffffffffa00f21db>] kvm_dev_ioctl+0x17b/0x300 [kvm]
[<ffffffff802c49a1>] vfs_ioctl+0x31/0xa0
[<ffffffff802c4c9b>] do_vfs_ioctl+0x28b/0x2f0
[<ffffffff802c4d4a>] sys_ioctl+0x4a/0x80
[<ffffffff8020b9db>] system_call_fastpath+0x16/0x1b


2008-08-13 08:36:41

by Avi Kivity

[permalink] [raw]
Subject: Re: Circular vma locking with kvm, seems to be mmu notifiers related

Max Krasnyansky wrote:
> Got this on the latest mainline git.
> There are already a couple of lockdep/kvm threads. So maybe it's known.
>
> =============================================
> [ INFO: possible recursive locking detected ]
> 2.6.27-rc2 #36
> ---------------------------------------------
> qemu-system-x86/3445 is trying to acquire lock:
> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>
> but task is already holding lock:
> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>
>

Seems to be a false positive. mmu_take_all_locks takes (surprise!) all
anon_vma->locks belonging to an mm, and takes special care not to
deadlock while doing this.

We need to communicate this to lockdep somehow.

--
error compiling committee.c: too many arguments to function

2008-08-13 08:49:51

by Johannes Weiner

[permalink] [raw]
Subject: Re: Circular vma locking with kvm, seems to be mmu notifiers related

Hi Avi,

Avi Kivity <[email protected]> writes:

> Max Krasnyansky wrote:
>> Got this on the latest mainline git.
>> There are already a couple of lockdep/kvm threads. So maybe it's known.
>>
>> =============================================
>> [ INFO: possible recursive locking detected ]
>> 2.6.27-rc2 #36
>> ---------------------------------------------
>> qemu-system-x86/3445 is trying to acquire lock:
>> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>>
>> but task is already holding lock:
>> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>>
>>
>
> Seems to be a false positive. mmu_take_all_locks takes (surprise!)
> all anon_vma->locks belonging to an mm, and takes special care not to
> deadlock while doing this.
>
> We need to communicate this to lockdep somehow.

I think Peter already annotated this in
454ed842d55740160334efc9ad56cfef54ed37bc .

Hannes

2008-08-13 09:01:20

by Avi Kivity

[permalink] [raw]
Subject: Re: Circular vma locking with kvm, seems to be mmu notifiers related

Johannes Weiner wrote:
> Hi Avi,
>
> Avi Kivity <[email protected]> writes:
>
>
>> Max Krasnyansky wrote:
>>
>>> Got this on the latest mainline git.
>>> There are already a couple of lockdep/kvm threads. So maybe it's known.
>>>
>>> =============================================
>>> [ INFO: possible recursive locking detected ]
>>> 2.6.27-rc2 #36
>>> ---------------------------------------------
>>> qemu-system-x86/3445 is trying to acquire lock:
>>> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>>>
>>> but task is already holding lock:
>>> (&anon_vma->lock){--..}, at: [<ffffffff8029f84d>] mm_take_all_locks+0x8d/0xf0
>>>
>>>
>>>
>> Seems to be a false positive. mmu_take_all_locks takes (surprise!)
>> all anon_vma->locks belonging to an mm, and takes special care not to
>> deadlock while doing this.
>>
>> We need to communicate this to lockdep somehow.
>>
>
> I think Peter already annotated this in
> 454ed842d55740160334efc9ad56cfef54ed37bc .
>
>

Excellent, thanks for the info.

--
error compiling committee.c: too many arguments to function