From: Keir Fraser Subject: Re: xen console output delay Date: Sun, 16 Mar 2008 11:10:12 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2087640868==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Dan Kuebrich Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --===============2087640868== Content-type: multipart/alternative; boundary="B_3288510618_7553670" > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3288510618_7553670 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable I don=B9t know what your evtchn_mask_* operations do, so I cannot judge why changing the location of the yield makes a difference. The correct thing to do in an idle loop is block: 1. Disable event delivery (evtchn_upcall_mask). 2. Check for work to do (in your case check for threads on run queue) 3. SCHEDOP_block (automatically reenables event delivery) When you block you stop receiving periodic timer ticks. If you wake up threads on timer ticks then you may want to set a one-shot timer before blocking. -- Keir On 16/3/08 00:18, "Dan Kuebrich" wrote: > Keir, >=20 > Your comment about a possible scheduling delay made me think about the id= le > loop of the fledgling operating system. I discovered that I needed to ad= d a > SCHEDOP_yield call in the "no runnable threads right now" loop in the > scheduler--that solved the output delay. However, if I put the call wher= e it > intuitively seems it should go, the delay still exists, whereas if I put = it in > a slightly different location, it works fine. >=20 > void sched_switch(void) > { > kthread_t *oldthr =3D curthr, *newthr; >=20 > evtchn_mask_t evtchn_mask; > evtchn_mask_save(&evtchn_mask); >=20 > // while no runnable threads are available... > while (ktqueue_empty(&kg_runq)) { >=20 > evtchn_unmask_all(); >=20 > //XXX this is where I think the yield should be XXX >=20 > evtchn_mask_restore(&evtchn_mask); >=20 > // and this is where I put it to make it work right > HYPERVISOR_sched_op(SCHEDOP_yield, 0); > } > // ... perform context switch, restore event channel mask of new thre= ad > ... > } >=20 > Anyone have an idea why this is? And is this even the right way to idle = in a > Xen OS? It's working now, but I'm not very satisfied by the solution. >=20 > Thanks again, > dan >=20 >=20 > On Fri, Mar 14, 2008 at 3:37 PM, Keir Fraser > wrote: >> Sounds like it isn't due to the rate limiting then. I'm not sure what it >> might be in that case. Is your system uniprocessor and hence this could = be >> scheduling latency? >>=20 >> -- Keir >>=20 >>=20 >> On 14/3/08 19:19, "Dan Kuebrich" wrote: >>=20 >>> Keir, >>>=20 >>> Thanks for the quick response. I did a little investigation and still = have >>> questions about this. >>>=20 >>> 1. Is this rate-limiting implemented in xen 3.0.3 (which is what I'm >>> running)? I couldn't find anything in console/daemon/io.c. >>>=20 >>> 2. If rate limiting were implemented, it doesn't seem to be flooded >>> entirely. There should be only 1-2 event-channel notifications occurri= ng >>> per second. Additionally, sometimes printing one character, waiting a >>> second, then printing a second character (and thus triggering another >>> notification) does not "flush" them--it still takes several seconds aft= er >>> before flushing occurs. >>>=20 >>> Is there another possibility for what is going on here? >>>=20 >>> dan >>>=20 >>> On Fri, Mar 14, 2008 at 5:07 AM, Keir Fraser >>> wrote: >>>> Output to the console is rate-limited to 30 event-channel notification= s per >>>> 200ms. You could be hitting that limit: see the RATE_LIMIT_ values in >>>> tools/console/daemon/io.c: the logic is fairly easily defeated to test= if >>>> that is what is stalling you. Batching your notifications a bit (e.g.,= once >>>> per console line) might actually smooth things out a bit. >>>>=20 >>>> -- Keir >>>>=20 >>>>=20 >>>> On 14/3/08 00:26, "Dan Kuebrich" wrote: >>>>=20 >>>>> Hello all, >>>>>=20 >>>>> I am working on writing a console driver for an OS on Xen and am runn= ing >>>>> into a strange delay regarding console output. I am using the ring b= uffer >>>>> (not the hypercall) for output, and signaling with >>>>> HYPERVISOR_event_channel_op after every character is written. >>>>>=20 >>>>> The delay seems to occur _only_sometimes_ after a character is output= . I >>>>> have tracked it using GDB and noted that the delay happens after the >>>>> characters are put into the ring buffer and the event channel is noti= fied. >>>>> Sometimes, the character appears instantly in the console output. Ot= her >>>>> times, it takes several seconds to show up. >>>>>=20 >>>>> I am using the standard xenconsole reader. Is there some sort of >>>>> time-based buffering that occurs in the console output buffer? >>>>>=20 >>>>> The result I would like to achieve is latency-free console output. >>>>>=20 >>>>> Thanks, >>>>> dan >>>>>=20 >>>>>=20 >>>>> _______________________________________________ >>>>> Xen-devel mailing list >>>>> Xen-devel@lists.xensource.com >>>>> http://lists.xensource.com/xen-devel >>>>=20 >>>=20 >>>=20 >>=20 >=20 >=20 --B_3288510618_7553670 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Re: [Xen-devel] xen console output delay I don= ’t know what your evtchn_mask_* operations do, so I cannot judge why c= hanging the location of the yield makes a difference.

The correct thing to do in an idle loop is block:
 1. Disable event delivery (evtchn_upcall_mask).
 2. Check for work to do (in your case check for threads on run queue)=
 3. SCHEDOP_block (automatically reenables event delivery)

When you block you stop receiving periodic timer ticks. If you wake up thre= ads on timer ticks then you may want to set a one-shot timer before blocking= .

 -- Keir

On 16/3/08 00:18, "Dan Kuebrich" <dan.kuebrich@gmail.com> w= rote:

Keir,

Your comment about a possible scheduling delay made me think about the idle= loop of the fledgling operating system.  I discovered that I needed to= add a SCHEDOP_yield call in the "no runnable threads right now" l= oop in the scheduler--that solved the output delay.  However, if I put = the call where it intuitively seems it should go, the delay still exists, wh= ereas if I put it in a slightly different location, it works fine.

void sched_switch(void)
{
    kthread_t *oldthr =3D curthr, *newthr;

    evtchn_mask_t evtchn_mask;
    evtchn_mask_save(&evtchn_mask);

    // while no runnable threads are available...
    while (ktqueue_empty(&kg_runq)) {

        evtchn_unmask_all();

        //XXX this is where I think= the yield should be XXX

        evtchn_mask_restore(&ev= tchn_mask);

        // and this is where I put = it to make it work right
        HYPERVISOR_sched_op(SCHEDOP= _yield, 0);
    }
    // ... perform context switch, restore event channe= l mask of new thread ...
}

Anyone have an idea why this is?  And is this even the right way to id= le in a Xen OS?  It's working now, but I'm not very satisfied by the so= lution.

Thanks again,
dan


On Fri, Mar 14, 2008 at 3:37 PM, Keir Fraser <keir.fraser@eu.citrix.com&= gt; wrote:
Sounds like it isn't due to the rate limiting then. I'm= not sure what it might be in that case. Is your system uniprocessor and hen= ce this could be scheduling latency?

 -- Keir


On 14/3/08 19:19, "Dan Kuebrich" <dan.kuebrich@gmail.com> w= rote:

Keir,

Thanks for the quick response.  I did a little investigation and still= have questions about this.

1. Is this rate-limiting implemented in xen 3.0.3 (which is what I'm runnin= g)?  I couldn't find anything in console/daemon/io.c.

2. If rate limiting were implemented, it doesn't seem to be flooded entirel= y.  There should be only 1-2 event-channel notifications occurring per = second.  Additionally, sometimes printing one character, waiting a seco= nd, then printing a second character (and thus triggering another notificati= on) does not "flush" them--it still takes several seconds after be= fore flushing occurs.

Is there another possibility for what is going on here?

dan

On Fri, Mar 14, 2008 at 5:07 AM, Keir Fraser <keir.fraser@eu.citrix.com&= gt; wrote:
Output to the console is rate-limited to 30 event-chann= el notifications per 200ms. You could be hitting that limit: see the RATE_LI= MIT_ values in tools/console/daemon/io.c: the logic is fairly easily defeate= d to test if that is what is stalling you. Batching your notifications a bit= (e.g., once per console line) might actually smooth things out a bit.

 -- Keir


On 14/3/08 00:26, "Dan Kuebrich" <dan.kuebrich@gmail.com> w= rote:

Hello all,

I am working on writing a console driver for an OS on Xen and am running in= to a strange delay regarding console output.  I am using the ring buffe= r (not the hypercall) for output, and signaling with HYPERVISOR_event_channe= l_op after every character is written.

The delay seems to occur _only_sometimes_ after a character is output. &nbs= p;I have tracked it using GDB and noted that the delay happens after the cha= racters are put into the ring buffer and the event channel is notified. &nbs= p;Sometimes, the character appears instantly in the console output.  Ot= her times, it takes several seconds to show up.

I am using the standard xenconsole reader.  Is there some sort of time= -based buffering that occurs in the console output buffer?

The result I would like to achieve is latency-free console output.

Thanks,
dan


____________________= ___________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/x= en-devel







--B_3288510618_7553670-- --===============2087640868== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============2087640868==--