|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 02/12] evtchn: avoid race in get_xen_consumer()
On 29.09.2020 17:44, Paul Durrant wrote:
>> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of Jan
>> Beulich
>> Sent: 28 September 2020 11:57
>>
>> @@ -81,7 +82,7 @@ static uint8_t get_xen_consumer(xen_even
>> for ( i = 0; i < ARRAY_SIZE(xen_consumers); i++ )
>> {
>> if ( xen_consumers[i] == NULL )
>> - xen_consumers[i] = fn;
>> + (void)cmpxchg(&xen_consumers[i], NULL, fn);
>> if ( xen_consumers[i] == fn )
>
> Why not use the return from cmpxchg() to determine success and break
> out of the loop rather than re-accessing the global array?
That's an option, in which case I wouldn't be sure anymore whether
adding __read_mostly to the definition of xen_consumers[] is
appropriate. This way, otoh, the (LOCKed on x86) write isn't even
attempted when the slot already holds non-NULL.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |