[openib-general] Re: uCM create connection ID

Sean Hefty mshefty at ichips.intel.com
Thu Jun 30 09:13:28 PDT 2005


Libor Michalek wrote:
>   Assume that the userspace 'struct ib_cm_event' contains the cm_id as
> well as a new 'u64 context' which is inherited from the cm_id, and is
> set at the time of the cm_id creation. This is what I'm assuming that
> Arlin would like to see.
> 
>   In the case of two threads accessing the CM at once there's a race
> condition if you are going to use the 'context' variable as a pointer
> to memory:
> 
> Thread 1                              Thread 2
> ------------------------------------- -----------------------------------
> cm_object = malloc(sizeof(*cm_object)
> ib_cm_create_id(&cm_object->cm_id,
>                 (u64)cm_object)
> 
>                                       ib_cm_event_get(&event)
> ib_cm_destroy_id(cm_object->cm_id)
> free(cm_object);
>                                       process_event((void *)event->context);

I see.  This appears to come from a difference between the event reporting 
model used by the kernel CM versus the usermode CM (callback versus 
calldown).  Maybe there's a way to assist the user here.  Can we report a 
destruction event, or require a second call to indicate that an event has 
been processed?  In the latter case, destruction could block while the event 
is being processed.  Not sure if either of these would help if the user 
processed events using multiple threads, but I think with additional 
serialization in the CM it might be able to work.

- Sean



More information about the general mailing list