From patchwork Mon Feb 5 22:03:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10201925 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 C3831601A1 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 AFE8B21BED for ; Mon, 5 Feb 2018 22:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3A4A28929; Mon, 5 Feb 2018 22:04:15 +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 05C1C289B7 for ; Mon, 5 Feb 2018 22:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbeBEWDy (ORCPT ); Mon, 5 Feb 2018 17:03:54 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:33635 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbeBEWDy (ORCPT ); Mon, 5 Feb 2018 17:03:54 -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=ICq0kKXpNDOVgsEu7dujS2N+HwcrY6YN9QwaLGiQ4YI=; b=Kgs6o6a8NhRtuTGCLjzICK64B zHNsr18QRMB7y26DiumyZoX7YDDxdlk6O+zOx9tFFEA1GUG1yqc8bOBFvW1gzchMa8U9qIPxmLhzO vU4D4lUZUkjxkZcaE/lyMweVo6jrT9e5fgwUFTWdci/yNyAFw1brCth2eLGXuYGhD+vr2s1txgRCJ DbuoQz0/+cotC7ljpbac9pLO4e1FhIezSEm/hPiUdyZTqDggvSkIOQGEhFniq0kgNOupqA17/FAqG MIMbksXfKJxnB88AS3QOnFdDYOWFlV3v18j1LFacdLJN4UQV2KcPN0c1wL34ThNmguJ5Kus9bmFI1 Z554hwI/Q==; Received: from [46.120.250.42] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eiorf-000145-5C; Mon, 05 Feb 2018 22:03:51 +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 4/5] IB/cq: add adaptive moderation support Date: Tue, 6 Feb 2018 00:03:15 +0200 Message-Id: <20180205220316.30236-5-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently activated via modparam, obviously we will want to find a more generic way to control this. Signed-off-by: Sagi Grimberg --- drivers/infiniband/core/cq.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index f2ae75fa3128..270801d28f9d 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -25,6 +25,51 @@ #define IB_POLL_FLAGS \ (IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS) +#define IB_CQ_AM_NR_LEVELS 8 +#define IB_CQ_AM_NR_EVENTS 64 + +struct ib_cq_moder { + u16 usec; + u16 comps; +}; + +/* XXX: magic adaptive moderation profiles */ +static const struct ib_cq_moder am_prof[IB_CQ_AM_NR_LEVELS] = { + {1, 1}, + {1, 2}, + {2, 4}, + {4, 8}, + {8, 16}, + {16, 32}, + {32, 48}, + {32, 64}, +}; + +static bool use_am = true; +module_param(use_am, bool, 0444); +MODULE_PARM_DESC(use_am, "Use cq adaptive moderation"); + +static int ib_cq_am(struct ib_cq *cq, unsigned short level) +{ + u16 usec; + u16 comps; + + if (!use_am) + return 0; + + usec = am_prof[level].usec; + comps = am_prof[level].comps; + + return cq->device->modify_cq(cq, comps, usec); +} + +static int ib_cq_irqpoll_am(struct irq_poll *iop, unsigned short level) +{ + struct ib_cq *cq = container_of(iop, struct ib_cq, iop); + + return ib_cq_am(cq, level); +} + static int __ib_process_cq(struct ib_cq *cq, int budget) { int i, n, completed = 0; @@ -162,6 +207,9 @@ struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, cq->comp_handler = ib_cq_completion_softirq; irq_poll_init(&cq->iop, IB_POLL_BUDGET_IRQ, ib_poll_handler); + if (cq->device->modify_cq) + irq_poll_init_am(&cq->iop, IB_CQ_AM_NR_EVENTS, + IB_CQ_AM_NR_LEVELS, 0, ib_cq_irqpoll_am); ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); break; case IB_POLL_WORKQUEUE: