Skip to content

ibv_destroy_cq()

0.00 avg. rating (0% score) - 0 votes
int ibv_destroy_cq(struct ibv_cq *cq);

Description

ibv_destroy_cq() destroys a Completion Queue.

The destruction of a CQ will fail if any QP is still associated with it.

If there is any affiliated asynchronous event on that CQ that was read, using ibv_get_async_event(), but still wasn't acknowledged, using ibv_ack_async_event(), calling to ibv_destroy_cq() will never end until that event will be acknowledged.

A CQ can be destroyed either if it is empty or contains Work Completions that still weren't polled by ibv_poll_cq(). Also, it can be destroyed if a request for notification was requested using ibv_req_notify_cq() before any notification event was created.

Parameters

Name Direction Description
cq in CQ that was returned from ibv_create_cq()

Return Values

Value Description
0 On success
errno On failure
EBUSY One or more Work Queues is still associated with the CQ

Examples

Create a CQ with 100 entries and destroy it:

struct ibv_cq *cq;
 
cq = ibv_create_cq(context, 100, NULL, NULL, 0);
if (!cq) {
	fprintf(stderr, "Error, ibv_create_cq() failed\n");
	return -1;
}
 
if (ibv_destroy_cq(cq)) {
	fprintf(stderr, "Error, ibv_destroy_cq() failed\n");
	return -1;
}

FAQs

ibv_destroy_cq() failed, what will happen to the QPs which are associated with it?

Nothing at all. You can continue working with them without any side-effect.

ibv_destroy_cq() failed, can I know which QPs are associated with it and caused this failure?

No, currently the RDMA stack doesn’t have this capability.

Can I destroy a CQ with Work Completion in it?

Yes, you can. When a CQ is being destroyed, it doesn't matter if it contains Work Completions or not.

I called ibv_req_notify_cq() on a CQ and didn't get any Completion event on it. Can I destroy that CQ?

Yes, you can.

I called ibv_destroy_cq(), but it never ended. What happened?

There is at least one affiliated asynchronous event on that CQ that was read without a proper acknowledgement.

Share Our Posts

Share this post through social bookmarks.

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati

Comments

Tell us what do you think.

  1. Srinivas says: January 1, 2017

    Will destroying a CQ which has work completions cause memory leak?

    • Dotan Barak says: February 10, 2017

      Hi.

      Destroying a CQ which has Work Completion won't cause a memory leak to the RDMA resources
      (the buffer of the CQ will be freed, if there are or aren't any Work Completions in it).

      However, if your program needs to use information in those Work Completion
      (for example the wr_id, to understand which buffers are used),
      then *your* code will have memory leaks.

      Thanks
      Dotan

Add a Comment

Fill in the form and submit.

Time limit is exhausted. Please reload CAPTCHA.