evtchn: (not so) recent XSAs follow-on
v5 cover evtchn: (not so) recent XSAs follow-on
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper for port_is_valid() + evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()
Jan
PATCH v5 1/6 evtchn: use per-channel lock where possible
Neither evtchn_status() nor domain_dump_evtchn_info() nor flask_get_peer_sid() need to hold the per-domain lock - they all only read a single channel's state (at a time, in the dump case).
---
v4: New.
xen/common/event_channel.c +47 -15
@@ -974,15 +974,16 @@ int evtchn_status(evtchn_status_t *statuif ( d ==NULL )return -ESRCH ; -spin_lock (&d->event_lock); -if ( !port_is_valid (d, port) ) { - rc = -EINVAL ; - goto out; +rcu_unlock_domain (d); +return -EINVAL ; } chn =evtchn_from_port (d, port); + +evtchn_read_lock (chn); +if (consumer_is_xen (chn) ) { rc = -EACCES ;
@@ -1027,7 +1028,7 @@ int evtchn_status(evtchn_status_t *statu status->vcpu = chn->notify_vcpu_id; out: -spin_unlock (&d->event_lock); +evtchn_read_unlock (chn);rcu_unlock_domain (d);return rc;
@@ -1582,22 +1583,32 @@ void evtchn_move_pirqs(struct vcpu *v)static void domain_dump_evtchn_info (struct domain *d) {unsigned int port; -int irq;printk ("Event channel information for domain %d:\n" "Polling vCPUs: {%*pbl}\n" " port [p/m/s]\n" , d->domain_id, d->max_vcpus, d->poll_mask); -spin_lock (&d->event_lock); -for ( port =1 ;port_is_valid (d, port); ++port ) { -const struct evtchn *chn; +struct evtchn *chn;char *ssid; +if ( !(port &0x3f ) ) +process_pending_softirqs (); + chn =evtchn_from_port (d, port); + +if ( !evtchn_read_trylock (chn) ) + { +printk (" %4u in flux\n" , port); +continue ; + } +if ( chn->state ==ECS_FREE ) + { +evtchn_read_unlock (chn);continue ; + } printk(" %4u [%d/%d/", port,
@@ -1607,26 +1618,49 @@ static void domain_dump_evtchn_info(struprintk ("]: s=%d n=%d x=%d" , chn->state, chn->notify_vcpu_id, chn->xen_consumer); + ssid =xsm_show_security_evtchn (d, chn); +switch ( chn->state ) {case ECS_UNBOUND :printk (" d=%d" , chn->u.unbound.remote_domid);break ; +case ECS_INTERDOMAIN :printk (" d=%d p=%d" , chn->u.interdomain.remote_dom->domain_id, chn->u.interdomain.remote_port);break ; -case ECS_PIRQ : - irq =domain_pirq_to_irq (d, chn->u.pirq.irq); -printk (" p=%d i=%d" , chn->u.pirq.irq, irq); + +case ECS_PIRQ : { +unsigned int pirq = chn->u.pirq.irq; + +/* +* The per-channel locks nest inside the per-domain one, so we +* can't acquire the latter without first letting go of the former. +*/ +evtchn_read_unlock (chn); + chn =NULL ; +if (spin_trylock (&d->event_lock) ) + { +int irq =domain_pirq_to_irq (d, pirq); + +spin_unlock (&d->event_lock); +printk (" p=%u i=%d" , pirq, irq); + } +else +printk (" p=%u i=?" , pirq);break ; + } +case ECS_VIRQ :printk (" v=%d" , chn->u.virq);break ; } - ssid =xsm_show_security_evtchn (d, chn); +if ( chn ) +evtchn_read_unlock (chn); +if (ssid) {printk (" Z=%s\n" , ssid);xfree (ssid);
@@ -1634,8 +1668,6 @@ static void domain_dump_evtchn_info(struprintk ("\n" ); } } - -spin_unlock (&d->event_lock); }static void dump_evtchn_info (unsigned char key)
xen/xsm/flask/flask_op.c +5 -4
@@ -555,12 +555,13 @@ static int flask_get_peer_sid(struct xenstruct evtchn *chn;struct domain_security_struct *dsec; -spin_lock (&d->event_lock); -if ( !port_is_valid (d, arg->evtchn) ) - goto out; +return -EINVAL ; chn =evtchn_from_port (d, arg->evtchn); + +evtchn_read_lock (chn); +if ( chn->state !=ECS_INTERDOMAIN ) goto out;
@@ -573,7 +574,7 @@ static int flask_get_peer_sid(struct xen rv =0 ; out: -spin_unlock (&d->event_lock); +evtchn_read_unlock (chn);return rv; }
PATCH v5 2/6 evtchn: convert domain event lock to an r/w one
In reply to Jan BeulichEspecially for the use in evtchn_move_pirqs() (called when moving a vCPU across pCPU-s) and the ones in EOI handling in PCI pass-through code, serializing perhaps an entire domain isn't helpful when no state (which isn't e.g. further protected by the per-channel lock) changes.
Unfortunately this implies dropping of lock profiling for this lock, until r/w locks may get enabled for such functionality.
While ->notify_vcpu_id is now meant to be consistently updated with the per-channel lock held, an extension applies to ECS_PIRQ: The field is also guaranteed to not change with the per-domain event lock held for writing. Therefore the link_pirq_port() call from evtchn_bind_pirq() could in principle be moved out of the per-channel locked regions, but this further code churn didn't seem worth it.
---
v5: Re-base, also over dropped earlier patch.
v4: Re-base, in particular over new earlier patches. Acquire both
per-domain locks for writing in evtchn_close(). Adjust spin_barrier() related comments.
v3: Re-base.
v2: Consistently lock for writing in evtchn_reset(). Fix error path in
pci_clean_dpci_irqs(). Lock for writing in pt_irq_time_out(), hvm_dirq_assist(), hvm_dpci_eoi(), and hvm_dpci_isairq_eoi(). Move rw_barrier() introduction here. Re-base over changes earlier in the series.
xen/arch/x86/domain.c +2 -2
@@ -903,7 +903,7 @@ int arch_domain_soft_reset(struct domainif ( !is_hvm_domain (d) )return -EINVAL ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock);for ( i =0 ; i < d->nr_pirqs ; i++ ) {if (domain_pirq_to_emuirq (d, i) !=IRQ_UNBOUND )
@@ -913,7 +913,7 @@ int arch_domain_soft_reset(struct domainbreak ; } } -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);if ( ret )return ret;
xen/arch/x86/hvm/hvm.c +2 -2
@@ -528,9 +528,9 @@ void hvm_migrate_pirqs(struct vcpu *v)if ( !is_iommu_enabled (d) || !hvm_domain_irq (d)->dpci )return ; -spin_lock (&d->event_lock); +read_lock (&d->event_lock);pt_pirq_iterate (d, migrate_pirq, v); -spin_unlock (&d->event_lock); +read_unlock (&d->event_lock); }static bool hvm_get_pending_event (struct vcpu *v,struct x86_event *info)
xen/arch/x86/hvm/irq.c +2 -2
@@ -404,9 +404,9 @@ int hvm_inject_msi(struct domain *d, uin {int rc; -spin_lock (&d->event_lock); +write_lock (&d->event_lock); rc =map_domain_emuirq_pirq (d, pirq,IRQ_MSI_EMU ); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);if ( rc )return rc; info =pirq_info (d, pirq);
xen/arch/x86/hvm/vioapic.c +2 -2
@@ -203,9 +203,9 @@ static int vioapic_hwdom_map_gsi(unsigne {gprintk (XENLOG_WARNING ,"vioapic: error binding GSI %u: %d\n" , gsi, ret); -spin_lock (&currd->event_lock); +write_lock (&currd->event_lock);unmap_domain_pirq (currd, pirq); -spin_unlock (&currd->event_lock); +write_unlock (&currd->event_lock); }pcidevs_unlock ();
xen/arch/x86/hvm/vmsi.c +6 -6
@@ -465,7 +465,7 @@ int msixtbl_pt_register(struct domain *dint r = -EINVAL ;ASSERT (pcidevs_locked ()); -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));if ( !msixtbl_initialised (d) )return -ENODEV ;
@@ -535,7 +535,7 @@ void msixtbl_pt_unregister(struct domainstruct msixtbl_entry *entry;ASSERT (pcidevs_locked ()); -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));if ( !msixtbl_initialised (d) )return ;
@@ -589,13 +589,13 @@ void msixtbl_pt_cleanup(struct domain *dif ( !msixtbl_initialised (d) )return ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock);list_for_each_entry_safe ( entry, temp, &d->arch.hvm.msixtbl_list, list )del_msixtbl_entry (entry); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock); }void msix_write_completion (struct vcpu *v)
@@ -809,9 +809,9 @@ static void vpci_msi_disable(const strucASSERT (!rc); } -spin_lock (&pdev->domain->event_lock); +write_lock (&pdev->domain->event_lock);unmap_domain_pirq (pdev->domain, pirq); -spin_unlock (&pdev->domain->event_lock); +write_unlock (&pdev->domain->event_lock);pcidevs_unlock (); }
xen/arch/x86/io_apic.c +2 -2
@@ -2413,10 +2413,10 @@ int ioapic_guest_write(unsigned long phy }if ( pirq >=0 ) { -spin_lock (&hardware_domain->event_lock); +write_lock (&hardware_domain->event_lock); ret =map_domain_pirq (hardware_domain, pirq, irq,MAP_PIRQ_TYPE_GSI ,NULL ); -spin_unlock (&hardware_domain->event_lock); +write_unlock (&hardware_domain->event_lock);if ( ret <0 )return ret; }
xen/arch/x86/irq.c +16 -16
@@ -1552,7 +1552,7 @@ int pirq_guest_bind(struct vcpu *v, struunsigned int max_nr_guests = will_share ? irq_max_guests :1 ;int rc =0 ; -WARN_ON (!spin_is_locked (&v->domain->event_lock)); +WARN_ON (!rw_is_write_locked (&v->domain->event_lock));BUG_ON (!local_irq_is_enabled ()); retry:
@@ -1766,7 +1766,7 @@ void pirq_guest_unbind(struct domain *d,struct irq_desc *desc;int irq =0 ; -WARN_ON (!spin_is_locked (&d->event_lock)); +WARN_ON (!rw_is_write_locked (&d->event_lock));BUG_ON (!local_irq_is_enabled ()); desc =pirq_spin_lock_irq_desc (pirq,NULL );
@@ -1803,7 +1803,7 @@ static bool pirq_guest_force_unbind(struunsigned int i;bool bound = false; -WARN_ON (!spin_is_locked (&d->event_lock)); +WARN_ON (!rw_is_write_locked (&d->event_lock));BUG_ON (!local_irq_is_enabled ()); desc =pirq_spin_lock_irq_desc (pirq,NULL );
@@ -2045,7 +2045,7 @@ int get_free_pirq(struct domain *d, int {int i; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));if ( type ==MAP_PIRQ_TYPE_GSI ) {
@@ -2070,7 +2070,7 @@ int get_free_pirqs(struct domain *d, uns {unsigned int i, found =0 ; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));for ( i = d->nr_pirqs -1 ; i >= nr_irqs_gsi; --i )if (is_free_pirq (d,pirq_info (d, i)) )
@@ -2098,7 +2098,7 @@ int map_domain_pirq( DECLARE_BITMAP(prepared, MAX_MSI_IRQS) = {}; DECLARE_BITMAP(granted, MAX_MSI_IRQS) = {}; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));if ( !irq_access_permitted (current->domain, irq))return -EPERM ;
@@ -2317,7 +2317,7 @@ int unmap_domain_pirq(struct domain *d,return -EINVAL ;ASSERT (pcidevs_locked ()); -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock)); info =pirq_info (d, pirq);if ( !info || (irq = info->arch.irq) <=0 )
@@ -2444,13 +2444,13 @@ void free_domain_pirqs(struct domain *d)int i;pcidevs_lock (); -spin_lock (&d->event_lock); +write_lock (&d->event_lock);for ( i =0 ; i < d->nr_pirqs; i++ )if (domain_pirq_to_irq (d, i) >0 )unmap_domain_pirq (d, i); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);pcidevs_unlock (); }
@@ -2693,7 +2693,7 @@ int map_domain_emuirq_pirq(struct domainint old_emuirq =IRQ_UNBOUND , old_pirq =IRQ_UNBOUND ;struct pirq *info; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock));if ( !is_hvm_domain (d) )return -EINVAL ;
@@ -2759,7 +2759,7 @@ int unmap_domain_pirq_emuirq(struct domaif ( (pirq <0 ) || (pirq >= d->nr_pirqs) )return -EINVAL ; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock)); emuirq =domain_pirq_to_emuirq (d, pirq);if ( emuirq ==IRQ_UNBOUND )
@@ -2807,7 +2807,7 @@ static int allocate_pirq(struct domain * {int current_pirq; -ASSERT (spin_is_locked (&d->event_lock)); +ASSERT (rw_is_write_locked (&d->event_lock)); current_pirq =domain_irq_to_pirq (d, irq);if ( pirq <0 ) {
@@ -2879,7 +2879,7 @@ int allocate_and_map_gsi_pirq(struct dom }/* Verify or get pirq. */ -spin_lock (&d->event_lock); +write_lock (&d->event_lock); pirq =allocate_pirq (d, index, *pirq_p, irq,MAP_PIRQ_TYPE_GSI ,NULL );if ( pirq <0 ) {
@@ -2892,7 +2892,7 @@ int allocate_and_map_gsi_pirq(struct dom *pirq_p = pirq; done: -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);return ret; }
@@ -2933,7 +2933,7 @@ int allocate_and_map_msi_pirq(struct dompcidevs_lock ();/* Verify or get pirq. */ -spin_lock (&d->event_lock); +write_lock (&d->event_lock); pirq =allocate_pirq (d, index, *pirq_p, irq, type, &msi->entry_nr);if ( pirq <0 ) {
@@ -2946,7 +2946,7 @@ int allocate_and_map_msi_pirq(struct dom *pirq_p = pirq; done: -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);pcidevs_unlock ();if ( ret ) {
xen/arch/x86/physdev.c +11 -11
@@ -34,7 +34,7 @@ static int physdev_hvm_map_pirq(ASSERT (!is_hardware_domain (d)); -spin_lock (&d->event_lock); +write_lock (&d->event_lock);switch ( type ) {case MAP_PIRQ_TYPE_GSI : {
@@ -84,7 +84,7 @@ static int physdev_hvm_map_pirq(break ; } -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);return ret; }
@@ -154,18 +154,18 @@ int physdev_unmap_pirq(domid_t domid, inif (is_hvm_domain (d) &&has_pirq (d) ) { -spin_lock (&d->event_lock); +write_lock (&d->event_lock);if (domain_pirq_to_emuirq (d, pirq) !=IRQ_UNBOUND ) ret =unmap_domain_pirq_emuirq (d, pirq); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);if ( domid ==DOMID_SELF || ret ) goto free_domain; }pcidevs_lock (); -spin_lock (&d->event_lock); +write_lock (&d->event_lock); ret =unmap_domain_pirq (d, pirq); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);pcidevs_unlock (); free_domain:
@@ -192,10 +192,10 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H ret = -EINVAL ;if ( eoi.irq >= currd->nr_pirqs )break ; -spin_lock (&currd->event_lock); +read_lock (&currd->event_lock); pirq =pirq_info (currd, eoi.irq);if ( !pirq ) { -spin_unlock (&currd->event_lock); +read_unlock (&currd->event_lock);break ; }if ( currd->arch.auto_unmask )
@@ -214,7 +214,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H && hvm_irq->gsi_assert_count[gsi] )send_guest_pirq (currd, pirq); } -spin_unlock (&currd->event_lock); +read_unlock (&currd->event_lock); ret =0 ;break ; }
@@ -626,7 +626,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_Hif (copy_from_guest (&out, arg,1 ) !=0 )break ; -spin_lock (&currd->event_lock); +write_lock (&currd->event_lock); ret =get_free_pirq (currd, out.type);if ( ret >=0 )
@@ -639,7 +639,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H ret = -ENOMEM ; } -spin_unlock (&currd->event_lock); +write_unlock (&currd->event_lock);if ( ret >=0 ) {
xen/arch/x86/pv/shim.c +5 -5
@@ -448,7 +448,7 @@ static long pv_shim_event_channel_op(intif ( rc ) \break ; \ \ -spin_lock (&d->event_lock); \ +write_lock (&d->event_lock); \ rc =evtchn_allocate_port (d, op.port_field); \if ( rc ) \ { \
@@ -457,7 +457,7 @@ static long pv_shim_event_channel_op(int } \else \evtchn_reserve (d, op.port_field); \ -spin_unlock (&d->event_lock); \ +write_unlock (&d->event_lock); \ \if ( !rc &&__copy_to_guest (arg, &op,1 ) ) \ rc = -EFAULT ; \
@@ -585,11 +585,11 @@ static long pv_shim_event_channel_op(intif ( rc )break ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock); rc =evtchn_allocate_port (d, ipi.port);if ( rc ) { -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock); close.port = ipi.port;BUG_ON (xen_hypercall_event_channel_op (EVTCHNOP_close, &close));
@@ -598,7 +598,7 @@ static long pv_shim_event_channel_op(intevtchn_assign_vcpu (d, ipi.port, ipi.vcpu);evtchn_reserve (d, ipi.port); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);if (__copy_to_guest (arg, &ipi,1 ) ) rc = -EFAULT ;
xen/common/event_channel.c +41 -41
268 lines not on this page · raw message
xen/common/event_fifo.c +5 -5
@@ -600,7 +600,7 @@ int evtchn_fifo_init_control(struct evtcif ( offset & (8 -1 ) )return -EINVAL ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock);/* * If this is the first control block, setup an empty event array
@@ -636,13 +636,13 @@ int evtchn_fifo_init_control(struct evtcelse rc =map_control_block (v, gfn, offset); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);return rc; error:evtchn_fifo_destroy (d); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);return rc; }
@@ -695,9 +695,9 @@ int evtchn_fifo_expand_array(const strucif ( !d->evtchn_fifo )return -EOPNOTSUPP ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock); rc =add_page_to_event_array (d, expand_array->array_gfn); -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock);return rc; }
xen/drivers/passthrough/vtd/x86/hvm.c +2 -2
@@ -54,7 +54,7 @@ void hvm_dpci_isairq_eoi(struct domain *if ( !is_iommu_enabled (d) )return ; -spin_lock (&d->event_lock); +write_lock (&d->event_lock); dpci =domain_get_irq_dpci (d);
@@ -63,5 +63,5 @@ void hvm_dpci_isairq_eoi(struct domain */* Multiple mirq may be mapped to one isa irq */ pt_pirq_iterate (d, _hvm_dpci_isairq_eoi, (void *)(long )isairq); } -spin_unlock (&d->event_lock); +write_unlock (&d->event_lock); }
xen/drivers/passthrough/x86/hvm.c +33 -33
258 lines not on this page · raw message
xen/include/xen/sched.h +1 -1
@@ -377,7 +377,7 @@ struct domainunsigned int xen_evtchns;/* Port to resume from in evtchn_reset(), when in a continuation. */ unsigned int next_evtchn; -spinlock_t event_lock; +rwlock_t event_lock;const struct evtchn_port_ops *evtchn_port_ops;struct evtchn_fifo_domain *evtchn_fifo;
Re: [PATCH v5 2/6] evtchn: convert domain event lock to an r/w one
Quoted 4 lines · Jan Beulich
Especially for the use in
evtchn_move_pirqs()(called when moving a vCPU across pCPU-s) and the ones in EOI handling in PCI pass-through code, serializing perhaps an entire domain isn't helpful when no state (which isn't e.g. further protected by the per-channel lock) changes.
I'm unsure this move is good from a performance PoV, as the operations switched to use the lock in read mode is a very small subset, and then the remaining operations get a performance penalty when compared to using a plain spin lock.
Quoted 12 lines
Unfortunately this implies dropping of lock profiling for this lock, until r/w locks may get enabled for such functionality.
While ->notify_vcpu_id is now meant to be consistently updated with the per-channel lock held, an extension applies to
ECS_PIRQ: The field is also guaranteed to not change with the per-domain event lock held for writing. Therefore thelink_pirq_port()call fromevtchn_bind_pirq()could in principle be moved out of the per-channel locked regions, but this further code churn didn't seem worth it.Signed-off-by Jan Beulich <[email protected]>
xen/common/event_channel.c int evtchn_destroy(struct domain *d) · line 1515
Quoted 9 lines
xen/common/event_channel.c +3
-2@@ -1510,9 +1509,10 @@ int evtchn_destroy(struct domain *d) {unsigned int i; -/* After this barrier no new event-channel allocations can occur. */ +/* After this kind-of-barrier no new event-channel allocations can occur. */ BUG_ON (!d->is_dying); -spin_barrier (&d->event_lock); +read_lock (&d->event_lock); +read_unlock (&d->event_lock);
Don't you want to use write mode here to assure there are no read users that have taken the lock before is_dying has been set, and thus could make wrong assumptions?
As I understand the point of the barrier here is to ensure there are no lockers carrier over from before is_dying has been set.
Thanks, Roger.
Re: [PATCH v5 2/6] evtchn: convert domain event lock to an r/w one
Quoted 10 lines · Roger Pau Monné
Quoted 4 lines · Jan Beulich
Especially for the use in
evtchn_move_pirqs()(called when moving a vCPU across pCPU-s) and the ones in EOI handling in PCI pass-through code, serializing perhaps an entire domain isn't helpful when no state (which isn't e.g. further protected by the per-channel lock) changes.I'm unsure this move is good from a performance PoV, as the operations switched to use the lock in read mode is a very small subset, and then the remaining operations get a performance penalty when compared to using a plain spin lock.
Well, yes, unfortunately review of earlier versions has resulted in there being quite a few less read_lock() uses now than I had (mistakenly) originally. There are a few worthwhile conversions, but on the whole maybe I should indeed drop this change.
Quoted 15 lines
xen/common/event_channel.c int evtchn_destroy(struct domain *d) · line 1515
Quoted 10 lines
xen/common/event_channel.c +3
-2@@ -1510,9 +1509,10 @@ int evtchn_destroy(struct domain *d) {unsigned int i; -/* After this barrier no new event-channel allocations can occur. */ +/* After this kind-of-barrier no new event-channel allocations can occur. */ BUG_ON (!d->is_dying); -spin_barrier (&d->event_lock); +read_lock (&d->event_lock); +read_unlock (&d->event_lock);Don't you want to use write mode here to assure there are no read users that have taken the lock before
is_dyinghas been set, and thus could make wrong assumptions?
Quoted 2 lines
As I understand the point of the barrier here is to ensure there are no lockers carrier over from before
is_dyinghas been set.
The purpose is, as the comment says, no new event channel allocations. Those happen under write lock, so a read-lock-based barrier is enough here afaict.
Jan
Re: [PATCH v5 2/6] evtchn: convert domain event lock to an r/w one
In reply to Jan BeulichHi Jan,
As discussed in [1], I think it would good to revive this patch.
AFAICT, this patch was dropped because the performance was thought to be minimal. However, I think it would be a better way to resolve the problem that one is trying to address [1].
So I will do another review of this patch.
Quoted 8 lines · Jan Beulich
Especially for the use in
evtchn_move_pirqs()(called when moving a vCPU across pCPU-s) and the ones in EOI handling in PCI pass-through code, serializing perhaps an entire domain isn't helpful when no state (which isn't e.g. further protected by the per-channel lock) changes.Unfortunately this implies dropping of lock profiling for this lock, until r/w locks may get enabled for such functionality.
Quoted 6 lines
While ->notify_vcpu_id is now meant to be consistently updated with the per-channel lock held, an extension applies to
ECS_PIRQ: The field is also guaranteed to not change with the per-domain event lock held for writing. Therefore thelink_pirq_port()call fromevtchn_bind_pirq()could in principle be moved out of the per-channel locked regions, but this further code churn didn't seem worth it.
This doesn't seem to apply on upstream anymore. Would you be able to respin it?
I have looked at the place where you use read_lock() rather than write_lock(). They all look fine to me, so I would be fine to give my reviewed-by on the next version (assuming there are nothing wrong with the rebase :)).
Cheers,
[1] https://lore.kernel.org/xen-devel/[email protected]/
Signature · 1 line
Julien Grall
PATCH v5 3/6 evtchn: slightly defer lock acquire where possible
In reply to Jan Beulichport_is_valid() and evtchn_from_port() are fine to use without holding any locks. Accordingly acquire the per-domain lock slightly later in evtchn_close() and evtchn_bind_vcpu().
---
v4: New.
xen/common/event_channel.c +7 -13
@@ -610,17 +610,14 @@ int evtchn_close(struct domain *d1, intint port2;long rc =0 ; - again: -write_lock (&d1->event_lock); -if ( !port_is_valid (d1, port1) ) - { - rc = -EINVAL ; - goto out; - } +return -EINVAL ; chn1 =evtchn_from_port (d1, port1); + again: +write_lock (&d1->event_lock); +/* Guest cannot close a Xen-attached event channel. */ if (unlikely (consumer_is_xen (chn1)) && guest ) {
@@ -1044,16 +1041,13 @@ long evtchn_bind_vcpu(unsigned int port,if ( (v =domain_vcpu (d, vcpu_id)) ==NULL )return -ENOENT ; -write_lock (&d->event_lock); -if ( !port_is_valid (d, port) ) - { - rc = -EINVAL ; - goto out; - } +return -EINVAL ; chn =evtchn_from_port (d, port); +write_lock (&d->event_lock); +/* Guest cannot re-bind a Xen-attached event channel. */ if (unlikely (consumer_is_xen (chn)) ) {
PATCH v5 4/6 evtchn: add helper for port_is_valid() + evtchn_from_port()
In reply to Jan BeulichThe combination is pretty common, so adding a simple local helper seems worthwhile. Make it const- and type-correct, in turn requiring the two called function to also be const-correct (and at this occasion also make them type-correct).
---
v4: New.
xen/common/event_channel.c +28 -38
@@ -147,6 +147,11 @@ static bool virq_is_global(unsigned intreturn true; } +static struct evtchn *_evtchn_from_port (const struct domain *d, +evtchn_port_t port) +{ +return port_is_valid (d, port) ?evtchn_from_port (d, port) :NULL ; +}static struct evtchn *alloc_evtchn_bucket (struct domain *d,unsigned int port) {
@@ -369,9 +374,9 @@ static long evtchn_bind_interdomain(evtcERROR_EXIT (lport); lchn =evtchn_from_port (ld, lport); -if ( !port_is_valid (rd, rport) ) + rchn =_evtchn_from_port (rd, rport); +if ( !rchn )ERROR_EXIT_DOM (-EINVAL , rd); - rchn =evtchn_from_port (rd, rport);if ( (rchn->state !=ECS_UNBOUND ) || (rchn->u.unbound.remote_domid != ld->domain_id) )ERROR_EXIT_DOM (-EINVAL , rd);
@@ -606,15 +611,12 @@ static long evtchn_bind_pirq(evtchn_bindint evtchn_close (struct domain *d1,int port1,bool guest) {struct domain *d2 =NULL ; -struct evtchn *chn1, *chn2; -int port2; +struct evtchn *chn1 =_evtchn_from_port (d1, port1), *chn2;long rc =0 ; -if ( !port_is_valid (d1, port1) ) +if ( !chn1 )return -EINVAL ; - chn1 =evtchn_from_port (d1, port1); - again:write_lock (&d1->event_lock);
@@ -700,10 +702,8 @@ int evtchn_close(struct domain *d1, int goto out; } - port2 = chn1->u.interdomain.remote_port; -BUG_ON (!port_is_valid (d2, port2)); - - chn2 =evtchn_from_port (d2, port2); + chn2 =_evtchn_from_port (d2, chn1->u.interdomain.remote_port); +BUG_ON (!chn2);BUG_ON (chn2->state !=ECS_INTERDOMAIN );BUG_ON (chn2->u.interdomain.remote_dom != d1);
@@ -741,15 +741,13 @@ int evtchn_close(struct domain *d1, intint evtchn_send (struct domain *ld,unsigned int lport) { -struct evtchn *lchn, *rchn; +struct evtchn *lchn =_evtchn_from_port (ld, lport), *rchn;struct domain *rd;int rport, ret =0 ; -if ( !port_is_valid (ld, lport) ) +if ( !lchn )return -EINVAL ; - lchn =evtchn_from_port (ld, lport); -evtchn_read_lock (lchn);/* Guest cannot send via a Xen-attached event channel. */
@@ -961,7 +959,6 @@ int evtchn_status(evtchn_status_t *statu {struct domain *d;domid_t dom = status->dom; -int port = status->port;struct evtchn *chn;long rc =0 ;
@@ -969,14 +966,13 @@ int evtchn_status(evtchn_status_t *statuif ( d ==NULL )return -ESRCH ; -if ( !port_is_valid (d, port) ) + chn =_evtchn_from_port (d, status->port); +if ( !chn ) {rcu_unlock_domain (d);return -EINVAL ; } - chn =evtchn_from_port (d, port); -evtchn_read_lock (chn);if (consumer_is_xen (chn) )
@@ -1041,11 +1037,10 @@ long evtchn_bind_vcpu(unsigned int port,if ( (v =domain_vcpu (d, vcpu_id)) ==NULL )return -ENOENT ; -if ( !port_is_valid (d, port) ) + chn =_evtchn_from_port (d, port); +if ( !chn )return -EINVAL ; - chn =evtchn_from_port (d, port); -write_lock (&d->event_lock);/* Guest cannot re-bind a Xen-attached event channel. */
@@ -1091,13 +1086,11 @@ long evtchn_bind_vcpu(unsigned int port,int evtchn_unmask (unsigned int port) {struct domain *d = current->domain; -struct evtchn *evtchn; +struct evtchn *evtchn =_evtchn_from_port (d, port); -if (unlikely (!port_is_valid (d, port)) ) +if (unlikely (!evtchn) )return -EINVAL ; - evtchn =evtchn_from_port (d, port); -evtchn_read_lock (evtchn);evtchn_port_unmask (d, evtchn);
@@ -1180,14 +1173,12 @@ static long evtchn_set_priority(const st {struct domain *d = current->domain;unsigned int port = set_priority->port; -struct evtchn *chn; +struct evtchn *chn =_evtchn_from_port (d, port);long ret; -if ( !port_is_valid (d, port) ) +if ( !chn )return -EINVAL ; - chn =evtchn_from_port (d, port); -evtchn_read_lock (chn); ret =evtchn_port_set_priority (d, chn, set_priority->priority);
@@ -1413,10 +1404,10 @@ void free_xen_event_channel(struct domaivoid notify_via_xen_event_channel (struct domain *ld,int lport) { -struct evtchn *lchn, *rchn; +struct evtchn *lchn =_evtchn_from_port (ld, lport), *rchn;struct domain *rd; -if ( !port_is_valid (ld, lport) ) +if ( !lchn ) {/* * Make sure ->is_dying is read /after/ ->valid_evtchns, pairing
@@ -1427,8 +1418,6 @@ void notify_via_xen_event_channel(structreturn ; } - lchn =evtchn_from_port (ld, lport); -if ( !evtchn_read_trylock (lchn) )return ;
@@ -1582,16 +1571,17 @@ static void domain_dump_evtchn_info(stru"Polling vCPUs: {%*pbl}\n" " port [p/m/s]\n", d->domain_id, d->max_vcpus, d->poll_mask); -for ( port =1 ;port_is_valid (d, port); ++port ) +for ( port =1 ; ; ++port ) { -struct evtchn *chn; +struct evtchn *chn =_evtchn_from_port (d, port);char *ssid; +if ( !chn ) +break ; +if ( !(port &0x3f ) )process_pending_softirqs (); - chn =evtchn_from_port (d, port); -if ( !evtchn_read_trylock (chn) ) {printk (" %4u in flux\n" , port);
xen/include/xen/event.h +3 -2
@@ -120,7 +120,7 @@ static inline void evtchn_read_unlock(stread_unlock (&evtchn->lock); } -static inline bool_t port_is_valid (struct domain *d,unsigned int p) +static inline bool port_is_valid (const struct domain *d,evtchn_port_t p) {if ( p >=read_atomic (&d->valid_evtchns) )return false;
@@ -135,7 +135,8 @@ static inline bool_t port_is_valid(strucreturn true; } -static inline struct evtchn *evtchn_from_port (struct domain *d,unsigned int p) +static inline struct evtchn *evtchn_from_port (const struct domain *d, +evtchn_port_t p) {if ( p <EVTCHNS_PER_BUCKET )return &d->evtchn[array_index_nospec (p,EVTCHNS_PER_BUCKET )];
PATCH v5 5/6 evtchn: type adjustments
In reply to Jan BeulichFirst of all avoid "long" when "int" suffices, i.e. in particular when merely conveying error codes. 32-bit values are slightly cheaper to deal with on x86, and their processing is at least no more expensive on Arm. Where possible use evtchn_port_t for port numbers and unsigned int for other unsigned quantities in adjacent code. In evtchn_set_priority() eliminate a local variable altogether instead of changing its type.
---
v4: New.
xen/common/event_channel.c +20 -22
@@ -287,13 +287,12 @@ void evtchn_free(struct domain *d, strucxsm_evtchn_close_post (chn); } -static long evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc) +static int evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc) {struct evtchn *chn;struct domain *d; -int port; +int port, rc;domid_t dom = alloc->dom; -long rc; d =rcu_lock_domain_by_any_id (dom);if ( d ==NULL )
@@ -346,13 +345,13 @@ static void double_evtchn_unlock(structevtchn_write_unlock (rchn); } -static long evtchn_bind_interdomain (evtchn_bind_interdomain_t *bind) +static int evtchn_bind_interdomain (evtchn_bind_interdomain_t *bind) {struct evtchn *lchn, *rchn;struct domain *ld = current->domain, *rd; -int lport, rport = bind->remote_port; +int lport, rc; +evtchn_port_t rport = bind->remote_port;domid_t rdom = bind->remote_dom; -long rc;if ( (rd =rcu_lock_domain_by_any_id (rdom)) ==NULL )return -ESRCH ;
@@ -488,12 +487,12 @@ int evtchn_bind_virq(evtchn_bind_virq_t } -static long evtchn_bind_ipi (evtchn_bind_ipi_t *bind) +static int evtchn_bind_ipi (evtchn_bind_ipi_t *bind) {struct evtchn *chn;struct domain *d = current->domain; -int port, vcpu = bind->vcpu; -long rc =0 ; +int port, rc =0 ; +unsigned int vcpu = bind->vcpu;if (domain_vcpu (d, vcpu) ==NULL )return -ENOENT ;
@@ -547,16 +546,16 @@ static void unlink_pirq_port(struct evtc } -static long evtchn_bind_pirq (evtchn_bind_pirq_t *bind) +static int evtchn_bind_pirq (evtchn_bind_pirq_t *bind) {struct evtchn *chn;struct domain *d = current->domain;struct vcpu *v = d->vcpu[0 ];struct pirq *info; -int port =0 , pirq = bind->pirq; -long rc; +int port =0 , rc; +unsigned int pirq = bind->pirq; -if ( (pirq <0 ) || (pirq >= d->nr_pirqs) ) +if ( pirq >= d->nr_pirqs )return -EINVAL ;if ( !is_hvm_domain (d) && !pirq_access_permitted (d, pirq) )
@@ -612,7 +611,7 @@ int evtchn_close(struct domain *d1, int {struct domain *d2 =NULL ;struct evtchn *chn1 =_evtchn_from_port (d1, port1), *chn2; -long rc =0 ; +int rc =0 ;if ( !chn1 )return -EINVAL ;
@@ -960,7 +959,7 @@ int evtchn_status(evtchn_status_t *statustruct domain *d;domid_t dom = status->dom;struct evtchn *chn; -long rc =0 ; +int rc =0 ; d =rcu_lock_domain_by_any_id (dom);if ( d ==NULL )
@@ -1026,11 +1025,11 @@ int evtchn_status(evtchn_status_t *statu } -long evtchn_bind_vcpu (unsigned int port,unsigned int vcpu_id) +int evtchn_bind_vcpu (evtchn_port_t port,unsigned int vcpu_id) {struct domain *d = current->domain;struct evtchn *chn; -long rc =0 ; +int rc =0 ;struct vcpu *v;/* Use the vcpu info to prevent speculative out-of-bound accesses */
@@ -1169,12 +1168,11 @@ int evtchn_reset(struct domain *d, boolreturn rc; } -static long evtchn_set_priority (const struct evtchn_set_priority *set_priority) +static int evtchn_set_priority (const struct evtchn_set_priority *set_priority) {struct domain *d = current->domain; -unsigned int port = set_priority->port; -struct evtchn *chn =_evtchn_from_port (d, port); -long ret; +struct evtchn *chn =_evtchn_from_port (d, set_priority->port); +int ret;if ( !chn )return -EINVAL ;
@@ -1190,7 +1188,7 @@ static long evtchn_set_priority(const stlong do_event_channel_op (int cmd,XEN_GUEST_HANDLE_PARAM (void ) arg) { -long rc; +int rc;switch ( cmd ) {
xen/include/xen/event.h +1 -1
@@ -54,7 +54,7 @@ void send_guest_pirq(struct domain *, coint evtchn_send (struct domain *d,unsigned int lport);/* Bind a local event-channel port to the specified VCPU. */ -long evtchn_bind_vcpu (unsigned int port,unsigned int vcpu_id); +int evtchn_bind_vcpu (evtchn_port_t port,unsigned int vcpu_id);/* Bind a VIRQ. */ int evtchn_bind_virq (evtchn_bind_virq_t *bind,evtchn_port_t port);
PATCH v5 6/6 evtchn: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()
In reply to Jan BeulichThe per-vCPU virq_lock, which is being held anyway, together with there not being any call to evtchn_port_set_pending() when v->virq_to_evtchn[] is zero, provide sufficient guarantees. Undo the lock addition done for XSA-343 (commit e045199c7c9c "evtchn: address races with evtchn_reset()"). Update the description next to struct evtchn_port_ops accordingly.
---
v4: Move to end of series, for being the most controversial change.
v3: Re-base.
v2: New.
xen/common/event_channel.c +2 -12
@@ -812,7 +812,6 @@ void send_guest_vcpu_virq(struct vcpu *vunsigned long flags;int port;struct domain *d; -struct evtchn *chn;ASSERT (!virq_is_global (virq));
@@ -823,12 +822,7 @@ void send_guest_vcpu_virq(struct vcpu *v goto out; d = v->domain; - chn =evtchn_from_port (d, port); -if (evtchn_read_trylock (chn) ) - { -evtchn_port_set_pending (d, v->vcpu_id, chn); -evtchn_read_unlock (chn); - } +evtchn_port_set_pending (d, v->vcpu_id,evtchn_from_port (d, port)); out:read_unlock_irqrestore (&v->virq_lock, flags);
@@ -857,11 +851,7 @@ void send_guest_global_virq(struct domai goto out; chn =evtchn_from_port (d, port); -if (evtchn_read_trylock (chn) ) - { -evtchn_port_set_pending (d, chn->notify_vcpu_id, chn); -evtchn_read_unlock (chn); - } +evtchn_port_set_pending (d, chn->notify_vcpu_id, chn); out:read_unlock_irqrestore (&v->virq_lock, flags);
xen/include/xen/event.h +10 -3
@@ -193,9 +193,16 @@ int evtchn_reset(struct domain *d, bool* Low-level event channel port ops. * * All hooks have to be called with a lock held which prevents the channel -* from changing state. This may be the domain event lock, the per-channel -* lock, or in the case of sending interdomain events also the other side's -* per-channel lock. Exceptions apply in certain cases for the PV shim. +* from changing state. This may be +* - the domain event lock, +* - the per-channel lock, +* - in the case of sending interdomain events the other side's per-channel +* lock, +* - in the case of sending non-global vIRQ-s the per-vCPU virq_lock (in +* combination with the ordering enforced through how the vCPU's +* virq_to_evtchn[] gets updated), +* - in the case of sending global vIRQ-s vCPU 0's virq_lock. +* Exceptions apply in certain cases for the PV shim. */ struct evtchn_port_ops {void (*init)(struct domain *d,struct evtchn *evtchn);
Ping: [PATCH v5 0/6] evtchn: (not so) recent XSAs follow-on
In reply to Jan BeulichQuoted 6 lines · Jan Beulich
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
Quoted 6 lines
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper forport_is_valid()+evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()
Only patch 4 here has got an ack so far - may I ask for clear feedback as to at least some of these being acceptable (I can see the last one being controversial, and if this was the only one left I probably wouldn't even ping, despite thinking that it helps reduce unecessary overhead).
Jan
Re: Ping: [PATCH v5 0/6] evtchn: (not so) recent XSAs follow-on
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Jan Beulich
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
Quoted 6 lines
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper forport_is_valid()+evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()
Quoted 5 lines
Only patch 4 here has got an ack so far - may I ask for clear feedback as to at least some of these being acceptable (I can see the last one being controversial, and if this was the only one left I probably wouldn't even ping, despite thinking that it helps reduce unecessary overhead).
I left feedback for the series one the previous version (see [1]). It would have been nice is if it was mentionned somewhere as this is still unresolved.
The locking in the event channel is already quite fragile (see recent XSAs, follow-up bugs...). Even if the pattern is used somewhere (as you suggested), I don't think it is good idea to pertain it.
To be clear, I am not saying I don't care about performance. Instead I am trying to find a trade off between code maintenability and performance. So far, I didn't see any data justifying that the extra performance is worth the risk of making a code more fragile.
Cheers,
[1] <[email protected]>
Quoted 3 lines
Jan
Signature · 1 line
Julien Grall
Re: Ping: [PATCH v5 0/6] evtchn: (not so) recent XSAs follow-on
Quoted 23 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Jan Beulich
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
Quoted 6 lines
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper forport_is_valid()+evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()Quoted 5 lines
Only patch 4 here has got an ack so far - may I ask for clear feedback as to at least some of these being acceptable (I can see the last one being controversial, and if this was the only one left I probably wouldn't even ping, despite thinking that it helps reduce unecessary overhead).
Quoted 3 lines
I left feedback for the series one the previous version (see [1]). It would have been nice is if it was mentionned somewhere as this is still unresolved.
I will admit I forgot about the controversy on patch 1. I did, however, reply to your concerns. What didn't happen is the feedback from others that you did ask for.
And of course there are 4 more patches here (one of them having an ack, yes) which could do with feedback. I'm certainly willing, where possible, to further re-order the series such that controversial changes are at its end.
Jan
Re: Ping: [PATCH v5 0/6] evtchn: (not so) recent XSAs follow-on
Quoted 28 lines · Jan Beulich
Quoted 23 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Jan Beulich
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
Quoted 6 lines
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper forport_is_valid()+evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()Quoted 5 lines
Only patch 4 here has got an ack so far - may I ask for clear feedback as to at least some of these being acceptable (I can see the last one being controversial, and if this was the only one left I probably wouldn't even ping, despite thinking that it helps reduce unecessary overhead).
Quoted 3 lines
I left feedback for the series one the previous version (see [1]). It would have been nice is if it was mentionned somewhere as this is still unresolved.
Quoted 8 lines
I will admit I forgot about the controversy on patch 1. I did, however, reply to your concerns. What didn't happen is the feedback from others that you did ask for.
And of course there are 4 more patches here (one of them having an ack, yes) which could do with feedback. I'm certainly willing, where possible, to further re-order the series such that controversial changes are at its end.
I think it would easier to figure out whether the changes are correct if we had some kind of documentation about what/how the per-domain event_lock and the per-event locks are supposed to be used. I don't seem to be able to find any comments regarding how they are to be used.
Regarding the changes itself in patch 1 (which I think has caused part of the controversy here), I'm unsure they are worth it because the functions modified all seem to be non-performance critical:evtchn_status, domain_dump_evtchn_info, flask_get_peer_sid.
So I would say that unless we have clear rules written down for what the per-domain event_lock protects, I would be hesitant to change any of the logic, specially for critical paths.
Thanks, Roger.
Re: Ping: [PATCH v5 0/6] evtchn: (not so) recent XSAs follow-on
Quoted 38 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 23 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Jan Beulich
These are grouped into a series largely because of their origin, not so much because there are (heavy) dependencies among them. The main change from v4 is the dropping of the two patches trying to do away with the double event lock acquires in interdomain channel handling. See also the individual patches.
Quoted 6 lines
1: use per-channel lock where possible
2: convert domain event lock to an r/w one
3: slightly defer lock acquire where possible
4: add helper forport_is_valid()+evtchn_from_port()
5: type adjustments
6: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq()Quoted 5 lines
Only patch 4 here has got an ack so far - may I ask for clear feedback as to at least some of these being acceptable (I can see the last one being controversial, and if this was the only one left I probably wouldn't even ping, despite thinking that it helps reduce unecessary overhead).
Quoted 3 lines
I left feedback for the series one the previous version (see [1]). It would have been nice is if it was mentionned somewhere as this is still unresolved.
Quoted 8 lines
I will admit I forgot about the controversy on patch 1. I did, however, reply to your concerns. What didn't happen is the feedback from others that you did ask for.
And of course there are 4 more patches here (one of them having an ack, yes) which could do with feedback. I'm certainly willing, where possible, to further re-order the series such that controversial changes are at its end.
Quoted 5 lines
I think it would easier to figure out whether the changes are correct if we had some kind of documentation about what/how the per-domain
event_lockand the per-event locks are supposed to be used. I don't seem to be able to find any comments regarding how they are to be used.
I think especially in pass-through code there are a number of cases where the per-domain lock really is being abused, simply for being available without much further thought. I'm not convinced documenting such abuse is going to help the situation. Yet of course I can see that having documentation would make review easier ...
Quoted 8 lines
Regarding the changes itself in patch 1 (which I think has caused part of the controversy here), I'm unsure they are worth it because the functions modified all seem to be non-performance critical:
evtchn_status,domain_dump_evtchn_info,flask_get_peer_sid.So I would say that unless we have clear rules written down for what the per-domain
event_lockprotects, I would be hesitant to change any of the logic, specially for critical paths.
Okay, I'll drop patch 1 and also patch 6 for being overly controversial. Some of the other patches still look worthwhile to me, though. I'll also consider moving the spin->r/w lock conversion last in the series.
Jan