WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] fooey. no interrupts.

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] fooey. no interrupts.
From: ron minnich <rminnich@xxxxxxxx>
Date: Mon, 9 Aug 2004 21:15:35 -0600 (MDT)
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 10 Aug 2004 04:36:08 +0100
Envelope-to: steven.hand@xxxxxxxxxxxx
In-reply-to: <E1BuJWK-0000lP-00@xxxxxxxxxxxxxxxxx>
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
I've got a question about this code. 


static inline void evtchn_set_pending(struct domain *d, int port)
{
    shared_info_t *s = d->shared_info;
    if ( !test_and_set_bit(port,    &s->evtchn_pending[0]) &&
         !test_bit        (port,    &s->evtchn_mask[0])    &&
         !test_and_set_bit(port>>5, &s->evtchn_pending_sel) )
    {
        /* The VCPU pending flag must be set /after/ update to 
                        evtchn-pend. */
        s->vcpu_data[0].evtchn_upcall_pending = 1;
        guest_async_callback(d);
    }
}

So you'll get an upcall IFF: the bit 'port' in evtchn_pending WAS 0, the 
bit 'port' in the mask IS 0, and the bit 'port >> 5' in the 
evtchn_pending_sel WAS 0. 

OK, here's my question: suppose the first test_and_set_bit fails because
the bit in evtchn_pending[0] was already set? You'll never get called,
that's what, as far as I can tell. And this is exactly what I'm seeing.  
I've got bits 0,1,2 set in evtchn_pending, but the guest_async_callback is
never happening, since the test_and_set_bit returns 1.  I'm missing an
interrupt, due to a plethora of debug prints in my kernel, and I'm not
seeing another one.

To me, it looks like I'm exercising a race condition in this function 
shown above. 

Here is my question: why isn't this code something like:

static inline void evtchn_set_pending(struct domain *d, int port)
{
    shared_info_t *s = d->shared_info;
    set_bit(port, &s->evtchn_pending[0]);
    if ( !test_bit        (port,    &s->evtchn_mask[0])    &&
         !test_and_set_bit(port>>5, &s->evtchn_pending_sel) )
    {
        /* The VCPU pending flag must be set /after/ update to 
                evtchn-pend. */
        s->vcpu_data[0].evtchn_upcall_pending = 1;
        guest_async_callback(d);
    }
}

In other words, I don't see the reason for the first test_and_set_bit, 
given that the bit may have been set by an earlier call to 
evtchn_set_pending, masked by the mask, and then the next time you call 
the first test_and_set_bit will fail. 

So, what's the reason for that first TAS? 

thanks

ron

-- 
LANL CCS-1 email flavor:
***** Correspondence   [X]
***** DUSA LACSI-HW    [ ]
***** DUSA LACSI-OS    [ ]
***** DUSA LACSI-CS    [ ]




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel