Skip to contentSkip to conversation

rdma_get_cm_event error behaviour defined?

DISCUSSION Dr. David Alan Gilbert 2 participants 5 messages May 17, 2021 – Jun 2, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

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

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#1 lore raw
Quoted 7 lines · Dr. David Alan Gilbert

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

Quoted 5 lines

Dave

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#2 lore raw
Quoted 9 lines · * Leon Romanovsky ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert

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.

Quoted 3 lines

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

Quoted 8 lines

Thanks

Quoted 5 lines

Dave

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#3 lore raw
Quoted 25 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Leon Romanovsky ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert

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.

Quoted 3 lines

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     }
Quoted 2 lines

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.

Quoted 4 lines

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

#4 lore raw
Quoted 29 lines · * Leon Romanovsky ([email protected]) wrote:
Quoted 25 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Leon Romanovsky ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert

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.

Quoted 3 lines

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     }
Quoted 2 lines

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

Quoted 6 lines

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.

Quoted 6 lines
Quoted 4 lines

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

Quoted 2 lines

Thanks

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK