From patchwork Thu May 22 00:56:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 4219551 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 39118BEEAB for ; Thu, 22 May 2014 00:56:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 576F220379 for ; Thu, 22 May 2014 00:56:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F27E32026C for ; Thu, 22 May 2014 00:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752896AbaEVA4T (ORCPT ); Wed, 21 May 2014 20:56:19 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:36700 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbaEVA4T (ORCPT ); Wed, 21 May 2014 20:56:19 -0400 Received: by mail-ig0-f182.google.com with SMTP id uy17so2879463igb.9 for ; Wed, 21 May 2014 17:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:subject:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=geIs3kJgHshlto6gLiBz/jX+De8VIAU717g0Y4bvpJk=; b=LlKbC6FhwB6I6drrbbPiv6CxlAXNuueJ8exQVv0okln3uj5rZAJbH9KEdbPV3DxQsV 2l3z/Lq6IoFmb06YJDrU2IGgKo7ZKW+lkeI9dxHvyPgociPSiLO0HryKwkSCozpXL0Vi x+dwEkyE6KrIweF5peMv49gXtUo6AvUrX6lJTRk/2rb3Yxm0nKtrfCd9qFw/Bp2GwLl8 uRFCsQ1BRH7r0L3N2VwGxyQcbIzXSZPl333jKiuW4NsTg/AudlpXV/MZLWVG9RXeCDp+ p0w0SC3k5/YeK29bNUQfibRrk3jhE0ejnVE237y9eN8Dn2N+Nddi68iTcYbvc55ZGAao S1iw== X-Received: by 10.50.43.225 with SMTP id z1mr17718323igl.29.1400720178583; Wed, 21 May 2014 17:56:18 -0700 (PDT) Received: from manet.1015granger.net ([2604:8800:100:81fc:82ee:73ff:fe43:d64f]) by mx.google.com with ESMTPSA id u10sm9226221igz.21.2014.05.21.17.56.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 May 2014 17:56:18 -0700 (PDT) From: Chuck Lever Subject: [PATCH v4 14/24] xprtrdma: Limit work done by completion handler To: linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org Date: Wed, 21 May 2014 20:56:17 -0400 Message-ID: <20140522005617.27190.95984.stgit@manet.1015granger.net> In-Reply-To: <20140522004505.27190.58897.stgit@manet.1015granger.net> References: <20140522004505.27190.58897.stgit@manet.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Sagi Grimberg points out that a steady stream of CQ events could starve other work because of the boundless loop pooling in rpcrdma_{send,recv}_poll(). Instead of a (potentially infinite) while loop, return after collecting a budgeted number of completions. Signed-off-by: Chuck Lever Acked-by: Sagi Grimberg --- net/sunrpc/xprtrdma/verbs.c | 10 ++++++---- net/sunrpc/xprtrdma/xprt_rdma.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index b8caee9..1d08366 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -165,8 +165,9 @@ static int rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep) { struct ib_wc *wcs; - int count, rc; + int budget, count, rc; + budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE; do { wcs = ep->rep_send_wcs; @@ -177,7 +178,7 @@ rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep) count = rc; while (count-- > 0) rpcrdma_sendcq_process_wc(wcs++); - } while (rc == RPCRDMA_POLLSIZE); + } while (rc == RPCRDMA_POLLSIZE && --budget); return 0; } @@ -254,8 +255,9 @@ static int rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep) { struct ib_wc *wcs; - int count, rc; + int budget, count, rc; + budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE; do { wcs = ep->rep_recv_wcs; @@ -266,7 +268,7 @@ rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep) count = rc; while (count-- > 0) rpcrdma_recvcq_process_wc(wcs++); - } while (rc == RPCRDMA_POLLSIZE); + } while (rc == RPCRDMA_POLLSIZE && --budget); return 0; } diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index cb4c882..0c3b88e 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h @@ -74,6 +74,7 @@ struct rpcrdma_ia { * RDMA Endpoint -- one per transport instance */ +#define RPCRDMA_WC_BUDGET (128) #define RPCRDMA_POLLSIZE (16) struct rpcrdma_ep {