public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* identify the race condition in this code and win the respect of linux-rdma developers!
@ 2011-09-15 23:58 Hefty, Sean
       [not found] ` <1828884A29C6694DAF28B7E6B8A8237316E5B2B1-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Hefty, Sean @ 2011-09-15 23:58 UTC (permalink / raw)
  To: linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)

I have a ping-pong test application that loops doing: send, wait for send completion, wait for receive completion.  The test occasionally hangs in the following code at ibv_get_cq_event() (error handling removed):

Case 1:
	ret = ibv_poll_cq(id->recv_cq, 1, wc);
	ret = ibv_req_notify_cq(id->recv_cq, 0);

	while (!(ret = ibv_poll_cq(id->recv_cq, 1, wc))) {
		ret = ibv_get_cq_event(id->recv_cq_channel, &cq, &context);
		ibv_ack_cq_events(id->recv_cq, 1);
	}

The test does NOT hang if the code is restructured as either of the below: 

Case 2:
	ret = ibv_poll_cq(id->recv_cq, 1, wc);
	ret = ibv_req_notify_cq(id->recv_cq, 0);

	do {
		ret = ibv_get_cq_event(id->recv_cq_channel, &cq, &context);
		ibv_ack_cq_events(id->recv_cq, 1);
	} while (!(ret = ibv_poll_cq(id->recv_cq, 1, wc)));

or
Case 3:
	ret = ibv_poll_cq(id->recv_cq, 1, wc);
	while (1)
		ret = ibv_req_notify_cq(id->recv_cq, 0);

		ret = ibv_poll_cq(id->recv_cq, 1, wc);
		if (ret)
			break;
		ret = ibv_get_cq_event(id->recv_cq_channel, &cq, &context);
		ibv_ack_cq_events(id->recv_cq, 1);
	}

Personally, I would have expected case 2 to hang and cases 1 and 3 to work.  Does anyone see why case 1 should hang?  This is with mlx4.

- Sean
--
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:[~2011-09-16 19:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 23:58 identify the race condition in this code and win the respect of linux-rdma developers! Hefty, Sean
     [not found] ` <1828884A29C6694DAF28B7E6B8A8237316E5B2B1-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2011-09-16  0:50   ` Jason Gunthorpe
     [not found]     ` <20110916005008.GC6020-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2011-09-16 14:51       ` Hefty, Sean
     [not found]         ` <1828884A29C6694DAF28B7E6B8A8237316E5B320-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2011-09-16 15:59           ` Jason Gunthorpe
     [not found]             ` <20110916155955.GA18548-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2011-09-16 16:57               ` Hefty, Sean
     [not found]                 ` <1828884A29C6694DAF28B7E6B8A8237316E5B3B8-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2011-09-16 17:21                   ` Hefty, Sean
2011-09-16 19:36               ` Hefty, Sean
     [not found]                 ` <1828884A29C6694DAF28B7E6B8A8237316E5B55E-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2011-09-16 19:57                   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox