Hi, everyone When I trace code of hypervisor, I can''t find the use of evtchn_upcall_mask. As the comment in include/public/xen.h, evtchn_upcall_mask is read before making an event upcall to the guest. After I search the mailing lists, I find the following changelog: [XEN] Replace direct common-code access of evtchn_upcall_mask with local_event_delivery_* accessors.<http://xen.markmail.org/message/4ushwnkx6mhlcz42?q=evtchn_set_pending&page=18> diff -r ea4829e30092 -r ddc25d4ebf60 xen/common/event_channel.c --- a/xen/common/event_channel.c Sat Jun 10 11:05:11 2006 +0100 +++ b/xen/common/event_channel.c Sat Jun 10 11:07:11 2006 +0100 @@ -499,7 +499,7 @@ void evtchn_set_pending(struct vcpu *v, evtchn_notify(v); } else if ( unlikely(test_bit(_VCPUF_blocked, &v->vcpu_flags) && - v->vcpu_info->* evtchn_upcall_mask*) ) + !local_event_delivery_is_enabled()) ) [XEN] Fix SCHEDOP_poll to work even when event channels are not bound to the polling VCPU.<http://xen.markmail.org/search/?q=local_event_delivery_is_enabled#query:local_event_delivery_is_enabled%20order%3Adate-backward+page:2+mid:pjznbfjzcp4sw33d+state:results> diff -r d7543cff88ae -r aced0ee216aa xen/common/event_channel.c --- a/xen/common/event_channel.c Sun Jun 11 14:33:16 2006 +0100 +++ b/xen/common/event_channel.c Sun Jun 11 19:23:31 2006 +0100 @@ -498,14 +498,14 @@ void evtchn_set_pending(struct vcpu *v, { evtchn_notify(v); } - else if ( unlikely(test_bit(_VCPUF_blocked, &v->vcpu_flags) && - *! local_event_delivery_is_enabled*()) ) - { - /* - * Blocked and masked will usually mean that the VCPU executed - * SCHEDOP_poll. Kick the VCPU in case this port is in its poll list. - */ - vcpu_unblock(v); + + /* Check if some VCPU might be polling for this event. */ + if ( unlikely(test_bit(_DOMF_polling, &d->domain_flags)) && + likely(test_and_clear_bit(_DOMF_polling, &d->domain_flags)) ) + { + for_each_vcpu ( d, v ) + if ( test_and_clear_bit(_VCPUF_polling, &v->vcpu_flags) ) + vcpu_unblock(v); } } I think evtchn_set_pending() is the function to decide whether to make an event upcall to the guest, and the first patch is the last patch which I see evtchn_upcall_mask in evtchn_set_pending(). I also find that local_event_delivery_is_enabled() is not used in hypervisor. I don''t know if i understand this part correctly, it seems that evtchn_upcall_mask is useless. Can somebody tell me the use of evtchn_upcall_mask? Any suggestions will be greatly appreciated, thanks in advance. -- Best regards, Yao-Jing Wen _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
On Fri, 2012-09-21 at 14:12 +0100, Yaogun Wen wrote:> I don''t know if i understand this part correctly, it seems that > evtchn_upcall_mask is useless.It is read from assembly code (entry.S) accessed via VCPUINFO_upcall_mask which is defined using the asm-offsets.c mechanism. local_event_delivery_is_enabled seems to be redundant these days. Ian.
>>> On 21.09.12 at 15:12, Yaogun Wen <techno.geek.0x01@gmail.com> wrote: > I think evtchn_set_pending() is the function to decide whether to make an > event upcall to the guest, and the first patch is the last patch which I > see evtchn_upcall_mask in evtchn_set_pending().Setting an event channel pending isn''t tied to the channel being unmasked - in particular, for polled event channels, one would keep them masked permanently, yet still expect events to be signaled. The mask really controls whether an upcall is actually permitted (just like EFLAGS.IF controls whether interrupts can be injected).> I don''t know if i understand this part correctly, it seems > that evtchn_upcall_mask is useless. > Can somebody tell me the use of evtchn_upcall_mask?If you''re looking at current -unstable, then you may get confused by c/s 25875:dd40b43f16bc ("x86: use only a single branch for upcall-pending exit path checks") - this one removes explicit uses of VCPUINFO_upcall_mask, leveraging the fact that the field is adjacent to VCPUINFO_upcall_pending. If you''re looking at 4.2 or earlier, I''m unclear about your confusion. Jan
On 2012/9/21 at pm 9:24 Ian Campbell wrote:> It is read from assembly code (entry.S) accessed via > VCPUINFO_upcall_mask which is defined using the asm-offsets.c mechanism. > > local_event_delivery_is_enabled seems to be redundant these days.Thank you for your guidance. :) But I still have some questions, please keep reading. On 2012/9/21 at pm 9:29 Jan Beulich wrote:> Setting an event channel pending isn''t tied to the channel being > unmasked - in particular, for polled event channels, one would > keep them masked permanently, yet still expect events to be > signaled. The mask really controls whether an upcall is actually > permitted (just like EFLAGS.IF controls whether interrupts can > be injected).This explanation helps me to understand the meaning of VCPUINFO_upcall_mask. I don''t know x86 assembly language, but according to your explanation, it seems that guest which only have masked channel will still receive the events. But from the comment of vcpu_info struct, it says "The mask (evtchn_upcall_mask) is read before making an event upcall to the guest". So, which one is correct? -- Best regards, Yao-Jing Wen
>>> On 24.09.12 at 04:50, Yaogun Wen <techno.geek.0x01@gmail.com> wrote: >> Setting an event channel pending isn''t tied to the channel being >> unmasked - in particular, for polled event channels, one would >> keep them masked permanently, yet still expect events to be >> signaled. The mask really controls whether an upcall is actually >> permitted (just like EFLAGS.IF controls whether interrupts can >> be injected). > This explanation helps me to understand the meaning of VCPUINFO_upcall_mask. > I don''t know x86 assembly language, but according to your explanation, > it seems that guest which only have masked channel will still receive > the events. > But from the comment of vcpu_info struct, it says "The mask > (evtchn_upcall_mask) is read before making an event upcall to the > guest". > So, which one is correct?Both. If I''m understanding correctly, you''re mixing up per-channel masks (evtchn_mask[]) and the global delivery mask (evtchn_upcall_mask). If that''s not the case, I''m afraid I don''t follow what your concern is. Jan