From patchwork Mon Dec 15 19:58:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arlin Davis X-Patchwork-Id: 5497381 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 560E2BEEA8 for ; Mon, 15 Dec 2014 19:59:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C54F20973 for ; Mon, 15 Dec 2014 19:59:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82639209E5 for ; Mon, 15 Dec 2014 19:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751057AbaLOT7E (ORCPT ); Mon, 15 Dec 2014 14:59:04 -0500 Received: from mga02.intel.com ([134.134.136.20]:38237 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbaLOT7C (ORCPT ); Mon, 15 Dec 2014 14:59:02 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 15 Dec 2014 11:58:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="499097839" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by orsmga003.jf.intel.com with ESMTP; 15 Dec 2014 11:54:49 -0800 From: arlin.r.davis@intel.com To: linux-rdma@vger.kernel.org Cc: Arlin Davis Subject: [PATCH 3/4] common: dapl_ep_free must serialize CM object destroy Date: Mon, 15 Dec 2014 11:58:54 -0800 Message-Id: <1418673535-1464-4-git-send-email-arlin.r.davis@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1418673535-1464-1-git-send-email-arlin.r.davis@intel.com> References: <1418673535-1464-1-git-send-email-arlin.r.davis@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arlin Davis CM object could be destroyed from time_wait state from provider in separate thread. Destruction must be serialized with EP lock. Signed-off-by: Arlin Davis --- dapl/common/dapl_ep_free.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dapl/common/dapl_ep_free.c b/dapl/common/dapl_ep_free.c index 62d7eff..652b61d 100644 --- a/dapl/common/dapl_ep_free.c +++ b/dapl/common/dapl_ep_free.c @@ -66,7 +66,7 @@ DAT_RETURN DAT_API dapl_ep_free(IN DAT_EP_HANDLE ep_handle) DAPL_EP *ep_ptr; DAPL_IA *ia_ptr; DAT_EP_PARAM *param; - dp_ib_cm_handle_t cm_ptr, next_cm_ptr; + dp_ib_cm_handle_t cm_ptr; ib_qp_state_t save_qp_state; DAT_RETURN dat_status = DAT_SUCCESS; @@ -110,25 +110,26 @@ DAT_RETURN DAT_API dapl_ep_free(IN DAT_EP_HANDLE ep_handle) */ (void)dapl_ep_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG); + /* + * Do verification of parameters and the state change atomically. + */ + dapl_os_lock(&ep_ptr->header.lock); + /* Free all CM objects */ cm_ptr = (dapl_llist_is_empty(&ep_ptr->cm_list_head) ? NULL : dapl_llist_peek_head(&ep_ptr->cm_list_head)); + while (cm_ptr != NULL) { dapl_log(DAPL_DBG_TYPE_EP, "dapl_ep_free: Free CM: EP=%p CM=%p\n", ep_ptr, cm_ptr); - - next_cm_ptr = dapl_llist_next_entry(&ep_ptr->cm_list_head, - &cm_ptr->list_entry); + dapl_os_unlock(&ep_ptr->header.lock); dapls_cm_free(cm_ptr); /* blocking call */ - cm_ptr = next_cm_ptr; + dapl_os_lock(&ep_ptr->header.lock); + cm_ptr = (dapl_llist_is_empty(&ep_ptr->cm_list_head) + ? NULL : dapl_llist_peek_head(&ep_ptr->cm_list_head)); } - /* - * Do verification of parameters and the state change atomically. - */ - dapl_os_lock(&ep_ptr->header.lock); - #ifdef DAPL_DBG /* check if event pending and warn, don't assert, state is valid */ if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING) {