From: MaoXiaoyun Subject: RE: Re: VM hung after running sometime Date: Wed, 22 Sep 2010 08:02:09 +0800 Message-ID: References: , <4C98EB42.4020808@goop.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1907809294==" Return-path: In-Reply-To: <4C98EB42.4020808@goop.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: jeremy@goop.org, keir.fraser@eu.citrix.com Cc: xen devel List-Id: xen-devel@lists.xenproject.org --===============1907809294== Content-Type: multipart/alternative; boundary="_b4ab99ca-c030-4b6a-8359-bf2cfdedc612_" --_b4ab99ca-c030-4b6a-8359-bf2cfdedc612_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Thanks Jeremy. =20 Regards to fix you mentioned, did you mean the patch I searched and paste= d below, if so, it this all what I need? For irqbalance disabled, I am afried it might have negative performance i= mpact, right? =20 ------------------------------------------------------- diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 32f4a2c..06fc991 100644 (file) --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -368,7 +368,7 @@ int bind_evtchn_to_irq(unsigned int evtchn) irq =3D find_unbound_irq(); =20 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip, - handle_level_irq, "event"); + handle_edge_irq, "event"); =20 evtchn_to_irq[evtchn] =3D irq; irq_info[irq] =3D mk_evtchn_info(evtchn); > Date: Tue, 21 Sep 2010 10:28:34 -0700 > From: jeremy@goop.org > To: keir.fraser@eu.citrix.com > CC: tinnycloud@hotmail.com; xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] Re: VM hung after running sometime >=20 > On 09/21/2010 12:53 AM, Keir Fraser wrote: > > On 21/09/2010 06:02, "MaoXiaoyun" wrote: > > > >> Take a look at domain 0 event channel with port 105,106, I find on p= ort 105, > >> it pending is > >> 1.(in [1,0], first bit refer to pending, and is 1, second bit refer = to mask, > >> is 0). > >>=20 > >> (XEN) 105 [1/0]: s=3D3 n=3D2 d=3D10 p=3D1 x=3D0 > >> (XEN) 106 [0/0]: s=3D3 n=3D2 d=3D10 p=3D2 x=3D0 > >>=20 > >> In all, we have domain U cpu blocking on _VPF_blocked_in_xen, and it= must set > >> the pending bit. > >> Consider pending is 1, it looks like the irq is not triggered, am I = right ? > >> Since if it is triggerred, it should clear the pending bit. (line 36= 1). > > Yes it looks like dom0 is not handling the event for some reason. Qem= u looks > > like it still works and is waiting for a notification via select(). B= ut that > > won't happen until dom0 kernel handles the event as an IRQ and calls = the > > relevant irq handler (drivers/xen/evtchn.c:evtchn_interrupt()). > > > > I think you're on the right track in your debugging. I don't know muc= h about > > the pv_ops irq handling path, except to say that this aspect is diffe= rent > > than non-pv_ops kernels which special-case handling of events bound t= o > > user-space rather more. So at the moment my best guess would be that = the bug > > is in the pv_ops kernel irq handling for this type of user-space-boun= d > > event. >=20 > We no longer use handle_level_irq because there's a race which loses > events when interrupt migration is enabled. Current xen/stable-2.6.32.x > has a proper fix for this, but the quick workaround is to disable > irqbalanced. >=20 > J >=20 > > -- Keir > > > >> ------------------------------/linux-2.6-pvops.git/kernel/irq/chip.c= --- > >> 354 void > >> 355 handle_level_irq(unsigned int irq, struct irq_desc *desc) > >> 356 { > >> 357 struct irqaction *action; > >> 358 irqreturn_t action_ret; > >> 359=20 > >> 360 spin_lock(&desc->lock); > >> 361 mask_ack_irq(desc, irq); > >> 362=20 > >> 363 if (unlikely(desc->status & IRQ_INPROGRESS)) > >> 364 goto out_unlock; > >> 365 desc->status &=3D ~(IRQ_REPLAY | IRQ_WAITING); > >> 366 kstat_incr_irqs_this_cpu(irq, desc); > >> 367=20 > >>=20 > >> BTW, the qemu still works fine when VM is hang. Below is it strace o= utput. > >> No much difference between other well worked qemu instance, other th= an select > >> all Timeout. > >> ------------------- > >> select(14, [3 7 11 12 13], [], [], {0, 10000}) =3D 0 (Timeout) > >> clock_gettime(CLOCK_MONOTONIC, {673470, 59535265}) =3D 0 > >> clock_gettime(CLOCK_MONOTONIC, {673470, 59629728}) =3D 0 > >> clock_gettime(CLOCK_MONOTONIC, {673470, 59717700}) =3D 0 > >> clock_gettime(CLOCK_MONOTONIC, {673470, 59806552}) =3D 0 > >> select(14, [3 7 11 12 13], [], [], {0, 10000}) =3D 0 (Timeout) > >> clock_gettime(CLOCK_MONOTONIC, {673470, 70234406}) =3D 0 > >> clock_gettime(CLOCK_MONOTONIC, {673470, 70332116}) =3D 0 > >> clock_gettime(CLOCK_MONOTONIC, {673470, 70419835}) =3D 0 > >>=20 > >>=20 > >>=20 > >>=20 > >>> Date: Mon, 20 Sep 2010 10:35:46 +0100 > >>> Subject: Re: VM hung after running sometime > >>> From: keir.fraser@eu.citrix.com > >>> To: tinnycloud@hotmail.com > >>> CC: xen-devel@lists.xensource.com; jbeulich@novell.com > >>> > >>> On 20/09/2010 10:15, "MaoXiaoyun" wrote: > >>> > >>>> Thanks Keir. > >>>> > >>>> You're right, after I deeply looked into the wait_on_xen_event_cha= nnel, it > >>>> is > >>>> smart enough > >>>> to avoid the race I assumed. > >>>> > >>>> How about prepare_wait_on_xen_event_channel ? > >>>> Currently Istill don't know when it will be invoked. > >>>> Could enlighten me? > >>> As you can see it is called from hvm_send_assist_req(), hence it is= called > >>> whenever an ioreq is sent to qemu-dm. Note that it is called *befor= e* > >>> qemu-dm is notified -- hence it cannot race the wakeup from qemu, a= s we will > >>> not get woken until qemu-dm has done the work, and it cannot start = the work > >>> until it is notified, and it is not notified until after > >>> prepare_wait_on_xen_event_channel has been executed. > >>> > >>> -- Keir > >>> > >>>>> Date: Mon, 20 Sep 2010 08:45:21 +0100 > >>>>> Subject: Re: VM hung after running sometime > >>>>> From: keir.fraser@eu.citrix.com > >>>>> To: tinnycloud@hotmail.com > >>>>> CC: xen-devel@lists.xensource.com; jbeulich@novell.com > >>>>> > >>>>> On 20/09/2010 07:00, "MaoXiaoyun" wrote: > >>>>> > >>>>>> When IO is not ready, domain U in VMEXIT->hvm_do_resume might in= voke > >>>>>> wait_on_xen_event_channel > >>>>>> (where it is blocked in _VPF_blocked_in_xen). > >>>>>> > >>>>>> Here is my assumption of event missed. > >>>>>> > >>>>>> step 1: hvm_do_resume execute 260, and suppose p->state is > >>>>>> STATE_IOREQ_READY > >>>>>> or STATE_IOREQ_INPROCESS > >>>>>> step 2: then in cpu_handle_ioreq is in line 547, it execute line= 548 so > >>>>>> quickly before hvm_do_resume execute line 270. > >>>>>> Well, the event is missed. > >>>>>> In other words, the _VPF_blocked_in_xen is cleared before it is = actually > >>>>>> setted, and Domian U who is blocked > >>>>>> might never get unblocked, it this possible? > >>>>> Firstly, that code is very paranoid and it should never actually = be the > >>>>> case > >>>>> that we see STATE_IOREQ_READY or STATE_IOREQ_INPROCESS in hvm_do_= resume(). > >>>>> Secondly, even if you do, take a look at the implementation of > >>>>> wait_on_xen_event_channel() -- it is smart enough to avoid the ra= ce you > >>>>> mention. > >>>>> > >>>>> -- Keir > >>>>> > >>>>> > >>> > >>=20 > > > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > > >=20 =20 --_b4ab99ca-c030-4b6a-8359-bf2cfdedc612_ Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable Thanks Jeremy.
 
Regards to fix you mentioned, did you mean the patch I searched and paste= d below, if so, it this all what I need?
For irqbalance disabled= , I am afried it might have negative performance impact, right?  
-------------------------------------------------------
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 32f4a2c..06fc991 100644 = (file)
@@ -368,7 +368,7 @@=  int bind_evtchn_to_irq(unsigned&n= bsp;int evtchn)
         &= nbsp;      irq =3D find_unbound_i= rq();
 
         &= nbsp;      set_irq_chip_and_handler_name(ir= q, &xen_dynamic_chip,
-        =             &= nbsp;           &n= bsp;           &nb= sp;handle_level_irq, "event");
+        =             &= nbsp;           &n= bsp;           &nb= sp;handle_edge_irq, "event");
 
         &= nbsp;      evtchn_to_irq[evtchn] =3D&n= bsp;irq;
         &= nbsp;      irq_info[irq] =3D mk_e= vtchn_info(evtchn);
 
> Date: Tue, 21 Sep 2010 10:28:34 -0700<= BR>> From: jeremy@goop.org
> To: keir.fraser@eu.citrix.com
&g= t; CC: tinnycloud@hotmail.com; xen-devel@lists.xensource.com
> Subj= ect: Re: [Xen-devel] Re: VM hung after running sometime
>
> = On 09/21/2010 12:53 AM, Keir Fraser wrote:
> > On 21/09/2010 06:= 02, "MaoXiaoyun" <tinnycloud@hotmail.com> wrote:
> >
&g= t; >> Take a look at domain 0 event channel with port 105,106, I fi= nd on port 105,
> >> it pending is
> >> 1.(in [1,= 0], first bit refer to pending, and is 1, second bit refer to mask,
&g= t; >> is 0).
> >>
> >> (XEN) 105 [1/0]: s=3D= 3 n=3D2 d=3D10 p=3D1 x=3D0
> >> (XEN) 106 [0/0]: s=3D3 n=3D2 = d=3D10 p=3D2 x=3D0
> >>
> >> In all, we have dom= ain U cpu blocking on _VPF_blocked_in_xen, and it must set
> >&g= t; the pending bit.
> >> Consider pending is 1, i t looks like the irq is not triggered, am I right ?
> >> Sin= ce if it is triggerred, it should clear the pending bit. (line 361).
&= gt; > Yes it looks like dom0 is not handling the event for some reason= . Qemu looks
> > like it still works and is waiting for a notifi= cation via select(). But that
> > won't happen until dom0 kernel= handles the event as an IRQ and calls the
> > relevant irq hand= ler (drivers/xen/evtchn.c:evtchn_interrupt()).
> >
> > = I think you're on the right track in your debugging. I don't know much ab= out
> > the pv_ops irq handling path, except to say that this as= pect is different
> > than non-pv_ops kernels which special-case= handling of events bound to
> > user-space rather more. So at t= he moment my best guess would be that the bug
> > is in the pv_o= ps kernel irq handling for this type of user-space-bound
> > eve= nt.
>
> We no longer use hand le_level_irq because there's a race which loses
> events when inte= rrupt migration is enabled. Current xen/stable-2.6.32.x
> has a pro= per fix for this, but the quick workaround is to disable
> irqbalan= ced.
>
> J
>
> > -- Keir
> >
>= ; >> ------------------------------/linux-2.6-pvops.git/kernel/irq/= chip.c---
> >> 354 void
> >> 355 handle_level_irq= (unsigned int irq, struct irq_desc *desc)
> >> 356 {
> = >> 357 struct irqaction *action;
> >> 358 irqreturn_t a= ction_ret;
> >> 359
> >> 360 spin_lock(&desc= ->lock);
> >> 361 mask_ack_irq(desc, irq);
> >>= ; 362
> >> 363 if (unlikely(desc->status & IRQ_INPROG= RESS))
> >> 364 goto out_unlock;
> >> 365 desc-&g= t;status &=3D ~(IRQ_REPLAY | IRQ_WAITING);
> >> 366 kstat= _incr_irqs_this_cpu(irq, desc);
> > > 367
> >>
> >> BTW, the qemu still works f= ine when VM is hang. Below is it strace output.
> >> No much = difference between other well worked qemu instance, other than select
= > >> all Timeout.
> >> -------------------
> &= gt;> select(14, [3 7 11 12 13], [], [], {0, 10000}) =3D 0 (Timeout)> >> clock_gettime(CLOCK_MONOTONIC, {673470, 59535265}) =3D 0> >> clock_gettime(CLOCK_MONOTONIC, {673470, 59629728}) =3D 0<= BR>> >> clock_gettime(CLOCK_MONOTONIC, {673470, 59717700}) =3D 0=
> >> clock_gettime(CLOCK_MONOTONIC, {673470, 59806552}) =3D = 0
> >> select(14, [3 7 11 12 13], [], [], {0, 10000}) =3D 0 (= Timeout)
> >> clock_gettime(CLOCK_MONOTONIC, {673470, 7023440= 6}) =3D 0
> >> clock_gettime(CLOCK_MONOTONIC, {673470, 703321= 16}) =3D 0
> >> clock_gettime(CLOCK_MONOTONIC, {673470, 70419= 835}) =3D 0
> >>
> >>
> > >
> >>
> >>> Date: Mon, 20 Sep 2010 10:3= 5:46 +0100
> >>> Subject: Re: VM hung after running someti= me
> >>> From: keir.fraser@eu.citrix.com
> >>&= gt; To: tinnycloud@hotmail.com
> >>> CC: xen-devel@lists.x= ensource.com; jbeulich@novell.com
> >>>
> >>&g= t; On 20/09/2010 10:15, "MaoXiaoyun" <tinnycloud@hotmail.com> wrote= :
> >>>
> >>>> Thanks Keir.
> >= >>>
> >>>> You're right, after I deeply looked= into the wait_on_xen_event_channel, it
> >>>> is
&g= t; >>>> smart enough
> >>>> to avoid the ra= ce I assumed.
> >>>>
> >>>> How about= prepare_wait_on_xen_event_channel ?
> >>>> Currently I= still don't know when it will be invoked.
> >>>> Could = enlighten me?
> >>> As you=20 can see it is called from hvm_send_assist_req(), hence it is called
&= gt; >>> whenever an ioreq is sent to qemu-dm. Note that it is ca= lled *before*
> >>> qemu-dm is notified -- hence it cannot= race the wakeup from qemu, as we will
> >>> not get woken= until qemu-dm has done the work, and it cannot start the work
> &g= t;>> until it is notified, and it is not notified until after
&g= t; >>> prepare_wait_on_xen_event_channel has been executed.
&= gt; >>>
> >>> -- Keir
> >>>
>= ; >>>>> Date: Mon, 20 Sep 2010 08:45:21 +0100
> >= >>>> Subject: Re: VM hung after running sometime
> >= >>>> From: keir.fraser@eu.citrix.com
> >>>>= > To: tinnycloud@hotmail.com
> >>>>> CC: xen-deve= l@lists.xensource.com; jbeulich@novell.com
> >>>>>> >>>>> On 20/09/2010=20 07:00, "MaoXiaoyun" <tinnycloud@hotmail.com> wrote:
> >&g= t;>>>
> >>>>>> When IO is not ready, dom= ain U in VMEXIT->hvm_do_resume might invoke
> >>>>&g= t;> wait_on_xen_event_channel
> >>>>>> (where = it is blocked in _VPF_blocked_in_xen).
> >>>>>>> >>>>>> Here is my assumption of event missed.> >>>>>>
> >>>>>> step 1: h= vm_do_resume execute 260, and suppose p->state is
> >>>= >>> STATE_IOREQ_READY
> >>>>>> or STATE_= IOREQ_INPROCESS
> >>>>>> step 2: then in cpu_hand= le_ioreq is in line 547, it execute line 548 so
> >>>>&= gt;> quickly before hvm_do_resume execute line 270.
> >>&g= t;>>> Well, the event is missed.
> >>>>>>= ; In other words, the _VPF_blocked_in_xen=20 is cleared before it is actually
> >>>>>> setted= , and Domian U who is blocked
> >>>>>> might neve= r get unblocked, it this possible?
> >>>>> Firstly, = that code is very paranoid and it should never actually be the
> &g= t;>>>> case
> >>>>> that we see STATE_IO= REQ_READY or STATE_IOREQ_INPROCESS in hvm_do_resume().
> >>&g= t;>> Secondly, even if you do, take a look at the implementation of=
> >>>>> wait_on_xen_event_channel() -- it is smart = enough to avoid the race you
> >>>>> mention.
>= ; >>>>>
> >>>>> -- Keir
> >&= gt;>>>
> >>>>>
> >>>
>= >>
> >
> >
> > _______________________= ________________________
> > Xen-devel mailing list
> >= Xen-devel@lists.xensource.com
> > ; http://lists.xensource.com/xen-devel
> >
>
= --_b4ab99ca-c030-4b6a-8359-bf2cfdedc612_-- --===============1907809294== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1907809294==--