From patchwork Mon Feb 5 22:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10201919 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 178BE601A1 for ; Mon, 5 Feb 2018 22:04:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 044AE21BED for ; Mon, 5 Feb 2018 22:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02E1928967; Mon, 5 Feb 2018 22:04:14 +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 E4CCB2893F for ; Mon, 5 Feb 2018 22:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbeBEWD5 (ORCPT ); Mon, 5 Feb 2018 17:03:57 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:43195 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbeBEWD4 (ORCPT ); Mon, 5 Feb 2018 17:03:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YhTZ3TMHSj769yxmRSuJz5fgvh7stF6FDBFnElMnYUo=; b=VZZlN8lZGTgqX7cYbSOeHi/gt nVCMb/AYsKINfX8LEzgbh5S8KMc9Pi6wbKp8Zmz3IbN5GD0kjBL96Ile/4jXOLpHQXtRetp4xTST2 ydU+/3GUYi32eNCtGVYqJaC4vF1rBW7WhG0gk3nOn8or5weA3Zj1Cqjz63UDNU5rBVFXjpZmM7FQ7 Zr5VMh6eMOHrDVKJonDFIUln09C71ntseH441p6KeqaOiZb3jSsXzimnnGCr5s2kBDe4GhrKRKnDt RAzw/1YxVlzxh4OIco+B/1eD01qYhO36164u5bAngc5ibz1pYCgsMTkO8HsySfULBUau1+ekBCrYa M8bbkOi4w==; Received: from [46.120.250.42] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eiorh-000145-MP; Mon, 05 Feb 2018 22:03:54 +0000 From: Sagi Grimberg To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Jason Gunthorpe , Christoph Hellwig , Jens Axboe , Idan Burstein , Bart Van Assche Subject: [PATCH rfc 5/5] IB/cq: wire up adaptive moderation to workqueue based completion queues Date: Tue, 6 Feb 2018 00:03:16 +0200 Message-Id: <20180205220316.30236-6-sagi@grimberg.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180205220316.30236-1-sagi@grimberg.me> References: <20180205220316.30236-1-sagi@grimberg.me> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Sagi Grimberg --- drivers/infiniband/core/cq.c | 25 ++++++++++++++++++++----- include/rdma/ib_verbs.h | 9 +++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index 270801d28f9d..1d984fd77449 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /* # of WCs to poll for with a single call to ib_poll_cq */ @@ -70,6 +71,13 @@ static int ib_cq_irqpoll_am(struct irq_poll *iop, unsigned short level) return ib_cq_am(cq, level); } +static int ib_cq_workqueue_am(struct irq_am *am, unsigned short level) +{ + struct ib_cq *cq = container_of(am, struct ib_cq, wq.am); + + return ib_cq_am(cq, level); +} + static int __ib_process_cq(struct ib_cq *cq, int budget) { int i, n, completed = 0; @@ -147,18 +155,21 @@ static void ib_cq_completion_softirq(struct ib_cq *cq, void *private) static void ib_cq_poll_work(struct work_struct *work) { - struct ib_cq *cq = container_of(work, struct ib_cq, work); + struct ib_cq *cq = container_of(work, struct ib_cq, wq.work); int completed; completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE); + irq_am_add_comps(&cq->wq.am, completed); if (completed >= IB_POLL_BUDGET_WORKQUEUE || ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) - queue_work(ib_comp_wq, &cq->work); + queue_work(ib_comp_wq, &cq->wq.work); + else + irq_am_add_event(&cq->wq.am); } static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private) { - queue_work(ib_comp_wq, &cq->work); + queue_work(ib_comp_wq, &cq->wq.work); } /** @@ -214,7 +225,10 @@ struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, break; case IB_POLL_WORKQUEUE: cq->comp_handler = ib_cq_completion_workqueue; - INIT_WORK(&cq->work, ib_cq_poll_work); + INIT_WORK(&cq->wq.work, ib_cq_poll_work); + if (cq->device->modify_cq) + irq_am_init(&cq->wq.am, IB_CQ_AM_NR_EVENTS, + IB_CQ_AM_NR_LEVELS, 0, ib_cq_workqueue_am); ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); break; default: @@ -250,7 +264,8 @@ void ib_free_cq(struct ib_cq *cq) irq_poll_disable(&cq->iop); break; case IB_POLL_WORKQUEUE: - cancel_work_sync(&cq->work); + cancel_work_sync(&cq->wq.work); + irq_am_cleanup(&cq->wq.am); break; default: WARN_ON_ONCE(1); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index fd84cda5ed7c..14a93566adb6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1555,6 +1555,11 @@ enum ib_poll_context { IB_POLL_WORKQUEUE, /* poll from workqueue */ }; +struct ib_cq_workqueue_poll { + struct irq_am am; + struct work_struct work; +}; + struct ib_cq { struct ib_device *device; struct ib_uobject *uobject; @@ -1566,8 +1571,8 @@ struct ib_cq { enum ib_poll_context poll_ctx; struct ib_wc *wc; union { - struct irq_poll iop; - struct work_struct work; + struct irq_poll iop; + struct ib_cq_workqueue_poll wq; }; };