From: "Andres Lagar-Cavilla" <andres@lagarcavilla.org>
To: "Hao, Xudong" <xudong.hao@intel.com>
Cc: Keir Fraser <keir@xen.org>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Tim Deegan <tim@xen.org>,
"Zhang, Xiantao" <xiantao.zhang@intel.com>,
"JBeulich@suse.com" <jbeulich@suse.com>
Subject: Re: Deadlocks by p2m_lock and event_lock
Date: Fri, 9 Mar 2012 08:29:27 -0800 [thread overview]
Message-ID: <763b511f59616a274ff142d62f55f7bf.squirrel@webmail.lagarcavilla.org> (raw)
In-Reply-To: <403610A45A2B5242BD291EDAE8B37D300FCE32B2@SHSMSX102.ccr.corp.intel.com>
>
>> -----Original Message-----
>> From: Tim Deegan [mailto:tim@xen.org]
>> Sent: Friday, March 09, 2012 7:20 PM
>> To: Hao, Xudong
>> Cc: JBeulich@suse.com; Andres Lagar-Cavilla;
>> xen-devel@lists.xensource.com;
>> Keir Fraser; Zhang, Xiantao
>> Subject: Re: [Xen-devel] Deadlocks by p2m_lock and event_lock
>>
>> Hi,
>>
>> At 10:58 +0000 on 09 Mar (1331290728), Hao, Xudong wrote:
>> > ====CPU0===
>> > map_domain_pirq() Grab event_lock
>> > /
>> > Pci_enable_msi()
>> > /
>> > msix_capability_init()
>> > /
>> > p2m_change_entry_type_global() Trying to acquire p2m_lock
>> >
>> > ====CPU9===
>> > hvm_hap_nested_page_fault() -> get_gfn_type_access() Grab p2m_lock
>> > /
>> > handle_mmio()
>> > /
>> > ...
>> > /
>> > notify_via_xen_event_channel() Trying to acquire event_lock
>> >
>> >
>> > The event_lock is used anywhere in Xen, I only have a patch of
>> workaround
>> this issue for proposal, but not for the final fix. Any good suggestion?
>> >
>> > diff -r f61120046915 xen/arch/x86/irq.c
>> > --- a/xen/arch/x86/irq.c Wed Mar 07 11:50:31 2012 +0100
>> > +++ b/xen/arch/x86/irq.c Sat Mar 10 02:06:18 2012 +0800
>> > @@ -1875,10 +1875,12 @@ int map_domain_pirq(
>> > if ( !cpu_has_apic )
>> > goto done;
>> >
>> > + spin_unlock(&d->event_lock);
>> > pdev = pci_get_pdev(msi->seg, msi->bus, msi->devfn);
>> > ret = pci_enable_msi(msi, &msi_desc);
>> > if ( ret )
>> > goto done;
>> > + spin_lock(&d->event_lock);
>> >
>> > spin_lock_irqsave(&desc->lock, flags);
>> >
>> > Best Regards,
>> > Xudong Hao
>>
>> I don't know about the event lock, but it seems unwise to call in to
>> handle_mmio with a gfn lock held. How about fixing the other path?
>>
>> diff -r 04673ecb9d78 xen/arch/x86/hvm/hvm.c
>> --- a/xen/arch/x86/hvm/hvm.c Thu Mar 08 16:40:05 2012 +0000
>> +++ b/xen/arch/x86/hvm/hvm.c Fri Mar 09 11:15:25 2012 +0000
>> @@ -1324,10 +1324,11 @@ int hvm_hap_nested_page_fault(unsigned l
>> if ( (p2mt == p2m_mmio_dm) ||
>> (access_w && (p2mt == p2m_ram_ro)) )
>> {
>> + put_gfn(p2m->domain, gfn);
>> if ( !handle_mmio() )
>> hvm_inject_exception(TRAP_gp_fault, 0, 0);
>> rc = 1;
>> - goto out_put_gfn;
>> + goto out;
>> }
>>
>> #ifdef __x86_64__
>> @@ -1379,6 +1380,7 @@ int hvm_hap_nested_page_fault(unsigned l
>>
>> out_put_gfn:
>> put_gfn(p2m->domain, gfn);
>> +out:
>> if ( paged )
>> p2m_mem_paging_populate(v->domain, gfn);
>> if ( req_ptr )
>
> Yes, that's fine to release the p2m lock earlier than handle_mmio.
Ack
Thanks,
Andres
>
next prev parent reply other threads:[~2012-03-09 16:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 10:58 Deadlocks by p2m_lock and event_lock Hao, Xudong
2012-03-09 11:20 ` Tim Deegan
2012-03-09 11:44 ` Hao, Xudong
2012-03-09 16:29 ` Andres Lagar-Cavilla [this message]
2012-03-09 16:55 ` Tim Deegan
2012-03-13 7:51 ` Hao, Xudong
2012-03-13 15:27 ` Andres Lagar-Cavilla
2012-03-13 18:26 ` Andres Lagar-Cavilla
2012-03-14 9:20 ` Jan Beulich
2012-03-14 14:18 ` Andres Lagar-Cavilla
2012-03-13 18:45 ` Andres Lagar-Cavilla
2012-03-14 7:12 ` Hao, Xudong
2012-03-14 8:28 ` Zhang, Yang Z
2012-03-14 14:20 ` Andres Lagar-Cavilla
2012-03-14 15:10 ` Andres Lagar-Cavilla
2012-03-15 2:19 ` Hao, Xudong
2012-03-15 3:37 ` Andres Lagar-Cavilla
2012-03-15 10:44 ` Tim Deegan
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=763b511f59616a274ff142d62f55f7bf.squirrel@webmail.lagarcavilla.org \
--to=andres@lagarcavilla.org \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xensource.com \
--cc=xiantao.zhang@intel.com \
--cc=xudong.hao@intel.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 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.