xen/evtchn: Alter free_xen_event_channel() to take a domain rather than vcpu
PATCH 1/1 xen/evtchn: Alter free_xen_event_channel() to take a domain rather than vcpu
The resource behind an event channel is domain centric rather than vcpu centric, and free_xen_event_channel() only follows the vcpu's domain pointer.
This change allows mem_event_disable() to avoid arbitrarily referencing d->vcpu[0] just to pass the domain.
No functional change.
--- xen/arch/x86/hvm/hvm.c | 12 ++++++------ xen/common/event_channel.c | 4 +--- xen/common/mem_event.c | 2 +- xen/include/xen/event.h | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-)
xen/arch/x86/hvm/hvm.c +6 -6
@@ -647,7 +647,7 @@ static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s,return 0 ; fail3: -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn); fail2:spin_unlock (&s->lock);
@@ -674,9 +674,9 @@ static void hvm_ioreq_server_remove_vcpu(struct hvm_ioreq_server *s,list_del (&sv->list_entry);if ( v->vcpu_id ==0 && s->bufioreq.va !=NULL ) -free_xen_event_channel (v, s->bufioreq_evtchn); +free_xen_event_channel (v->domain, s->bufioreq_evtchn); -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn);xfree (sv);break ;
@@ -701,9 +701,9 @@ static void hvm_ioreq_server_remove_all_vcpus(struct hvm_ioreq_server *s)list_del (&sv->list_entry);if ( v->vcpu_id ==0 && s->bufioreq.va !=NULL ) -free_xen_event_channel (v, s->bufioreq_evtchn); +free_xen_event_channel (v->domain, s->bufioreq_evtchn); -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn);xfree (sv); }
@@ -1333,7 +1333,7 @@ static int hvm_replace_event_channel(struct vcpu *v, domid_t remote_domid,/* xchg() ensures that only we call free_xen_event_channel(). */ old_port =xchg (p_port, new_port); -free_xen_event_channel (v, old_port); +free_xen_event_channel (v->domain, old_port);return 0 ; }
xen/common/event_channel.c +1 -3
@@ -1173,11 +1173,9 @@ int alloc_unbound_xen_event_channel( } -void free_xen_event_channel ( -struct vcpu *local_vcpu,int port) +void free_xen_event_channel (struct domain *d,int port) {struct evtchn *chn; -struct domain *d = local_vcpu->domain;spin_lock (&d->event_lock);
xen/common/mem_event.c +1 -1
@@ -221,7 +221,7 @@ static int mem_event_disable(struct domain *d, struct mem_event_domain *med) }/* Free domU's event channel and leave the other one unbound */ -free_xen_event_channel (d->vcpu[0 ], med->xen_port); +free_xen_event_channel (d, med->xen_port);/* Unblock all vCPUs */ for_each_vcpu ( d, v )
xen/include/xen/event.h +1 -2
@@ -60,8 +60,7 @@ typedef void (*xen_event_channel_notification_t)(int alloc_unbound_xen_event_channel (struct vcpu *local_vcpu,domid_t remote_domid,xen_event_channel_notification_t notification_fn); -void free_xen_event_channel ( -struct vcpu *local_vcpu,int port); +void free_xen_event_channel (struct domain *d,int port);/* Query if event channel is in use by the guest */ int guest_enabled_event (struct vcpu *v,uint32_t virq);
Signature · 1 line
1.7.10.4
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Andrew Cooper
Sent: 12 January 2015 09:47
To: Xen-devel
Cc: Andrew Cooper; Keir (Xen.org); Jan Beulich
Subject: [Xen-devel] [PATCH] xen/evtchn: Alterfree_xen_event_channel()to take a domain rather than vcpuThe resource behind an event channel is domain centric rather than vcpu centric, and
free_xen_event_channel()only follows the vcpu's domain pointer.
Quoted 8 lines
This change allows
mem_event_disable()to avoid arbitrarily referencing d->vcpu[0] just to pass the domain.No functional change.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>
Quoted 110 lines
--- xen/arch/x86/hvm/hvm.c | 12 ++++++------ xen/common/event_channel.c | 4 +--- xen/common/mem_event.c | 2 +- xen/include/xen/event.h | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-)xen/arch/x86/hvm/hvm.c +1
-1@@ -647,7 +647,7 @@ static int hvm_ioreq_server_add_vcpu(structhvm_ioreq_server *s, return 0; fail3: -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn); fail2:spin_unlock(&s->lock);xen/arch/x86/hvm/hvm.c +2
-2@@ -674,9 +674,9 @@ static void hvm_ioreq_server_remove_vcpu(struct hvm_ioreq_server *s,list_del (&sv->list_entry);if ( v->vcpu_id ==0 && s->bufioreq.va !=NULL ) -free_xen_event_channel (v, s->bufioreq_evtchn); +free_xen_event_channel (v->domain, s->bufioreq_evtchn); -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn);xfree (sv);break;xen/arch/x86/hvm/hvm.c +2
-2@@ -701,9 +701,9 @@ static void hvm_ioreq_server_remove_all_vcpus(struct hvm_ioreq_server *s) list_del(&sv->list_entry);if ( v->vcpu_id ==0 && s->bufioreq.va !=NULL ) -free_xen_event_channel (v, s->bufioreq_evtchn); +free_xen_event_channel (v->domain, s->bufioreq_evtchn); -free_xen_event_channel (v, sv->ioreq_evtchn); +free_xen_event_channel (v->domain, sv->ioreq_evtchn);xfree (sv);}xen/arch/x86/hvm/hvm.c +1
-1@@ -1333,7 +1333,7 @@ static int hvm_replace_event_channel(struct vcpu *v, domid_t remote_domid,/* xchg() ensures that only we call free_xen_event_channel(). */ old_port =xchg (p_port, new_port); -free_xen_event_channel (v, old_port); +free_xen_event_channel (v->domain, old_port);return 0 ; }xen/common/event_channel.c +1
-3@@ -1173,11 +1173,9 @@ int alloc_unbound_xen_event_channel( } -void free_xen_event_channel ( -struct vcpu *local_vcpu,int port) +void free_xen_event_channel (struct domain *d,int port) {struct evtchn *chn; -struct domain *d = local_vcpu->domain;spin_lock (&d->event_lock);xen/common/mem_event.c +1
-1@@ -221,7 +221,7 @@ static int mem_event_disable(struct domain *d, struct mem_event_domain *med) }/* Free domU's event channel and leave the other one unbound */ -free_xen_event_channel (d->vcpu[0 ], med->xen_port); +free_xen_event_channel (d, med->xen_port);/* Unblock all vCPUs */
for_each_vcpu( d, v )xen/include/xen/event.h +1
-3@@ -60,8 +60,7 @@ typedef void (*xen_event_channel_notification_t)(int alloc_unbound_xen_event_channel (struct vcpu *local_vcpu,domid_t remote_domid,xen_event_channel_notification_t notification_fn); -void free_xen_event_channel ( -struct vcpu *local_vcpu,int port); +void free_xen_event_channel (struct domain *d,int port);/* Query if event channel is in use by the guest */ int guest_enabled_event (struct vcpu *v,uint32_t virq); --1.7.10.4
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.01.15 at 10:46, <[email protected]> wrote:
The resource behind an event channel is domain centric rather than vcpu centric, and
free_xen_event_channel()only follows the vcpu's domain pointer.
I wonder whether for symmetry alloc_unbound_xen_event_channel() shouldn't then also take a [struct domain *, unsigned int vcpu_id] pair instead of a struct vcpu *.
Jan
Quoted 7 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.01.15 at 10:46, <[email protected]> wrote:
The resource behind an event channel is domain centric rather than vcpu centric, and
free_xen_event_channel()only follows the vcpu's domain pointer.I wonder whether for symmetry
alloc_unbound_xen_event_channel()shouldn't then also take a [struct domain *, unsigned intvcpu_id] pair instead of a struct vcpu *.
Sounds like a good idea - I will do that for v2.
~Andrew