All of lore.kernel.org
 help / color / mirror / Atom feed
* Leak in rdma_get_cm_event on pthread_cancel?
@ 2012-01-13 11:46 Flavio Baronti
       [not found] ` <4F101978.6010608-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Flavio Baronti @ 2012-01-13 11:46 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

When I want to stop the thread reading rdma events, I kill it with a pthread_cancel(), since it is blocked in a 
rdma_get_cm_event(). This causes a leak of the evt variable in the rdma_get_cm_event() function. Not a big deal, of 
course, but a couple of pthread_cleanup_push(free, evt) and pthread_cleanup_pop() should solve it.

Flavio
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Leak in rdma_get_cm_event on pthread_cancel?
       [not found] ` <4F101978.6010608-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
@ 2012-01-13 16:43   ` Hefty, Sean
       [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325676E37-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
  2012-01-13 17:59   ` Jason Gunthorpe
  1 sibling, 1 reply; 8+ messages in thread
From: Hefty, Sean @ 2012-01-13 16:43 UTC (permalink / raw)
  To: Flavio Baronti, linux-rdma-u79uwXL29TY76Z2rM5mHXA

> When I want to stop the thread reading rdma events, I kill it with a
> pthread_cancel(), since it is blocked in a
> rdma_get_cm_event(). This causes a leak of the evt variable in the
> rdma_get_cm_event() function. Not a big deal, of
> course, but a couple of pthread_cleanup_push(free, evt) and
> pthread_cleanup_pop() should solve it.

What version of the librdmacm are you using?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325676E37-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2012-01-13 16:55       ` Flavio Baronti
  0 siblings, 0 replies; 8+ messages in thread
From: Flavio Baronti @ 2012-01-13 16:55 UTC (permalink / raw)
  To: Hefty, Sean; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Il 1/13/2012 17:43 PM, Hefty, Sean ha scritto:
>> When I want to stop the thread reading rdma events, I kill it with a
>> pthread_cancel(), since it is blocked in a
>> rdma_get_cm_event(). This causes a leak of the evt variable in the
>> rdma_get_cm_event() function. Not a big deal, of
>> course, but a couple of pthread_cleanup_push(free, evt) and
>> pthread_cleanup_pop() should solve it.
>
> What version of the librdmacm are you using?

I'm using 1.0.13; I checked in 1.0.15 too, and the code appears to have the same structure.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found] ` <4F101978.6010608-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
  2012-01-13 16:43   ` Hefty, Sean
@ 2012-01-13 17:59   ` Jason Gunthorpe
       [not found]     ` <20120113175925.GE6798-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2012-01-13 17:59 UTC (permalink / raw)
  To: Flavio Baronti; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Fri, Jan 13, 2012 at 12:46:00PM +0100, Flavio Baronti wrote:
> When I want to stop the thread reading rdma events, I kill it with a
> pthread_cancel(), since it is blocked in a rdma_get_cm_event(). This
> causes a leak of the evt variable in the rdma_get_cm_event()
> function. Not a big deal, of course, but a couple of
> pthread_cleanup_push(free, evt) and pthread_cleanup_pop() should
> solve it.

None of the IB libraries have been audited for posix async cancellation
safety.

To do this work someone would have to review every call to determine
if it is a cancelation point, and document this as part of the API.

Then review if any of the internal cancelation points in the
cancelable functions require a resource clean up, and add it.

IHMO, cancelation should not be used with threads that call into the
ib libraries.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found]     ` <20120113175925.GE6798-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2012-01-16  8:46       ` Flavio Baronti
       [not found]         ` <4F13E3ED.3010708-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Flavio Baronti @ 2012-01-16  8:46 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Il 1/13/2012 18:59 PM, Jason Gunthorpe ha scritto:
> On Fri, Jan 13, 2012 at 12:46:00PM +0100, Flavio Baronti wrote:
>> When I want to stop the thread reading rdma events, I kill it with a
>> pthread_cancel(), since it is blocked in a rdma_get_cm_event(). This
>> causes a leak of the evt variable in the rdma_get_cm_event()
>> function. Not a big deal, of course, but a couple of
>> pthread_cleanup_push(free, evt) and pthread_cleanup_pop() should
>> solve it.
>
> None of the IB libraries have been audited for posix async cancellation
> safety.
>
> To do this work someone would have to review every call to determine
> if it is a cancelation point, and document this as part of the API.
>
> Then review if any of the internal cancelation points in the
> cancelable functions require a resource clean up, and add it.
>
> IHMO, cancelation should not be used with threads that call into the
> ib libraries.
>
> Jason
>

Ok, but what is then the proper way to stop a thread blocked on rdma_get_cm_event() (or on ibv_get_cq_event())?

Flavio
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found]         ` <4F13E3ED.3010708-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
@ 2012-01-16 22:15           ` Or Gerlitz
       [not found]             ` <CAJZOPZ+ik7DdXJHbEyr-PKyOQ3yEoWa6H=rhEe4cwc__61DUrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Or Gerlitz @ 2012-01-16 22:15 UTC (permalink / raw)
  To: Flavio Baronti; +Cc: Jason Gunthorpe, linux-rdma-u79uwXL29TY76Z2rM5mHXA

Flavio Baronti <f.baronti-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org> wrote:
> what is then the proper way to stop a thread blocked on
> rdma_get_cm_event() (or on ibv_get_cq_event())?

Oh, this is simple - don't get there... have your code

1. get the FDs associated with IB - which you can retrieve from
librdmacm and from libibverbs

2. make them non blocking

3. add them to you select/poll  FD group

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found]             ` <CAJZOPZ+ik7DdXJHbEyr-PKyOQ3yEoWa6H=rhEe4cwc__61DUrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-01-16 22:35               ` Jason Gunthorpe
       [not found]                 ` <20120116223541.GA2892-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2012-01-16 22:35 UTC (permalink / raw)
  To: Or Gerlitz; +Cc: Flavio Baronti, linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Tue, Jan 17, 2012 at 12:15:23AM +0200, Or Gerlitz wrote:
> Flavio Baronti <f.baronti-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org> wrote:
> > what is then the proper way to stop a thread blocked on
> > rdma_get_cm_event() (or on ibv_get_cq_event())?
> 
> Oh, this is simple - don't get there... have your code
> 
> 1. get the FDs associated with IB - which you can retrieve from
> librdmacm and from libibverbs
> 
> 2. make them non blocking
> 
> 3. add them to you select/poll  FD group

4. Use an eventfd or otherwise to break out of the select/poll loop
and then exit your thread.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Leak in rdma_get_cm_event on pthread_cancel?
       [not found]                 ` <20120116223541.GA2892-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2012-01-17  8:52                   ` Flavio Baronti
  0 siblings, 0 replies; 8+ messages in thread
From: Flavio Baronti @ 2012-01-17  8:52 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Il 1/16/2012 23:35 PM, Jason Gunthorpe ha scritto:
> On Tue, Jan 17, 2012 at 12:15:23AM +0200, Or Gerlitz wrote:
>> Flavio Baronti<f.baronti-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>  wrote:
>>> what is then the proper way to stop a thread blocked on
>>> rdma_get_cm_event() (or on ibv_get_cq_event())?
>>
>> Oh, this is simple - don't get there... have your code
>>
>> 1. get the FDs associated with IB - which you can retrieve from
>> librdmacm and from libibverbs
>>
>> 2. make them non blocking
>>
>> 3. add them to you select/poll  FD group
>
> 4. Use an eventfd or otherwise to break out of the select/poll loop
> and then exit your thread.
>
> Jason

Thanks, I did not think about eventfd+select.

Flavio
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-17  8:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13 11:46 Leak in rdma_get_cm_event on pthread_cancel? Flavio Baronti
     [not found] ` <4F101978.6010608-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
2012-01-13 16:43   ` Hefty, Sean
     [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325676E37-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2012-01-13 16:55       ` Flavio Baronti
2012-01-13 17:59   ` Jason Gunthorpe
     [not found]     ` <20120113175925.GE6798-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2012-01-16  8:46       ` Flavio Baronti
     [not found]         ` <4F13E3ED.3010708-ngIpsMLAhaq41k5uCYKmRQ@public.gmane.org>
2012-01-16 22:15           ` Or Gerlitz
     [not found]             ` <CAJZOPZ+ik7DdXJHbEyr-PKyOQ3yEoWa6H=rhEe4cwc__61DUrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-16 22:35               ` Jason Gunthorpe
     [not found]                 ` <20120116223541.GA2892-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2012-01-17  8:52                   ` Flavio Baronti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.