From patchwork Thu Sep 20 17:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10608241 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 4F5D214DA for ; Thu, 20 Sep 2018 17:09:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38B822E259 for ; Thu, 20 Sep 2018 17:09:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CC6A2E25F; Thu, 20 Sep 2018 17:09:03 +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 D9ED32E259 for ; Thu, 20 Sep 2018 17:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbeITWx2 (ORCPT ); Thu, 20 Sep 2018 18:53:28 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40585 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeITWx2 (ORCPT ); Thu, 20 Sep 2018 18:53:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id y8-v6so6520412wrh.7 for ; Thu, 20 Sep 2018 10:09:01 -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=bvfJaRuUcYwYEpI6FeOwnnxAhXZcwibxiugEJA1zVYj21KsFKCUW/ITEO23f8RWKzc 08Z0dCON7v2+2FOFpBqY5nLi3Eg3VmOxSiJmhHe2RyT1FZmbLi+Io/beCVICJarA78jY eUdOZpTzT1+uAR2zM0ZAgb2S3VlQzNtZHhs5U= 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=OzdLw4JdVSr6udPWxPp+IYq8xKhHX8VafZ58p75npx1vQXQtL318XgRtMRAOo4oF17 O+T2dDdcBKoPmMI2ZKLZybn5oTcqQ0tkthwvTBkldGNPhmov5IMQnKUMnB9nWKVVlzSX f1JHWNhF6mdvZdZh7eji0kmsDpPysIIWhP09veGVKvte/ZxZw4eOZbdK4MvSyXHmRncM k3QjeWzJkZEx3tfZ2zbToyeOm8oInSzrikLprPKfO2dqmsZgjYS/EamPpMLAwkPBPlQX FSHiBQJkjm2jW+p7xH3pSMSPuu6n/vVPAdsz1BhPfunC1QDNNjUPAl0HBBiomddi3gpH SGNA== X-Gm-Message-State: APzg51DxVHUxIhAv98BSzSdBPMkgBzmlGOLM9alpVE5vBR+mjKq/+ZEW iW9UqN7ljuLYMCO3hGDG4f3uUQ== X-Google-Smtp-Source: ANB0VdY0kn3WfLoN44ddyttBOiEIxG4Ndx/q32BI/qDoPYPDZ7G/IZFid0G1u0CjP/Rk4rCZBuQWCg== X-Received: by 2002:a5d:6b01:: with SMTP id v1-v6mr16473449wrw.208.1537463340359; Thu, 20 Sep 2018 10:09:00 -0700 (PDT) Received: from neo00-el73.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id v133-v6sm3458232wma.36.2018.09.20.10.08.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 10:08:59 -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 3/4] bnxt_re/lib: Fix the frequency of acquiring flush lock Date: Thu, 20 Sep 2018 13:08:33 -0400 Message-Id: <1537463314-7807-4-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537463314-7807-1-git-send-email-devesh.sharma@broadcom.com> References: <1537463314-7807-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; }