From patchwork Mon Feb 5 22:03:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10201929 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 0D97B605F3 for ; Mon, 5 Feb 2018 22:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED7621BED for ; Mon, 5 Feb 2018 22:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E374428929; 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=unavailable 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 3B26F2894C for ; Mon, 5 Feb 2018 22:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751878AbeBEWDw (ORCPT ); Mon, 5 Feb 2018 17:03:52 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:53651 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbeBEWDw (ORCPT ); Mon, 5 Feb 2018 17:03:52 -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=0uSM3Ge5peZ0kfumdSBflERC5BrmvPUaAhXMqbwqW/w=; b=UOGScJU6ftjb+ZF2A7/q2Eexq cq+NhlBguOf//dHWfq5KXBYo8c9vbpQJTefISxok3t6MyDkUo2USPVv1NEWZ9doQC3acW/AhuBHWc Y3dklJRK75CJYtG+2yD/9W38y2hSYLAL25iwLrylTj/7fXIw96PJbsteczyG9Y1y2da4rfVd43QSp UZFu+HTOw5Cn+CK6SdWaGBq5hU/2G1TcxRkXrclQ3YFJqRET346k3HlBsGbxMEvdt5Sx7j7mzCHui nOptXPiyKle+/XmOiv7D4JrT7eG4l5nUUiM78i/ZfFwlvyO9DBfb2WfvqcsRxsutj1XGHMdOgs2NH awjt1yGdw==; Received: from [46.120.250.42] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eiorc-000145-LS; Mon, 05 Feb 2018 22:03:49 +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 3/5] irq_poll: wire up irq_am Date: Tue, 6 Feb 2018 00:03:14 +0200 Message-Id: <20180205220316.30236-4-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 Update online stats for fired event and completions on each poll cycle. Also expose am initialization interface. The irqpoll consumer will initialize the irq-am context of the irq-poll context. Signed-off-by: Sagi Grimberg --- include/linux/irq_poll.h | 9 +++++++++ lib/Kconfig | 1 + lib/irq_poll.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/include/linux/irq_poll.h b/include/linux/irq_poll.h index 16aaeccb65cb..de3055359fd8 100644 --- a/include/linux/irq_poll.h +++ b/include/linux/irq_poll.h @@ -2,14 +2,20 @@ #ifndef IRQ_POLL_H #define IRQ_POLL_H +#include + struct irq_poll; typedef int (irq_poll_fn)(struct irq_poll *, int); +typedef int (irq_poll_am_fn)(struct irq_poll *, unsigned short); struct irq_poll { struct list_head list; unsigned long state; int weight; irq_poll_fn *poll; + + struct irq_am am; + irq_poll_am_fn *amfn; }; enum { @@ -23,4 +29,7 @@ extern void irq_poll_complete(struct irq_poll *); extern void irq_poll_enable(struct irq_poll *); extern void irq_poll_disable(struct irq_poll *); +extern void irq_poll_init_am(struct irq_poll *iop, unsigned int nr_events, + unsigned short nr_levels, unsigned short start_level, + irq_poll_am_fn *amfn); #endif diff --git a/lib/Kconfig b/lib/Kconfig index bbb4c9eea84d..d495b21cd241 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -511,6 +511,7 @@ config IRQ_AM config IRQ_POLL bool "IRQ polling library" + select IRQ_AM help Helper library to poll interrupt mitigation using polling. diff --git a/lib/irq_poll.c b/lib/irq_poll.c index 86a709954f5a..6bc86a677d8c 100644 --- a/lib/irq_poll.c +++ b/lib/irq_poll.c @@ -53,6 +53,7 @@ static void __irq_poll_complete(struct irq_poll *iop) list_del(&iop->list); smp_mb__before_atomic(); clear_bit_unlock(IRQ_POLL_F_SCHED, &iop->state); + irq_am_add_event(&iop->am); } /** @@ -106,8 +107,10 @@ static void __latent_entropy irq_poll_softirq(struct softirq_action *h) weight = iop->weight; work = 0; - if (test_bit(IRQ_POLL_F_SCHED, &iop->state)) + if (test_bit(IRQ_POLL_F_SCHED, &iop->state)) { work = iop->poll(iop, weight); + irq_am_add_comps(&iop->am, work); + } budget -= work; @@ -144,6 +147,7 @@ static void __latent_entropy irq_poll_softirq(struct softirq_action *h) **/ void irq_poll_disable(struct irq_poll *iop) { + irq_am_cleanup(&iop->am); set_bit(IRQ_POLL_F_DISABLE, &iop->state); while (test_and_set_bit(IRQ_POLL_F_SCHED, &iop->state)) msleep(1); @@ -185,6 +189,30 @@ void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn) } EXPORT_SYMBOL(irq_poll_init); +static int irq_poll_am(struct irq_am *am, unsigned short level) +{ + struct irq_poll *iop = container_of(am, struct irq_poll, am); + + return iop->amfn(iop, level); +} + +/** + * irq_poll_init_am - Initialize adaptive moderation parameters on this @iop + * @iop: The parent iopoll structure + * @weight: The default weight (or command completion budget) + * @poll_fn: The handler to invoke + * + * Description: + * Initialize adaptive moderation for this irq_poll structure. + **/ +void irq_poll_init_am(struct irq_poll *iop, unsigned int nr_events, + unsigned short nr_levels, unsigned short start_level, irq_poll_am_fn *amfn) +{ + iop->amfn = amfn; + irq_am_init(&iop->am, nr_events, nr_levels, start_level, irq_poll_am); +} +EXPORT_SYMBOL(irq_poll_init_am); + static int irq_poll_cpu_dead(unsigned int cpu) { /*