All of lore.kernel.org
 help / color / mirror / Atom feed
* rdma_get_cm_event error behaviour defined?
@ 2021-05-17 10:06 Dr. David Alan Gilbert
  2021-06-01 11:16 ` Leon Romanovsky
  0 siblings, 1 reply; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2021-05-17 10:06 UTC (permalink / raw)
  To: linux-rdma; +Cc: lizhijian

Hi,
  Is 'rdma_get_cm_event's behaviour in initialising **event
defined in the error case?
  We don't see anything in the manual page, my reading of the
code is it's not set/changed in the case of failure - but is
that defined?
  It would be good if the manpage could explicitly state it.

Dave
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


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

* Re: rdma_get_cm_event error behaviour defined?
  2021-05-17 10:06 rdma_get_cm_event error behaviour defined? Dr. David Alan Gilbert
@ 2021-06-01 11:16 ` Leon Romanovsky
  2021-06-01 11:32   ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2021-06-01 11:16 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: linux-rdma, lizhijian

On Mon, May 17, 2021 at 11:06:35AM +0100, Dr. David Alan Gilbert wrote:
> Hi,
>   Is 'rdma_get_cm_event's behaviour in initialising **event
> defined in the error case?
>   We don't see anything in the manual page, my reading of the
> code is it's not set/changed in the case of failure - but is
> that defined?
>   It would be good if the manpage could explicitly state it.

AFAIK, the general practice do not rely on any output argument if
function returns an error and I'm not sure that the man update is
needed.

Thanks

> 
> Dave
> -- 
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> 

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

* Re: rdma_get_cm_event error behaviour defined?
  2021-06-01 11:16 ` Leon Romanovsky
@ 2021-06-01 11:32   ` Dr. David Alan Gilbert
  2021-06-02 12:33     ` Leon Romanovsky
  0 siblings, 1 reply; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2021-06-01 11:32 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: linux-rdma, lizhijian

* Leon Romanovsky (leon@kernel.org) wrote:
> On Mon, May 17, 2021 at 11:06:35AM +0100, Dr. David Alan Gilbert wrote:
> > Hi,
> >   Is 'rdma_get_cm_event's behaviour in initialising **event
> > defined in the error case?
> >   We don't see anything in the manual page, my reading of the
> > code is it's not set/changed in the case of failure - but is
> > that defined?
> >   It would be good if the manpage could explicitly state it.
> 
> AFAIK, the general practice do not rely on any output argument if
> function returns an error and I'm not sure that the man update is
> needed.

The case we had was whether we needed to clean up or not in the error
case; the original code in qemu was:

    2496     ret = rdma_get_cm_event(rdma->channel, &cm_event);
    2497     if (ret) {
    2498         perror("rdma_get_cm_event after rdma_connect");
    2499         ERROR(errp, "connecting to destination!");
    2500         rdma_ack_cm_event(cm_event);
    2501         goto err_rdma_source_connect;
    2502     }

and Li spotted that rdma_ack_cm_event  would seg in the case
rdma_get_cm_event failed.

While I agree on not relying on an output; without a definition you're
stuck between not knowing if you're leaking an event that should
have been cleaned up.

Dave

> Thanks
> 
> > 
> > Dave
> > -- 
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> > 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


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

* Re: rdma_get_cm_event error behaviour defined?
  2021-06-01 11:32   ` Dr. David Alan Gilbert
@ 2021-06-02 12:33     ` Leon Romanovsky
  2021-06-02 12:55       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2021-06-02 12:33 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: linux-rdma, lizhijian

On Tue, Jun 01, 2021 at 12:32:00PM +0100, Dr. David Alan Gilbert wrote:
> * Leon Romanovsky (leon@kernel.org) wrote:
> > On Mon, May 17, 2021 at 11:06:35AM +0100, Dr. David Alan Gilbert wrote:
> > > Hi,
> > >   Is 'rdma_get_cm_event's behaviour in initialising **event
> > > defined in the error case?
> > >   We don't see anything in the manual page, my reading of the
> > > code is it's not set/changed in the case of failure - but is
> > > that defined?
> > >   It would be good if the manpage could explicitly state it.
> > 
> > AFAIK, the general practice do not rely on any output argument if
> > function returns an error and I'm not sure that the man update is
> > needed.
> 
> The case we had was whether we needed to clean up or not in the error
> case; the original code in qemu was:
> 
>     2496     ret = rdma_get_cm_event(rdma->channel, &cm_event);
>     2497     if (ret) {
>     2498         perror("rdma_get_cm_event after rdma_connect");
>     2499         ERROR(errp, "connecting to destination!");
>     2500         rdma_ack_cm_event(cm_event);
>     2501         goto err_rdma_source_connect;
>     2502     }
> 
> and Li spotted that rdma_ack_cm_event  would seg in the case
> rdma_get_cm_event failed.

man page says that you should rdma_ack_cm_event() on success only.

   14 All events which are allocated by rdma_get_cm_event must be released,
   15 there should be a one-to-one correspondence between successful gets
   16 and acks.  This call frees the event structure and any memory that it
   17 references.

> 
> While I agree on not relying on an output; without a definition you're
> stuck between not knowing if you're leaking an event that should
> have been cleaned up.

You are not supposed to have rdma_ack_cm_event() in your snippet.

Thanks

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

* Re: rdma_get_cm_event error behaviour defined?
  2021-06-02 12:33     ` Leon Romanovsky
@ 2021-06-02 12:55       ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2021-06-02 12:55 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: linux-rdma, lizhijian

* Leon Romanovsky (leon@kernel.org) wrote:
> On Tue, Jun 01, 2021 at 12:32:00PM +0100, Dr. David Alan Gilbert wrote:
> > * Leon Romanovsky (leon@kernel.org) wrote:
> > > On Mon, May 17, 2021 at 11:06:35AM +0100, Dr. David Alan Gilbert wrote:
> > > > Hi,
> > > >   Is 'rdma_get_cm_event's behaviour in initialising **event
> > > > defined in the error case?
> > > >   We don't see anything in the manual page, my reading of the
> > > > code is it's not set/changed in the case of failure - but is
> > > > that defined?
> > > >   It would be good if the manpage could explicitly state it.
> > > 
> > > AFAIK, the general practice do not rely on any output argument if
> > > function returns an error and I'm not sure that the man update is
> > > needed.
> > 
> > The case we had was whether we needed to clean up or not in the error
> > case; the original code in qemu was:
> > 
> >     2496     ret = rdma_get_cm_event(rdma->channel, &cm_event);
> >     2497     if (ret) {
> >     2498         perror("rdma_get_cm_event after rdma_connect");
> >     2499         ERROR(errp, "connecting to destination!");
> >     2500         rdma_ack_cm_event(cm_event);
> >     2501         goto err_rdma_source_connect;
> >     2502     }
> > 
> > and Li spotted that rdma_ack_cm_event  would seg in the case
> > rdma_get_cm_event failed.
> 
> man page says that you should rdma_ack_cm_event() on success only.
> 
>    14 All events which are allocated by rdma_get_cm_event must be released,
>    15 there should be a one-to-one correspondence between successful gets
>    16 and acks.  This call frees the event structure and any memory that it
>    17 references.

Hmm ok; it did fool at least 2 of us; and I ended up going to the code
to check.

> > 
> > While I agree on not relying on an output; without a definition you're
> > stuck between not knowing if you're leaking an event that should
> > have been cleaned up.
> 
> You are not supposed to have rdma_ack_cm_event() in your snippet.

Right, that's what we figured out the hard way.

Dave

> Thanks
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


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

end of thread, other threads:[~2021-06-02 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 10:06 rdma_get_cm_event error behaviour defined? Dr. David Alan Gilbert
2021-06-01 11:16 ` Leon Romanovsky
2021-06-01 11:32   ` Dr. David Alan Gilbert
2021-06-02 12:33     ` Leon Romanovsky
2021-06-02 12:55       ` Dr. David Alan Gilbert

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.