public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] RPING: Make sure CQ event thread exits before destroying the CQ.
@ 2010-10-25 19:43 Steve Wise
       [not found] ` <20101025194309.11127.29600.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Wise @ 2010-10-25 19:43 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

It is possible for the CQ event thread to poll the CQ after it has been
destroyed which can result in a seg fault on T3 interfaces.  This patch
waits for the thread to exit before destroying the CQ.

Signed-off-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
---

 examples/rping.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/examples/rping.c b/examples/rping.c
index b58ea74..a8af4d6 100644
--- a/examples/rping.c
+++ b/examples/rping.c
@@ -280,12 +280,11 @@ static int rping_cq_event_handler(struct rping_cb *cb)
 		ret = 0;
 
 		if (wc.status) {
-			if (wc.status != IBV_WC_WR_FLUSH_ERR) {
+			if (wc.status != IBV_WC_WR_FLUSH_ERR)
 				fprintf(stderr, 
 					"cq completion failed status %d\n",
 					wc.status);
-				ret = -1;
-			}
+			ret = -1;
 			goto error;
 		}
 
@@ -802,10 +801,9 @@ static void *rping_persistent_server_thread(void *arg)
 
 	rping_test_server(cb);
 	rdma_disconnect(cb->child_cm_id);
+	pthread_join(cb->cqthread, NULL);
 	rping_free_buffers(cb);
 	rping_free_qp(cb);
-	pthread_cancel(cb->cqthread);
-	pthread_join(cb->cqthread, NULL);
 	rdma_destroy_id(cb->child_cm_id);
 	free_cb(cb);
 	return NULL;
@@ -890,6 +888,7 @@ static int rping_run_server(struct rping_cb *cb)
 
 	rping_test_server(cb);
 	rdma_disconnect(cb->child_cm_id);
+	pthread_join(cb->cqthread, NULL);
 	rdma_destroy_id(cb->child_cm_id);
 err2:
 	rping_free_buffers(cb);
@@ -1057,6 +1056,7 @@ static int rping_run_client(struct rping_cb *cb)
 
 	rping_test_client(cb);
 	rdma_disconnect(cb->cm_id);
+	pthread_join(cb->cqthread, NULL);
 err2:
 	rping_free_buffers(cb);
 err1:

--
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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] RPING: Make sure CQ event thread exits before destroying the CQ.
       [not found] ` <20101025194309.11127.29600.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
@ 2010-11-01 17:14   ` Steve Wise
       [not found]     ` <4CCEF57C.60306-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
  2010-11-01 19:26   ` Hefty, Sean
  1 sibling, 1 reply; 4+ messages in thread
From: Steve Wise @ 2010-11-01 17:14 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hey Sean,

Thoughts on this?

I did quick rping tests on mthca, mlx4 and T3.  Tested out ok.


Steve.


On 10/25/2010 02:43 PM, Steve Wise wrote:
> It is possible for the CQ event thread to poll the CQ after it has been
> destroyed which can result in a seg fault on T3 interfaces.  This patch
> waits for the thread to exit before destroying the CQ.
>
> Signed-off-by: Steve Wise<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> ---
>
>   examples/rping.c |   10 +++++-----
>   1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/examples/rping.c b/examples/rping.c
> index b58ea74..a8af4d6 100644
> --- a/examples/rping.c
> +++ b/examples/rping.c
> @@ -280,12 +280,11 @@ static int rping_cq_event_handler(struct rping_cb *cb)
>   		ret = 0;
>
>   		if (wc.status) {
> -			if (wc.status != IBV_WC_WR_FLUSH_ERR) {
> +			if (wc.status != IBV_WC_WR_FLUSH_ERR)
>   				fprintf(stderr,
>   					"cq completion failed status %d\n",
>   					wc.status);
> -				ret = -1;
> -			}
> +			ret = -1;
>   			goto error;
>   		}
>
> @@ -802,10 +801,9 @@ static void *rping_persistent_server_thread(void *arg)
>
>   	rping_test_server(cb);
>   	rdma_disconnect(cb->child_cm_id);
> +	pthread_join(cb->cqthread, NULL);
>   	rping_free_buffers(cb);
>   	rping_free_qp(cb);
> -	pthread_cancel(cb->cqthread);
> -	pthread_join(cb->cqthread, NULL);
>   	rdma_destroy_id(cb->child_cm_id);
>   	free_cb(cb);
>   	return NULL;
> @@ -890,6 +888,7 @@ static int rping_run_server(struct rping_cb *cb)
>
>   	rping_test_server(cb);
>   	rdma_disconnect(cb->child_cm_id);
> +	pthread_join(cb->cqthread, NULL);
>   	rdma_destroy_id(cb->child_cm_id);
>   err2:
>   	rping_free_buffers(cb);
> @@ -1057,6 +1056,7 @@ static int rping_run_client(struct rping_cb *cb)
>
>   	rping_test_client(cb);
>   	rdma_disconnect(cb->cm_id);
> +	pthread_join(cb->cqthread, NULL);
>   err2:
>   	rping_free_buffers(cb);
>   err1:
>
> --
> 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
>    

--
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] 4+ messages in thread

* RE: [PATCH v2] RPING: Make sure CQ event thread exits before destroying the CQ.
       [not found]     ` <4CCEF57C.60306-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
@ 2010-11-01 17:45       ` Hefty, Sean
  0 siblings, 0 replies; 4+ messages in thread
From: Hefty, Sean @ 2010-11-01 17:45 UTC (permalink / raw)
  To: Steve Wise; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

> Thoughts on this?

I was out last week, but I have this marked to look at later today.

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

* RE: [PATCH v2] RPING: Make sure CQ event thread exits before destroying the CQ.
       [not found] ` <20101025194309.11127.29600.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
  2010-11-01 17:14   ` Steve Wise
@ 2010-11-01 19:26   ` Hefty, Sean
  1 sibling, 0 replies; 4+ messages in thread
From: Hefty, Sean @ 2010-11-01 19:26 UTC (permalink / raw)
  To: Steve Wise; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 151 bytes --]

thanks - applied
N‹§²æìr¸›yúèšØb²X¬¶Ç§vØ^–)Þº{.nÇ+‰·¥Š{±­ÙšŠ{ayº\x1dʇڙë,j\a­¢f£¢·hš‹»öì\x17/oSc¾™Ú³9˜uÀ¦æå‰È&jw¨®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿïêäz¹Þ–Šàþf£¢·hšˆ§~ˆmš

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

end of thread, other threads:[~2010-11-01 19:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-25 19:43 [PATCH v2] RPING: Make sure CQ event thread exits before destroying the CQ Steve Wise
     [not found] ` <20101025194309.11127.29600.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
2010-11-01 17:14   ` Steve Wise
     [not found]     ` <4CCEF57C.60306-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2010-11-01 17:45       ` Hefty, Sean
2010-11-01 19:26   ` Hefty, Sean

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