From: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
To: linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Jason Gunthorpe <jgg-uk2M96/98Pc@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
Idan Burstein <idanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
Subject: [PATCH rfc 3/5] irq_poll: wire up irq_am
Date: Tue, 6 Feb 2018 00:03:14 +0200 [thread overview]
Message-ID: <20180205220316.30236-4-sagi@grimberg.me> (raw)
In-Reply-To: <20180205220316.30236-1-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
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 <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
---
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 <linux/irq-am.h>
+
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)
{
/*
--
2.14.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-02-05 22:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 22:03 [PATCH rfc 0/5] generic adaptive IRQ moderation library for I/O devices Sagi Grimberg
[not found] ` <20180205220316.30236-1-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2018-02-05 22:03 ` [PATCH rfc 1/5] irq-am: Introduce library implementing generic adaptive moderation Sagi Grimberg
[not found] ` <20180205220316.30236-2-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2018-02-06 7:43 ` Or Gerlitz
2018-02-05 22:03 ` [PATCH rfc 2/5] irq-am: add some debugfs exposure on tuning state Sagi Grimberg
2018-02-06 16:04 ` kbuild test robot
2018-02-06 17:38 ` kbuild test robot
2018-02-08 1:24 ` Bart Van Assche
2018-02-12 19:42 ` Sagi Grimberg
2018-02-05 22:03 ` Sagi Grimberg [this message]
[not found] ` <20180205220316.30236-4-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2018-02-08 1:28 ` [PATCH rfc 3/5] irq_poll: wire up irq_am Bart Van Assche
[not found] ` <1518053304.2870.95.camel-Sjgp3cTcYWE@public.gmane.org>
2018-02-12 19:40 ` Sagi Grimberg
2018-02-05 22:03 ` [PATCH rfc 4/5] IB/cq: add adaptive moderation support Sagi Grimberg
2018-02-06 6:56 ` [PATCH rfc 0/5] generic adaptive IRQ moderation library for I/O devices Or Gerlitz
2018-02-06 9:25 ` Sagi Grimberg
[not found] ` <08889344-db9d-cf46-6cfb-56764042f578-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2018-02-06 11:34 ` Or Gerlitz
2018-02-06 8:54 ` Or Gerlitz
[not found] ` <CAJ3xEMi0KzOMJt7d01ohHW-ZpmdwvfzZCLN0qA-LLFwROeVseQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-02-06 9:02 ` Tal Gilboa
2018-02-06 9:34 ` Sagi Grimberg
2018-02-06 9:45 ` Tal Gilboa
[not found] ` <a47a8012-c021-74c4-9161-eaff7374a0b2-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-02-13 9:30 ` Or Gerlitz
2018-02-13 21:46 ` Tal Gilboa
2018-02-05 22:03 ` [PATCH rfc 5/5] IB/cq: wire up adaptive moderation to workqueue based completion queues Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180205220316.30236-4-sagi@grimberg.me \
--to=sagi-nqwnxtmzq1alnmji0ikvqw@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=bart.vanassche-Sjgp3cTcYWE@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=idanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=jgg-uk2M96/98Pc@public.gmane.org \
--cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).