From patchwork Thu Mar 16 16:57:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9629019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD4C260244 for ; Thu, 16 Mar 2017 16:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCF9627F9A for ; Thu, 16 Mar 2017 16:57:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0CC028532; Thu, 16 Mar 2017 16:57:29 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 53A1A27F9A for ; Thu, 16 Mar 2017 16:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753084AbdCPQ52 (ORCPT ); Thu, 16 Mar 2017 12:57:28 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35276 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752886AbdCPQ51 (ORCPT ); Thu, 16 Mar 2017 12:57:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fQ00FDuKXyd7kLaT1/YVyyiDH7CWG29goVHdW5DZYrc=; b=ZtTyF8Ccph7Mvr7eQlPz7TmtE jB+SQntfeV3vyeN6mpVapGsssrbeSZboMko3h15Ua3LBn+5TnTdhntqSJSyY1549tlQeW/SYvPz1S B40EqeaF+YPo5pamGLUnoWzL8YP+LmKiyrrJ2+2KPlLBWYYlNmq1liNT1Ibu0CHB3dSTPAr8c/uD3 3SUziMKvYZfXaUngg6K7Sf1wst2Wx2W1/SlH1DfaWpM2tJmW4XF6vjb0YlD5f+bE5DWh9Qm06IKtC fBNOCbJ8joGisNWE6sB8Yy5cOYELqdW1tw8mBOs6mRkp3iT++ImPPz8GGnQ0adD6TMELfPMVJ79Nc qgN0uDV/A==; Received: from 50-197-129-18-static.hfc.comcastbusiness.net ([50.197.129.18] helo=bombadil.infradead.org) by merlin.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1coYhx-0007ZG-Qj; Thu, 16 Mar 2017 16:57:02 +0000 From: Sagi Grimberg To: linux-rdma@vger.kernel.org Cc: Bart Van Assche Subject: [PATCH v3] IB/cq: Don't process more than the given budget Date: Thu, 16 Mar 2017 18:57:00 +0200 Message-Id: <1489683420-28005-1-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 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 caller might not want this overhead. Reviewed-by: Bart Van Assche Reviewed-by: Leon Romanovsky Signed-off-by: Sagi Grimberg Reviewed-by: Yuval Shaia --- drivers/infiniband/core/cq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index e95510117a6d..b9c4cefe90c1 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -29,7 +29,13 @@ static int __ib_process_cq(struct ib_cq *cq, int budget) { int i, n, completed = 0; - while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) { + /* + * budget might be (-1) if the caller does not + * want to bound this call, thus we need unsigned + * minimum here. + */ + while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH, + budget - completed), cq->wc)) > 0) { for (i = 0; i < n; i++) { struct ib_wc *wc = &cq->wc[i];