Greetings all. Some small question regarding schedule poll operation hypercall. 1. struct sched_poll poll.timeout is measured in what unit of time? Secs, ms? ns? 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no timeout is used in poll struct how long will I yield the CPU? 3. If I issue the hypercall and the event never comes is it possible to to yield the CPU for ever? Thanks you very much for answering these questions. Daniel Castro -- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote:> Greetings all. > > Some small question regarding schedule poll operation hypercall. > > 1. struct sched_poll poll.timeout is measured in what unit of time? > Secs, ms? ns?It is an absolute system time (rather than a duration), in nanoseconds.> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no > timeout is used in poll struct how long will I yield the CPU?Until one of the specified event channel ports is pending.> 3. If I issue the hypercall and the event never comes is it possible > to to yield the CPU for ever?Yes, if you do not specify a timeout. -- Keir> Thanks you very much for answering these questions. > > Daniel Castro_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser <keir.xen@gmail.com> wrote:> On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote: > >> Greetings all. >> >> Some small question regarding schedule poll operation hypercall. >> >> 1. struct sched_poll poll.timeout is measured in what unit of time? >> Secs, ms? ns? > > It is an absolute system time (rather than a duration), in nanoseconds.really an absolute system time? When the timeout is set and the timeout is reached, the system behaves like if the event had been received? i.e the bit is changed?> >> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >> timeout is used in poll struct how long will I yield the CPU? > > Until one of the specified event channel ports is pending.If the channel port never changes (the event never arrives) then I would yield for ever?> >> 3. If I issue the hypercall and the event never comes is it possible >> to to yield the CPU for ever? > > Yes, if you do not specify a timeout.Keir thanks for the answer. I am trying to read from xenstore, so I have the following: I write on my xenstore ring the query I want, then, hypercall_event_channel_op(EVTCHNOP_send ... If I read the ring inmediatly the answer is not ready so I issue a hypercall_sched_op(SCHEDOP_poll, &poll); But while I am entering the yield state the answer comes, so the event is never seen because it has already been delivered. If I use some way to wait (just for very brief instant) after the event_channel_op send then, when I check the ring the answer is there; And I do not need to yield the CPU. Should I issue the wait after the send, rather than when I am about to read the answer? Thanks, Daniel> > -- Keir > >> Thanks you very much for answering these questions. >> >> Daniel Castro > > >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>>> Daniel Castro 09/20/11 8:18 AM >>> >On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser wrote: >> On 19/09/2011 22:21, "Daniel Castro" wrote: >> >>> Greetings all. >>> >>> Some small question regarding schedule poll operation hypercall. >>> >>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>> Secs, ms? ns? >> >> It is an absolute system time (rather than a duration), in nanoseconds. > >really an absolute system time? > >When the timeout is set and the timeout is reached, the system behaves >like if the event had been received? i.e the bit is changed?No, the bit would remain unset - the poll times out then, it doesn''t "complete".>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >>> timeout is used in poll struct how long will I yield the CPU? >> >> Until one of the specified event channel ports is pending. >If the channel port never changes (the event never arrives) then I >would yield for ever?Yes.>I am trying to read from xenstore, so I have the following: >I write on my xenstore ring the query I want, then, >hypercall_event_channel_op(EVTCHNOP_send ... >If I read the ring inmediatly the answer is not ready so I issue aThat would suggest an ordering problem on either or both sides.>hypercall_sched_op(SCHEDOP_poll, &poll); >But while I am entering the yield state the answer comes, so the event >is never seen because it has already been delivered. > >If I use some way to wait (just for very brief instant) after the >event_channel_op send then, when I check the ring the answer is there; >And I do not need to yield the CPU. > >Should I issue the wait after the send, rather than when I am about to >read the answer?When you start the wait really shouldn''t matter. But ordering needs to be in place so that the event only gets signaled when the consuming side can actually see what the producer put into the shared data structure. Since the signaling is done through a hypercall, there shouldn''t really be anything the producer needs to do (unless your shared data is not in memory). Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, Sep 20, 2011 at 4:33 PM, Jan Beulich <jbeulich@suse.com> wrote:>>>> Daniel Castro 09/20/11 8:18 AM >>> >>On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser wrote: >>> On 19/09/2011 22:21, "Daniel Castro" wrote: >>> >>>> Greetings all. >>>> >>>> Some small question regarding schedule poll operation hypercall. >>>> >>>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>>> Secs, ms? ns? >>> >>> It is an absolute system time (rather than a duration), in nanoseconds. >> >>really an absolute system time? >> >>When the timeout is set and the timeout is reached, the system behaves >>like if the event had been received? i.e the bit is changed? > > No, the bit would remain unset - the poll times out then, it doesn''t > "complete".My Guest VM would get stuck on the hypercall call, like if it was an infinite loop? And once the timeout occurs or the event get delivered, then the hypercall would return, right? Thanks> >>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >>>> timeout is used in poll struct how long will I yield the CPU? >>> >>> Until one of the specified event channel ports is pending. >>If the channel port never changes (the event never arrives) then I >>would yield for ever? > > Yes. > >>I am trying to read from xenstore, so I have the following: >>I write on my xenstore ring the query I want, then, >>hypercall_event_channel_op(EVTCHNOP_send ... >>If I read the ring inmediatly the answer is not ready so I issue a > > That would suggest an ordering problem on either or both sides. > >>hypercall_sched_op(SCHEDOP_poll, &poll); >>But while I am entering the yield state the answer comes, so the event >>is never seen because it has already been delivered. >> >>If I use some way to wait (just for very brief instant) after the >>event_channel_op send then, when I check the ring the answer is there; >>And I do not need to yield the CPU. >> >>Should I issue the wait after the send, rather than when I am about to >>read the answer? > > When you start the wait really shouldn''t matter. But ordering needs > to be in place so that the event only gets signaled when the consuming > side can actually see what the producer put into the shared data > structure. Since the signaling is done through a hypercall, there > shouldn''t really be anything the producer needs to do (unless your > shared data is not in memory). > > Jan > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>>> On 20.09.11 at 10:31, Daniel Castro <evil.dani@gmail.com> wrote: > On Tue, Sep 20, 2011 at 4:33 PM, Jan Beulich <jbeulich@suse.com> wrote: >>>>> Daniel Castro 09/20/11 8:18 AM >>> >>>On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser wrote: >>>> On 19/09/2011 22:21, "Daniel Castro" wrote: >>>> >>>>> Greetings all. >>>>> >>>>> Some small question regarding schedule poll operation hypercall. >>>>> >>>>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>>>> Secs, ms? ns? >>>> >>>> It is an absolute system time (rather than a duration), in nanoseconds. >>> >>>really an absolute system time? >>> >>>When the timeout is set and the timeout is reached, the system behaves >>>like if the event had been received? i.e the bit is changed? >> >> No, the bit would remain unset - the poll times out then, it doesn''t >> "complete". > > My Guest VM would get stuck on the hypercall call, like if it was an > infinite loop?I''m not following. Of course, if you blindly and constantly re-issue the hypercall, then you''d be stuck in a loop. Allowing to prevent that is what the timeout is for.> And once the timeout occurs or the event get delivered, then the > hypercall would return, right?Yes. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, Sep 20, 2011 at 6:08 PM, Jan Beulich <JBeulich@suse.com> wrote:>>>> On 20.09.11 at 10:31, Daniel Castro <evil.dani@gmail.com> wrote: >> On Tue, Sep 20, 2011 at 4:33 PM, Jan Beulich <jbeulich@suse.com> wrote: >>>>>> Daniel Castro 09/20/11 8:18 AM >>> >>>>On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser wrote: >>>>> On 19/09/2011 22:21, "Daniel Castro" wrote: >>>>> >>>>>> Greetings all. >>>>>> >>>>>> Some small question regarding schedule poll operation hypercall. >>>>>> >>>>>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>>>>> Secs, ms? ns? >>>>> >>>>> It is an absolute system time (rather than a duration), in nanoseconds. >>>> >>>>really an absolute system time? >>>> >>>>When the timeout is set and the timeout is reached, the system behaves >>>>like if the event had been received? i.e the bit is changed? >>> >>> No, the bit would remain unset - the poll times out then, it doesn''t >>> "complete". >> >> My Guest VM would get stuck on the hypercall call, like if it was an >> infinite loop? > > I''m not following. Of course, if you blindly and constantly re-issue the > hypercall, then you''d be stuck in a loop. Allowing to prevent that is > what the timeout is for.What I am trying is writing to the xenstore ring, issue the send hypercall, then wait (poll hypercall) for event, then read answer from ring. The waiting is not working, but If I wait enough time, the ring will contain the answer, but apparently I have a problem with my event channel port. So to test this theory I am using event channel status hypercall, and I get: Status 2 (meaning interdomain connected) VCPU 0 The Union reports dom 32752 and port 2. Right now, there are two things that jump to my mind, first when I issue the poll hypercall the system continues execution, instead of yielding CPU unitl event arrives. If it were never to arrive it should yield infinitely, right? Second, the bit is never set. Or it is being undone before I can check it. Thanks, Daniel> >> And once the timeout occurs or the event get delivered, then the >> hypercall would return, right? > > Yes. > > Jan > >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>>> On 20.09.11 at 12:55, Daniel Castro <evil.dani@gmail.com> wrote: > What I am trying is writing to the xenstore ring, issue the send > hypercall, then wait (poll hypercall) for event, then read answer from > ring.That reads as if you do all this from the same thread in the same domain. Which might be your problem, particularly if additionally you use the same event channel for signaling production and consumption.> The waiting is not working, but If I wait enough time, the ring will > contain the answer, but apparently I have a problem with my event > channel port. So to test this theory I am using event channel status > hypercall, and I get: > Status 2 (meaning interdomain connected) > VCPU 0 > The Union reports dom 32752 and port 2.32752 == DOMID_SELF. And I can''t see where the hypercall implementation would return DOMID_SELF here.> Right now, there are two things that jump to my mind, first when I > issue the poll hypercall the system continues execution, instead of > yielding CPU unitl event arrives. If it were never to arrive it should > yield infinitely, right?Without a timeout, yes.> Second, the bit is never set. Or it is being undone before I can check it.That would need to be you to undo it. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, Sep 20, 2011 at 8:57 PM, Jan Beulich <JBeulich@suse.com> wrote:>>>> On 20.09.11 at 12:55, Daniel Castro <evil.dani@gmail.com> wrote: >> What I am trying is writing to the xenstore ring, issue the send >> hypercall, then wait (poll hypercall) for event, then read answer from >> ring. > > That reads as if you do all this from the same thread in the same domain. > Which might be your problem, particularly if additionally you use the > same event channel for signaling production and consumption.Yes you are correct, I have all in the same thread. But I have no other choice, since this is run inside hvmloader when the BIOS is being deployed.>> The waiting is not working, but If I wait enough time, the ring will >> contain the answer, but apparently I have a problem with my event >> channel port. So to test this theory I am using event channel status >> hypercall, and I get: >> Status 2 (meaning interdomain connected) >> VCPU 0 >> The Union reports dom 32752 and port 2. > > 32752 == DOMID_SELF. And I can''t see where the hypercall > implementation would return DOMID_SELF here.Sorry I had a coding error, but it is corrected (I did not call the union correctly, so I ended up calling dom in the main struct). Anyway here is the output corrected: Xenbus rings @0xfeffc000, event channel 2 Event Chn 2 Status 2 VCPU 0. Event is interdomain (2) union dom 983040 union port 42 Thanks, Daniel> >> Right now, there are two things that jump to my mind, first when I >> issue the poll hypercall the system continues execution, instead of >> yielding CPU unitl event arrives. If it were never to arrive it should >> yield infinitely, right? > > Without a timeout, yes. > >> Second, the bit is never set. Or it is being undone before I can check it. > > That would need to be you to undo it. > > Jan > >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, 2011-09-20 at 12:57 +0100, Jan Beulich wrote:> > > The waiting is not working, but If I wait enough time, the ring will > > contain the answer, but apparently I have a problem with my event > > channel port. So to test this theory I am using event channel status > > hypercall, and I get: > > Status 2 (meaning interdomain connected) > > VCPU 0 > > The Union reports dom 32752 and port 2.You can also use lsevtchn in dom0, it lives in the /usr/lib/xen/bin dir. You can give it a domid and therefore check that you can see both ends look sane e.g. if I run it on an hvm domain I see: # lsevtchn 3 1: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 51 2: VCPU 1: Interdomain (Connected) - Remote Domain 0, Port 52 3: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 49 4: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 50 and in dom0 I see: # lsevtchn 0 | grep Domain.3 49: VCPU 0: Interdomain (Connected) - Remote Domain 3, Port 3 50: VCPU 0: Interdomain (Connected) - Remote Domain 3, Port 4 51: VCPU 3: Interdomain (Connected) - Remote Domain 3, Port 1 52: VCPU 3: Interdomain (Connected) - Remote Domain 3, Port 2 i.e. everything matches up.> 32752 == DOMID_SELF. And I can''t see where the hypercall > implementation would return DOMID_SELF here.Daniel, are you 100% sure you are printing/looking at evtchn_status_t->u.interdomain.dom and not evtchn_status_t->dom? Oh wait, you discovered that you weren''t already. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>>> On 20.09.11 at 14:35, Daniel Castro <evil.dani@gmail.com> wrote: > On Tue, Sep 20, 2011 at 8:57 PM, Jan Beulich <JBeulich@suse.com> wrote: >>>>> On 20.09.11 at 12:55, Daniel Castro <evil.dani@gmail.com> wrote: >>> What I am trying is writing to the xenstore ring, issue the send >>> hypercall, then wait (poll hypercall) for event, then read answer from >>> ring. >> >> That reads as if you do all this from the same thread in the same domain. >> Which might be your problem, particularly if additionally you use the >> same event channel for signaling production and consumption. > > Yes you are correct, I have all in the same thread. But I have no > other choice, since this is run inside hvmloader when the BIOS is > being deployed.What do you need the synchronization/signaling/polling for then? Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Tue, 2011-09-20 at 13:35 +0100, Daniel Castro wrote:> On Tue, Sep 20, 2011 at 8:57 PM, Jan Beulich <JBeulich@suse.com> wrote:> > 32752 == DOMID_SELF. And I can''t see where the hypercall > > implementation would return DOMID_SELF here. > Sorry I had a coding error, but it is corrected (I did not call the > union correctly, so I ended up calling dom in the main struct). > Anyway here is the output corrected: > Xenbus rings @0xfeffc000, event channel 2 > Event Chn 2 Status 2 VCPU 0. > Event is interdomain (2) union dom 983040 union port 42That''s dom 0xf0000 but domid_t is a 16 bit value so there''s no way you really have that value -- I think you must have used the wrong printf format specifier. The lower 16 bits are 0 which makes sense. You could confirm using lsevtchn. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2011-Sep-21 01:28 UTC
Re: [Xen-devel] Sched_op hypercall small questions
On 09/19/2011 11:17 PM, Daniel Castro wrote:> On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser <keir.xen@gmail.com> wrote: >> On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote: >> >>> Greetings all. >>> >>> Some small question regarding schedule poll operation hypercall. >>> >>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>> Secs, ms? ns? >> It is an absolute system time (rather than a duration), in nanoseconds. > really an absolute system time? > > When the timeout is set and the timeout is reached, the system behaves > like if the event had been received? i.e the bit is changed?You specify the timeout in the the form "wake up by time t". If t is in the past, it times out immediately.>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >>> timeout is used in poll struct how long will I yield the CPU? >> Until one of the specified event channel ports is pending. > If the channel port never changes (the event never arrives) then I > would yield for ever?If you have events unmasked and you get an unmasked event, then it will go into the event handler.>>> 3. If I issue the hypercall and the event never comes is it possible >>> to to yield the CPU for ever? >> Yes, if you do not specify a timeout. > Keir thanks for the answer. > > I am trying to read from xenstore, so I have the following: > I write on my xenstore ring the query I want, then, > hypercall_event_channel_op(EVTCHNOP_send ... > If I read the ring inmediatly the answer is not ready so I issue a > hypercall_sched_op(SCHEDOP_poll, &poll); > But while I am entering the yield state the answer comes, so the event > is never seen because it has already been delivered.It generally only makes sense to poll on masked events.> > If I use some way to wait (just for very brief instant) after the > event_channel_op send then, when I check the ring the answer is there; > And I do not need to yield the CPU. > > Should I issue the wait after the send, rather than when I am about to > read the answer?What environment is this in? J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Wed, Sep 21, 2011 at 10:28 AM, Jeremy Fitzhardinge <jeremy@goop.org> wrote:> On 09/19/2011 11:17 PM, Daniel Castro wrote: >> On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser <keir.xen@gmail.com> wrote: >>> On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote: >>> >>>> Greetings all. >>>> >>>> Some small question regarding schedule poll operation hypercall. >>>> >>>> 1. struct sched_poll poll.timeout is measured in what unit of time? >>>> Secs, ms? ns? >>> It is an absolute system time (rather than a duration), in nanoseconds. >> really an absolute system time? >> >> When the timeout is set and the timeout is reached, the system behaves >> like if the event had been received? i.e the bit is changed? > > You specify the timeout in the the form "wake up by time t". If t is in > the past, it times out immediately. > >>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >>>> timeout is used in poll struct how long will I yield the CPU? >>> Until one of the specified event channel ports is pending. >> If the channel port never changes (the event never arrives) then I >> would yield for ever? > > If you have events unmasked and you get an unmasked event, then it will > go into the event handler.My vcpu[0].evntchn_upcall_mask is 0, does this prevents the guest from receiving events? would that also explain why poll hypercall returns immediately? According to Xen''s Definitive Guide evntchn_upcall_mask is unset at boot (my case exactly) so if it is 0 from the start and the guest (me) has to change it to 1 in order to receive events. How can I change the flag, I tried changing the value but it does not work like that apparently. Thanks> >>>> 3. If I issue the hypercall and the event never comes is it possible >>>> to to yield the CPU for ever? >>> Yes, if you do not specify a timeout. >> Keir thanks for the answer. >> >> I am trying to read from xenstore, so I have the following: >> I write on my xenstore ring the query I want, then, >> hypercall_event_channel_op(EVTCHNOP_send ... >> If I read the ring inmediatly the answer is not ready so I issue a >> hypercall_sched_op(SCHEDOP_poll, &poll); >> But while I am entering the yield state the answer comes, so the event >> is never seen because it has already been delivered. > > It generally only makes sense to poll on masked events. > >> >> If I use some way to wait (just for very brief instant) after the >> event_channel_op send then, when I check the ring the answer is there; >> And I do not need to yield the CPU. >> >> Should I issue the wait after the send, rather than when I am about to >> read the answer? > > What environment is this in? > > J >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ -- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Thu, 2011-09-22 at 06:41 +0100, Daniel Castro wrote:> On Wed, Sep 21, 2011 at 10:28 AM, Jeremy Fitzhardinge <jeremy@goop.org> wrote: > > On 09/19/2011 11:17 PM, Daniel Castro wrote: > >> On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser <keir.xen@gmail.com> wrote: > >>> On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote: > >>> > >>>> Greetings all. > >>>> > >>>> Some small question regarding schedule poll operation hypercall. > >>>> > >>>> 1. struct sched_poll poll.timeout is measured in what unit of time? > >>>> Secs, ms? ns? > >>> It is an absolute system time (rather than a duration), in nanoseconds. > >> really an absolute system time? > >> > >> When the timeout is set and the timeout is reached, the system behaves > >> like if the event had been received? i.e the bit is changed? > > > > You specify the timeout in the the form "wake up by time t". If t is in > > the past, it times out immediately. > > > >>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no > >>>> timeout is used in poll struct how long will I yield the CPU? > >>> Until one of the specified event channel ports is pending. > >> If the channel port never changes (the event never arrives) then I > >> would yield for ever? > > > > If you have events unmasked and you get an unmasked event, then it will > > go into the event handler. > > My vcpu[0].evntchn_upcall_mask is 0, does this prevents the guest from > receiving events?IIRC it''s vice versa: setting it to 1 prevents the guest from receiving events.> would that also explain why poll hypercall returns > immediately?I don''t see any reference to the masks in xen/common/schedule.c:do_poll() so I don''t think so.> According to Xen''s Definitive Guide evntchn_upcall_mask > is unset at boot (my case exactly) so if it is 0 from the start and > the guest (me) has to change it to 1 in order to receive events.I think that''s the wrong way round.> How can I change the flag, I tried changing the value but it does not work > like that apparently.evtchn_upcall_mask is the global mask but you may also need to unmask the specific evtchn, which means clearing the relevant bit in evtchn_mask.> > Thanks > > > >>>> 3. If I issue the hypercall and the event never comes is it possible > >>>> to to yield the CPU for ever? > >>> Yes, if you do not specify a timeout. > >> Keir thanks for the answer. > >> > >> I am trying to read from xenstore, so I have the following: > >> I write on my xenstore ring the query I want, then, > >> hypercall_event_channel_op(EVTCHNOP_send ... > >> If I read the ring inmediatly the answer is not ready so I issue a > >> hypercall_sched_op(SCHEDOP_poll, &poll); > >> But while I am entering the yield state the answer comes, so the event > >> is never seen because it has already been delivered. > > > > It generally only makes sense to poll on masked events. > > > >> > >> If I use some way to wait (just for very brief instant) after the > >> event_channel_op send then, when I check the ring the answer is there; > >> And I do not need to yield the CPU. > >> > >> Should I issue the wait after the send, rather than when I am about to > >> read the answer? > > > > What environment is this in? > > > > J > > > > > > -- > +-=====---------------------------+ > | +---------------------------------+ | This space intentionally blank > for notetaking. > | | | Daniel Castro, | > | | | Consultant/Programmer.| > | | | U Andes | > +-------------------------------------+ > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Thu, Sep 22, 2011 at 3:30 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:> On Thu, 2011-09-22 at 06:41 +0100, Daniel Castro wrote: >> On Wed, Sep 21, 2011 at 10:28 AM, Jeremy Fitzhardinge <jeremy@goop.org> wrote: >> > On 09/19/2011 11:17 PM, Daniel Castro wrote: >> >> On Tue, Sep 20, 2011 at 2:41 PM, Keir Fraser <keir.xen@gmail.com> wrote: >> >>> On 19/09/2011 22:21, "Daniel Castro" <evil.dani@gmail.com> wrote: >> >>> >> >>>> Greetings all. >> >>>> >> >>>> Some small question regarding schedule poll operation hypercall. >> >>>> >> >>>> 1. struct sched_poll poll.timeout is measured in what unit of time? >> >>>> Secs, ms? ns? >> >>> It is an absolute system time (rather than a duration), in nanoseconds. >> >> really an absolute system time? >> >> >> >> When the timeout is set and the timeout is reached, the system behaves >> >> like if the event had been received? i.e the bit is changed? >> > >> > You specify the timeout in the the form "wake up by time t". If t is in >> > the past, it times out immediately. >> > >> >>>> 2. After issuing the hypercall_sched_op(SCHEDOP_poll, &poll); if no >> >>>> timeout is used in poll struct how long will I yield the CPU? >> >>> Until one of the specified event channel ports is pending. >> >> If the channel port never changes (the event never arrives) then I >> >> would yield for ever? >> > >> > If you have events unmasked and you get an unmasked event, then it will >> > go into the event handler. >> >> My vcpu[0].evntchn_upcall_mask is 0, does this prevents the guest from >> receiving events? > > IIRC it''s vice versa: setting it to 1 prevents the guest from receiving > events. > >> would that also explain why poll hypercall returns >> immediately? > > I don''t see any reference to the masks in > xen/common/schedule.c:do_poll() so I don''t think so. > >> According to Xen''s Definitive Guide evntchn_upcall_mask >> is unset at boot (my case exactly) so if it is 0 from the start and >> the guest (me) has to change it to 1 in order to receive events. > > I think that''s the wrong way round. > >> How can I change the flag, I tried changing the value but it does not work >> like that apparently. > > evtchn_upcall_mask is the global mask but you may also need to unmask > the specific evtchn, which means clearing the relevant bit in > evtchn_mask.Thanks for the answer Ian, one question: If I do not manually change the mask bit, then after writing to the ring and the response arrives how can I be sure that xenstore is delivering an event? I am suspecting that xenstore does not use event notification for simple read and write operations. Could I be right?> >> >> Thanks >> > >> >>>> 3. If I issue the hypercall and the event never comes is it possible >> >>>> to to yield the CPU for ever? >> >>> Yes, if you do not specify a timeout. >> >> Keir thanks for the answer. >> >> >> >> I am trying to read from xenstore, so I have the following: >> >> I write on my xenstore ring the query I want, then, >> >> hypercall_event_channel_op(EVTCHNOP_send ... >> >> If I read the ring inmediatly the answer is not ready so I issue a >> >> hypercall_sched_op(SCHEDOP_poll, &poll); >> >> But while I am entering the yield state the answer comes, so the event >> >> is never seen because it has already been delivered. >> > >> > It generally only makes sense to poll on masked events. >> > >> >> >> >> If I use some way to wait (just for very brief instant) after the >> >> event_channel_op send then, when I check the ring the answer is there; >> >> And I do not need to yield the CPU. >> >> >> >> Should I issue the wait after the send, rather than when I am about to >> >> read the answer? >> > >> > What environment is this in? >> > >> > J >> > >> >> >> >> -- >> +-=====---------------------------+ >> | +---------------------------------+ | This space intentionally blank >> for notetaking. >> | | | Daniel Castro, | >> | | | Consultant/Programmer.| >> | | | U Andes | >> +-------------------------------------+ >> >> >> > > >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Thu, 2011-09-22 at 08:43 +0100, Daniel Castro wrote:> On Thu, Sep 22, 2011 at 3:30 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:> Thanks for the answer Ian, one question: If I do not manually change > the mask bit, then after writing to the ring and the response arrives > how can I be sure that xenstore is delivering an event?Add some printfs in the daemon?> I am suspecting that xenstore does not use event notification for simple > read and write operations. Could I be right?I don''t think so, how else would it notify the client end that it should look into the ring? In the daemon the do_read() function calls the same common send_reply() as most (all?) other commands. send_reply queues a message on conn->out_list. Later on write_messages() dequeues it and calls the connections write method, which is writechn() in this case (the other case is a local socket connection which uses writefd but isn''t relevant here). writechn() has an xc_evtchn_notify() at the end. Ian.> > > > >> > >> Thanks > >> > > >> >>>> 3. If I issue the hypercall and the event never comes is it possible > >> >>>> to to yield the CPU for ever? > >> >>> Yes, if you do not specify a timeout. > >> >> Keir thanks for the answer. > >> >> > >> >> I am trying to read from xenstore, so I have the following: > >> >> I write on my xenstore ring the query I want, then, > >> >> hypercall_event_channel_op(EVTCHNOP_send ... > >> >> If I read the ring inmediatly the answer is not ready so I issue a > >> >> hypercall_sched_op(SCHEDOP_poll, &poll); > >> >> But while I am entering the yield state the answer comes, so the event > >> >> is never seen because it has already been delivered. > >> > > >> > It generally only makes sense to poll on masked events. > >> > > >> >> > >> >> If I use some way to wait (just for very brief instant) after the > >> >> event_channel_op send then, when I check the ring the answer is there; > >> >> And I do not need to yield the CPU. > >> >> > >> >> Should I issue the wait after the send, rather than when I am about to > >> >> read the answer? > >> > > >> > What environment is this in? > >> > > >> > J > >> > > >> > >> > >> > >> -- > >> +-=====---------------------------+ > >> | +---------------------------------+ | This space intentionally blank > >> for notetaking. > >> | | | Daniel Castro, | > >> | | | Consultant/Programmer.| > >> | | | U Andes | > >> +-------------------------------------+ > >> > >> > >> > > > > > > > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Thu, Sep 22, 2011 at 5:00 PM, Ian Campbell <Ian.Campbell@eu.citrix.com> wrote:> On Thu, 2011-09-22 at 08:43 +0100, Daniel Castro wrote: >> On Thu, Sep 22, 2011 at 3:30 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote: > >> Thanks for the answer Ian, one question: If I do not manually change >> the mask bit, then after writing to the ring and the response arrives >> how can I be sure that xenstore is delivering an event? > > Add some printfs in the daemon? > >> I am suspecting that xenstore does not use event notification for simple >> read and write operations. Could I be right? > > I don''t think so, how else would it notify the client end that it should > look into the ring? > > In the daemon the do_read() function calls the same common send_reply() > as most (all?) other commands. send_reply queues a message on > conn->out_list. Later on write_messages() dequeues it and calls the > connections write method, which is writechn() in this case (the other > case is a local socket connection which uses writefd but isn''t relevant > here). writechn() has an xc_evtchn_notify() at the end.You are right as usual, using trace in the deamon in function writechn I get: DEBUG notify dom 1 on port 42 Form /usr/lib/xen/bin/lsevtchn I get: 42: VCPU 0: Interdomain (Connected) - Remote Domain 1, Port 2 And from the guest I have: Event is interdomain to dom 0 port 42 So they are interconected and the xenstore deamon is delivering the event. I am going to check the ring waiting function there has to be something I am missing.... thanks, Daniel> > Ian. > >> >> > >> >> >> >> Thanks >> >> > >> >> >>>> 3. If I issue the hypercall and the event never comes is it possible >> >> >>>> to to yield the CPU for ever? >> >> >>> Yes, if you do not specify a timeout. >> >> >> Keir thanks for the answer. >> >> >> >> >> >> I am trying to read from xenstore, so I have the following: >> >> >> I write on my xenstore ring the query I want, then, >> >> >> hypercall_event_channel_op(EVTCHNOP_send ... >> >> >> If I read the ring inmediatly the answer is not ready so I issue a >> >> >> hypercall_sched_op(SCHEDOP_poll, &poll); >> >> >> But while I am entering the yield state the answer comes, so the event >> >> >> is never seen because it has already been delivered. >> >> > >> >> > It generally only makes sense to poll on masked events. >> >> > >> >> >> >> >> >> If I use some way to wait (just for very brief instant) after the >> >> >> event_channel_op send then, when I check the ring the answer is there; >> >> >> And I do not need to yield the CPU. >> >> >> >> >> >> Should I issue the wait after the send, rather than when I am about to >> >> >> read the answer? >> >> > >> >> > What environment is this in? >> >> > >> >> > J >> >> > >> >> >> >> >> >> >> >> -- >> >> +-=====---------------------------+ >> >> | +---------------------------------+ | This space intentionally blank >> >> for notetaking. >> >> | | | Daniel Castro, | >> >> | | | Consultant/Programmer.| >> >> | | | U Andes | >> >> +-------------------------------------+ >> >> >> >> >> >> >> > >> > >> > >> >> >> > > >-- +-=====---------------------------+ | +---------------------------------+ | This space intentionally blank for notetaking. | | | Daniel Castro, | | | | Consultant/Programmer.| | | | U Andes | +-------------------------------------+ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel