From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] evtchn: simplify sending of notifications Date: Mon, 12 Jan 2015 08:57:16 +0000 Message-ID: <54B39A7C020000780005382E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part7F4A957C.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YAaoN-0005z4-TP for xen-devel@lists.xenproject.org; Mon, 12 Jan 2015 08:57:24 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part7F4A957C.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The trivial wrapper evtchn_set_pending() is pretty pointless, as it only serves to invoke another wrapper evtchn_port_set_pending(). In turn, the latter is kind of inconsistent with its siblings in that is takes a struct vcpu * rather than a struct domain * - adjusting this allows for more efficient code in the majority of cases. Signed-off-by: Jan Beulich --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -95,8 +95,6 @@ static uint8_t get_xen_consumer(xen_even /* Get the notification function for a given Xen-bound event channel. */ #define xen_notification_fn(e) (xen_consumers[(e)->xen_consumer-1]) =20 -static void evtchn_set_pending(struct vcpu *v, int port); - static int virq_is_global(uint32_t virq) { int rc; @@ -287,7 +285,7 @@ static long evtchn_bind_interdomain(evtc * We may have lost notifications on the remote unbound port. Fix = that up * here by conservatively always setting a notification on the local = port. */ - evtchn_set_pending(ld->vcpu[lchn->notify_vcpu_id], lport); + evtchn_port_set_pending(ld, lchn->notify_vcpu_id, lchn); =20 bind->local_port =3D lport; =20 @@ -599,11 +597,10 @@ static long evtchn_close(evtchn_close_t=20 return __evtchn_close(current->domain, close->port); } =20 -int evtchn_send(struct domain *d, unsigned int lport) +int evtchn_send(struct domain *ld, unsigned int lport) { struct evtchn *lchn, *rchn; - struct domain *ld =3D d, *rd; - struct vcpu *rvcpu; + struct domain *rd; int rport, ret =3D 0; =20 spin_lock(&ld->event_lock); @@ -633,14 +630,13 @@ int evtchn_send(struct domain *d, unsign rd =3D lchn->u.interdomain.remote_dom; rport =3D lchn->u.interdomain.remote_port; rchn =3D evtchn_from_port(rd, rport); - rvcpu =3D rd->vcpu[rchn->notify_vcpu_id]; if ( consumer_is_xen(rchn) ) - (*xen_notification_fn(rchn))(rvcpu, rport); + xen_notification_fn(rchn)(rd->vcpu[rchn->notify_vcpu_id], = rport); else - evtchn_set_pending(rvcpu, rport); + evtchn_port_set_pending(rd, rchn->notify_vcpu_id, rchn); break; case ECS_IPI: - evtchn_set_pending(ld->vcpu[lchn->notify_vcpu_id], lport); + evtchn_port_set_pending(ld, lchn->notify_vcpu_id, lchn); break; case ECS_UNBOUND: /* silently drop the notification */ @@ -655,11 +651,6 @@ out: return ret; } =20 -static void evtchn_set_pending(struct vcpu *v, int port) -{ - evtchn_port_set_pending(v, evtchn_from_port(v->domain, port)); -} - int guest_enabled_event(struct vcpu *v, uint32_t virq) { return ((v !=3D NULL) && (v->virq_to_evtchn[virq] !=3D 0)); @@ -669,6 +660,7 @@ void send_guest_vcpu_virq(struct vcpu *v { unsigned long flags; int port; + struct domain *d; =20 ASSERT(!virq_is_global(virq)); =20 @@ -678,7 +670,8 @@ void send_guest_vcpu_virq(struct vcpu *v if ( unlikely(port =3D=3D 0) ) goto out; =20 - evtchn_set_pending(v, port); + d =3D v->domain; + evtchn_port_set_pending(d, v->vcpu_id, evtchn_from_port(d, port)); =20 out: spin_unlock_irqrestore(&v->virq_lock, flags); @@ -707,7 +700,7 @@ static void send_guest_global_virq(struc goto out; =20 chn =3D evtchn_from_port(d, port); - evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port); + evtchn_port_set_pending(d, chn->notify_vcpu_id, chn); =20 out: spin_unlock_irqrestore(&v->virq_lock, flags); @@ -731,7 +724,7 @@ void send_guest_pirq(struct domain *d, c } =20 chn =3D evtchn_from_port(d, port); - evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port); + evtchn_port_set_pending(d, chn->notify_vcpu_id, chn); } =20 static struct domain *global_virq_handlers[NR_VIRQS] __read_mostly; @@ -1202,7 +1195,6 @@ void notify_via_xen_event_channel(struct { struct evtchn *lchn, *rchn; struct domain *rd; - int rport; =20 spin_lock(&ld->event_lock); =20 @@ -1219,9 +1211,8 @@ void notify_via_xen_event_channel(struct if ( likely(lchn->state =3D=3D ECS_INTERDOMAIN) ) { rd =3D lchn->u.interdomain.remote_dom; - rport =3D lchn->u.interdomain.remote_port; - rchn =3D evtchn_from_port(rd, rport); - evtchn_set_pending(rd->vcpu[rchn->notify_vcpu_id], rport); + rchn =3D evtchn_from_port(rd, lchn->u.interdomain.remote_port); + evtchn_port_set_pending(rd, rchn->notify_vcpu_id, rchn); } =20 spin_unlock(&ld->event_lock); --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -152,10 +152,11 @@ static inline void evtchn_port_init(stru d->evtchn_port_ops->init(d, evtchn); } =20 -static inline void evtchn_port_set_pending(struct vcpu *v, +static inline void evtchn_port_set_pending(struct domain *d, + unsigned int vcpu_id, struct evtchn *evtchn) { - v->domain->evtchn_port_ops->set_pending(v, evtchn); + d->evtchn_port_ops->set_pending(d->vcpu[vcpu_id], evtchn); } =20 static inline void evtchn_port_clear_pending(struct domain *d, --=__Part7F4A957C.1__= Content-Type: text/plain; name="evtchn-send-simplify.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="evtchn-send-simplify.patch" evtchn: simplify sending of notifications=0A=0AThe trivial wrapper = evtchn_set_pending() is pretty pointless, as it=0Aonly serves to invoke = another wrapper evtchn_port_set_pending(). In=0Aturn, the latter is kind = of inconsistent with its siblings in that is=0Atakes a struct vcpu * = rather than a struct domain * - adjusting this=0Aallows for more efficient = code in the majority of cases.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/common/event_channel.c=0A+++ b/xen/common/event_chan= nel.c=0A@@ -95,8 +95,6 @@ static uint8_t get_xen_consumer(xen_even=0A /* = Get the notification function for a given Xen-bound event channel. */=0A = #define xen_notification_fn(e) (xen_consumers[(e)->xen_consumer-1])=0A = =0A-static void evtchn_set_pending(struct vcpu *v, int port);=0A-=0A = static int virq_is_global(uint32_t virq)=0A {=0A int rc;=0A@@ -287,7 = +285,7 @@ static long evtchn_bind_interdomain(evtc=0A * We may have = lost notifications on the remote unbound port. Fix that up=0A * here = by conservatively always setting a notification on the local port.=0A = */=0A- evtchn_set_pending(ld->vcpu[lchn->notify_vcpu_id], lport);=0A+ = evtchn_port_set_pending(ld, lchn->notify_vcpu_id, lchn);=0A =0A = bind->local_port =3D lport;=0A =0A@@ -599,11 +597,10 @@ static long = evtchn_close(evtchn_close_t =0A return __evtchn_close(current->domain, = close->port);=0A }=0A =0A-int evtchn_send(struct domain *d, unsigned int = lport)=0A+int evtchn_send(struct domain *ld, unsigned int lport)=0A {=0A = struct evtchn *lchn, *rchn;=0A- struct domain *ld =3D d, *rd;=0A- = struct vcpu *rvcpu;=0A+ struct domain *rd;=0A int = rport, ret =3D 0;=0A =0A spin_lock(&ld->event_lock);=0A@@ -633,14 = +630,13 @@ int evtchn_send(struct domain *d, unsign=0A rd =3D = lchn->u.interdomain.remote_dom;=0A rport =3D lchn->u.interdomain.re= mote_port;=0A rchn =3D evtchn_from_port(rd, rport);=0A- = rvcpu =3D rd->vcpu[rchn->notify_vcpu_id];=0A if ( consumer_is_xen(r= chn) )=0A- (*xen_notification_fn(rchn))(rvcpu, rport);=0A+ = xen_notification_fn(rchn)(rd->vcpu[rchn->notify_vcpu_id], rport);=0A = else=0A- evtchn_set_pending(rvcpu, rport);=0A+ = evtchn_port_set_pending(rd, rchn->notify_vcpu_id, rchn);=0A = break;=0A case ECS_IPI:=0A- evtchn_set_pending(ld->vcpu[lchn->no= tify_vcpu_id], lport);=0A+ evtchn_port_set_pending(ld, lchn->notify_= vcpu_id, lchn);=0A break;=0A case ECS_UNBOUND:=0A /* = silently drop the notification */=0A@@ -655,11 +651,6 @@ out:=0A = return ret;=0A }=0A =0A-static void evtchn_set_pending(struct vcpu *v, int = port)=0A-{=0A- evtchn_port_set_pending(v, evtchn_from_port(v->domain, = port));=0A-}=0A-=0A int guest_enabled_event(struct vcpu *v, uint32_t = virq)=0A {=0A return ((v !=3D NULL) && (v->virq_to_evtchn[virq] !=3D = 0));=0A@@ -669,6 +660,7 @@ void send_guest_vcpu_virq(struct vcpu *v=0A = {=0A unsigned long flags;=0A int port;=0A+ struct domain *d;=0A = =0A ASSERT(!virq_is_global(virq));=0A =0A@@ -678,7 +670,8 @@ void = send_guest_vcpu_virq(struct vcpu *v=0A if ( unlikely(port =3D=3D 0) = )=0A goto out;=0A =0A- evtchn_set_pending(v, port);=0A+ d = =3D v->domain;=0A+ evtchn_port_set_pending(d, v->vcpu_id, evtchn_from_po= rt(d, port));=0A =0A out:=0A spin_unlock_irqrestore(&v->virq_lock, = flags);=0A@@ -707,7 +700,7 @@ static void send_guest_global_virq(struc=0A = goto out;=0A =0A chn =3D evtchn_from_port(d, port);=0A- = evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);=0A+ evtchn_port_= set_pending(d, chn->notify_vcpu_id, chn);=0A =0A out:=0A spin_unlock_i= rqrestore(&v->virq_lock, flags);=0A@@ -731,7 +724,7 @@ void send_guest_pirq= (struct domain *d, c=0A }=0A =0A chn =3D evtchn_from_port(d, = port);=0A- evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);=0A+ = evtchn_port_set_pending(d, chn->notify_vcpu_id, chn);=0A }=0A =0A static = struct domain *global_virq_handlers[NR_VIRQS] __read_mostly;=0A@@ -1202,7 = +1195,6 @@ void notify_via_xen_event_channel(struct=0A {=0A struct = evtchn *lchn, *rchn;=0A struct domain *rd;=0A- int = rport;=0A =0A spin_lock(&ld->event_lock);=0A =0A@@ -1219,9 +1211,8 @@ = void notify_via_xen_event_channel(struct=0A if ( likely(lchn->state = =3D=3D ECS_INTERDOMAIN) )=0A {=0A rd =3D lchn->u.interdomain= .remote_dom;=0A- rport =3D lchn->u.interdomain.remote_port;=0A- = rchn =3D evtchn_from_port(rd, rport);=0A- evtchn_set_pending(rd-= >vcpu[rchn->notify_vcpu_id], rport);=0A+ rchn =3D evtchn_from_port(= rd, lchn->u.interdomain.remote_port);=0A+ evtchn_port_set_pending(rd= , rchn->notify_vcpu_id, rchn);=0A }=0A =0A spin_unlock(&ld->event_l= ock);=0A--- a/xen/include/xen/event.h=0A+++ b/xen/include/xen/event.h=0A@@ = -152,10 +152,11 @@ static inline void evtchn_port_init(stru=0A = d->evtchn_port_ops->init(d, evtchn);=0A }=0A =0A-static inline void = evtchn_port_set_pending(struct vcpu *v,=0A+static inline void evtchn_port_s= et_pending(struct domain *d,=0A+ = unsigned int vcpu_id,=0A struct = evtchn *evtchn)=0A {=0A- v->domain->evtchn_port_ops->set_pending(v, = evtchn);=0A+ d->evtchn_port_ops->set_pending(d->vcpu[vcpu_id], = evtchn);=0A }=0A =0A static inline void evtchn_port_clear_pending(struct = domain *d,=0A --=__Part7F4A957C.1__= 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.xen.org http://lists.xen.org/xen-devel --=__Part7F4A957C.1__=--