[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/2] events/fifo: don't spin indefinitely when setting LINK



On 11/11/13 16:38, Jan Beulich wrote:
>>>> On 11.11.13 at 17:03, David Vrabel <david.vrabel@xxxxxxxxxx> wrote:
> 
>> +    w = read_atomic(word);
>> +
>> +    for ( try = 0; try < 4; try++ )
>> +    {
>> +        ret = try_set_link(word, &w, link);
>> +        if ( ret >= 0 )
>> +        {
>> +            clear_bit(EVTCHN_FIFO_BUSY, word);
> 
> Considering that this is another atomic operation, wouldn't it
> make sense to have the cmpxchg() at once clear the flag,
> and hence you'd need to clear it here only when ret == 0
> (which I understand isn't the common case)?

The common case (I believe, but haven't measured it) is the first
try_set_link() call without BUSY set.

In the loop, I suspect the mostly likely write by the guest is clearing
LINKED, i.e., ret == 0.

Still, it seems easy enough to have:

    for ( try = 0; try < 4; try++ )
    {
        ret = try_set_link(word, &w, link);
        if ( ret >= 0 )
        {
            if ( ret == 0 )
                clear_bit(EVTCHN_FIFO_BUSY, word);
            return ret;
        }
    }

David

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.