From: "Kasai Takanori" Subject: [PATCH] [PV-on-HVM] Process event channels notifications in round-robin order Date: Fri, 25 Jan 2008 19:41:44 +0900 Message-ID: <072e01c85f3e$e387d480$e16f210a@VF03007L> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_072B_01C85F8A.50FA0FB0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_072B_01C85F8A.50FA0FB0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit Hi All, It is corrected that the interrupt to the event channel goes up evenly for PV kernel. However, it has not been corrected in PV-on-HVM yet. It is corrected as follows for PV kernel. http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/7fe1c6d02a2b http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/b2768401db94 This patch is a correction the same for PV-on-HVM. Signed-off-by: Takanori Kasai Singed-off-by: Kouya Shimura Best Regard, -- Takanori Kasai ------=_NextPart_000_072B_01C85F8A.50FA0FB0 Content-Type: application/octet-stream; name="pv-on-hvm-evtchn-round-robin.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pv-on-hvm-evtchn-round-robin.patch" # HG changeset patch=0A= # User kasai.takanori@jp.fujitsu.com=0A= # Date 1201254403 -32400=0A= # Node ID 183f86ccb06e9afcc14a72853a9159cc56ba884a=0A= # Parent 31adb5c972d03e45cb746cd2305126ea2571282f=0A= PV-on-HVM: Process event channels notifications in round-robin order.=0A= =0A= Signed-off-by: Takanori Kasai =0A= Singed-off-by: Kouya Shimura =0A= =0A= diff -r 31adb5c972d0 -r 183f86ccb06e = unmodified_drivers/linux-2.6/platform-pci/evtchn.c=0A= --- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Thu Jan 24 = 14:41:26 2008 +0000=0A= +++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Fri Jan 25 = 18:46:43 2008 +0900=0A= @@ -254,6 +254,15 @@ void notify_remote_via_irq(int irq)=0A= }=0A= EXPORT_SYMBOL(notify_remote_via_irq);=0A= =0A= +static DEFINE_PER_CPU(unsigned int, last_processed_l1i) =3D { = BITS_PER_LONG - 1 };=0A= +static DEFINE_PER_CPU(unsigned int, last_processed_l2i) =3D { = BITS_PER_LONG - 1 };=0A= +=0A= +static inline unsigned long active_evtchns(unsigned int cpu, = shared_info_t *sh,=0A= + unsigned int idx)=0A= +{=0A= + return (sh->evtchn_pending[idx] & ~sh->evtchn_mask[idx]);=0A= +}=0A= +=0A= static irqreturn_t evtchn_interrupt(int irq, void *dev_id=0A= #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)=0A= , struct pt_regs *regs=0A= @@ -262,7 +271,8 @@ static irqreturn_t evtchn_interrupt(int =0A= #endif=0A= )=0A= {=0A= - unsigned int l1i, port;=0A= + unsigned int l1i, l2i, port;=0A= + unsigned long masked_l1, masked_l2;=0A= /* XXX: All events are bound to vcpu0 but irq may be redirected. */=0A= int cpu =3D 0; /*smp_processor_id();*/=0A= irq_handler_t handler;=0A= @@ -271,13 +281,42 @@ static irqreturn_t evtchn_interrupt(int =0A= unsigned long l1, l2;=0A= =0A= v->evtchn_upcall_pending =3D 0;=0A= - /* NB. No need for a barrier here -- XCHG is a barrier on x86. */=0A= +=0A= +#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on = x86. */=0A= + /* Clear master flag /before/ clearing selector flag. */=0A= + rmb();=0A= +#endif=0A= l1 =3D xchg(&v->evtchn_pending_sel, 0);=0A= +=0A= + l1i =3D per_cpu(last_processed_l1i, cpu);=0A= + l2i =3D per_cpu(last_processed_l2i, cpu);=0A= +=0A= while (l1 !=3D 0) {=0A= - l1i =3D __ffs(l1);=0A= - l1 &=3D ~(1 << l1i);=0A= - while ((l2 =3D s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i])) {=0A= - port =3D (l1i * BITS_PER_LONG) + __ffs(l2);=0A= +=0A= + l1i =3D (l1i + 1) % BITS_PER_LONG;=0A= + masked_l1 =3D l1 & ((~0UL) << l1i);=0A= +=0A= + if (masked_l1 =3D=3D 0) { /* if we masked out all events, wrap around = to the beginning */=0A= + l1i =3D BITS_PER_LONG - 1;=0A= + l2i =3D BITS_PER_LONG - 1;=0A= + continue;=0A= + }=0A= + l1i =3D __ffs(masked_l1);=0A= +=0A= + do {=0A= + l2 =3D active_evtchns(cpu, s, l1i);=0A= +=0A= + l2i =3D (l2i + 1) % BITS_PER_LONG;=0A= + masked_l2 =3D l2 & ((~0UL) << l2i);=0A= +=0A= + if (masked_l2 =3D=3D 0) { /* if we masked out all events, move on */=0A= + l2i =3D BITS_PER_LONG - 1;=0A= + break;=0A= + }=0A= + l2i =3D __ffs(masked_l2);=0A= +=0A= + /* process port */=0A= + port =3D (l1i * BITS_PER_LONG) + l2i;=0A= synch_clear_bit(port, &s->evtchn_pending[0]);=0A= =0A= irq =3D evtchn_to_irq[port];=0A= @@ -303,7 +342,16 @@ static irqreturn_t evtchn_interrupt(int =0A= spin_lock(&irq_evtchn[irq].lock);=0A= irq_evtchn[irq].in_handler =3D 0;=0A= spin_unlock(&irq_evtchn[irq].lock);=0A= - }=0A= +=0A= + /* if this is the final port processed, we'll pick up here+1 next = time */=0A= + per_cpu(last_processed_l1i, cpu) =3D l1i;=0A= + per_cpu(last_processed_l2i, cpu) =3D l2i;=0A= +=0A= + } while (l2i !=3D BITS_PER_LONG - 1);=0A= +=0A= + l2 =3D active_evtchns(cpu, s, l1i);=0A= + if (l2 =3D=3D 0) /* we handled all ports, so we can clear the = selector bit */=0A= + l1 &=3D ~(1UL << l1i);=0A= }=0A= =0A= return IRQ_HANDLED;=0A= ------=_NextPart_000_072B_01C85F8A.50FA0FB0 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 ------=_NextPart_000_072B_01C85F8A.50FA0FB0--