From patchwork Wed Oct 10 06:27:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10634003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 471FD5CAF for ; Wed, 10 Oct 2018 06:27:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE4A029622 for ; Wed, 10 Oct 2018 06:27:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E237D29633; Wed, 10 Oct 2018 06:27:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDF5C29622 for ; Wed, 10 Oct 2018 06:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725757AbeJJNs2 (ORCPT ); Wed, 10 Oct 2018 09:48:28 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45206 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbeJJNs2 (ORCPT ); Wed, 10 Oct 2018 09:48:28 -0400 Received: by mail-pf1-f195.google.com with SMTP id u12-v6so2080580pfn.12 for ; Tue, 09 Oct 2018 23:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JlA0FgK0MhyHqAmlZKl1AT0XWSwuLQftS+GW37q8utQ=; b=JG/CyD4Vi1PwJyz0lIDuqAzJ9Li9fvLhhUls//nHD2SisQM+kYSDW3cc2LZrqRVMhC VyFQfzFQT4j+7BucQ+XM0I7RUSFDJ23iF9aHaWj1lExcq+/gDoBc0rXPGLSF4SdIl0mJ KLqd3KRNIBwH0V3h4zKmpxXNMX0qnBCtdbt+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JlA0FgK0MhyHqAmlZKl1AT0XWSwuLQftS+GW37q8utQ=; b=WkfAfbv0rLcfeZmpNZi/Wpa6k8viN7E8/IXia9UX6yRKwZdGLzZ5e1mn2APtJw9K7h 8zBTORscRcSFkfq+hEQGnbOMv8skQrdlDKTWhwI/6ET7B5QQ8n0qDnadSDpI3E2qjLZq 6yn0C+Hj+vYq8IaHhAycP0JvI82CK2Ia//Or3W9ZbEojqSzj3pXtMNO375DH8oP7zgUZ UM1a06k3JdOWa+fqM2BEMZ6NyVrwC/IFAZiVk0RtPC5TIzDIEWkud3E3FExsWjgKWXOG Ked6TRuwIKDT2Ov77WOtcMRPUV49gqOPQd8/CTTHBldgXGanoBH/f2NcUtXX3HcqRDQq wcrg== X-Gm-Message-State: ABuFfojXOps1cQbyr3LXoLItqAgkpHzvNfBEuMUO7iM2LylMuH2OmgGq gohVU4QzO5Jvlv1jU6aRy7cT8VnZ+PhBpA== X-Google-Smtp-Source: ACcGV61sWU5yq3fNVOh54g+lZPiGXb0iJbbdLfwbDyk6EWHMuA867wNEuWeRAVUqlVGV9cbb0JmjHw== X-Received: by 2002:a63:26c4:: with SMTP id m187-v6mr28734483pgm.268.1539152870456; Tue, 09 Oct 2018 23:27:50 -0700 (PDT) Received: from neo00-el73.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id r65-v6sm31330790pfj.5.2018.10.09.23.27.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 23:27:49 -0700 (PDT) From: Devesh Sharma To: jgg@mellanox.com, dledford@redhat.com Cc: linux-rdma@vger.kernel.org, NMoreyChaisemartin@suse.de, Devesh Sharma Subject: [PATCH rdma-core V2 3/4] bnxt_re/lib: Fix the frequency of acquiring flush lock Date: Wed, 10 Oct 2018 02:27:29 -0400 Message-Id: <1539152850-24357-4-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539152850-24357-1-git-send-email-devesh.sharma@broadcom.com> References: <1539152850-24357-1-git-send-email-devesh.sharma@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The flush lock should be tried only if there is some room left in the WC array supplied from consumer. Signed-off-by: Devesh Sharma --- providers/bnxt_re/verbs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c index 8e9fd8c..570dfc1 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c @@ -686,12 +686,13 @@ int bnxt_re_poll_cq(struct ibv_cq *ibvcq, int nwc, struct ibv_wc *wc) cq->deferred_arm_flags = 0; } pthread_spin_unlock(&cq->cqq.qlock); - /* Check if anything is there to flush. */ - pthread_spin_lock(&cntx->fqlock); left = nwc - dqed; - if (left) + if (left) { + /* Check if anything is there to flush. */ + pthread_spin_lock(&cntx->fqlock); dqed += bnxt_re_poll_flush_lists(cq, left, (wc + dqed)); - pthread_spin_unlock(&cntx->fqlock); + pthread_spin_unlock(&cntx->fqlock); + } return dqed; }