netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
	Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Sagi Grimberg <sagi@grimberg.me>, Tal Gilboa <talgi@mellanox.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Yamin Friedman <yaminf@mellanox.com>,
	Max Gurtovoy <maxg@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [for-next V2 07/10] linux/dim: Add completions count to dim_sample
Date: Tue, 25 Jun 2019 20:57:46 +0000	[thread overview]
Message-ID: <20190625205701.17849-8-saeedm@mellanox.com> (raw)
In-Reply-To: <20190625205701.17849-1-saeedm@mellanox.com>

From: Yamin Friedman <yaminf@mellanox.com>

Added a measurement of completions per/msec to allow for completion based
dim algorithms.

In order to use dynamic interrupt moderation with RDMA we need to have a
different measurment than packets per second. This change is meant to
prepare for adding a new DIM method.

All drivers that use net_dim and thus do not need a completion count will
have the completions set to 0.

Signed-off-by: Yamin Friedman <yaminf@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 include/linux/dim.h | 28 +++++++++++++++++++++++++---
 lib/dim/dim.c       |  9 +++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/include/linux/dim.h b/include/linux/dim.h
index f48ede3e0322..aa9bdd47a648 100644
--- a/include/linux/dim.h
+++ b/include/linux/dim.h
@@ -37,6 +37,7 @@
 struct dim_cq_moder {
 	u16 usec;
 	u16 pkts;
+	u16 comps;
 	u8 cq_period_mode;
 };
 
@@ -54,6 +55,7 @@ struct dim_sample {
 	u32 pkt_ctr;
 	u32 byte_ctr;
 	u16 event_ctr;
+	u32 comp_ctr;
 };
 
 /**
@@ -65,9 +67,11 @@ struct dim_sample {
  * @epms: Events per msec
  */
 struct dim_stats {
-	int ppms;
-	int bpms;
-	int epms;
+	int ppms; /* packets per msec */
+	int bpms; /* bytes per msec */
+	int epms; /* events per msec */
+	int cpms; /* completions per msec */
+	int cpe_ratio; /* ratio of completions to events */
 };
 
 /**
@@ -89,6 +93,7 @@ struct dim {
 	u8 state;
 	struct dim_stats prev_stats;
 	struct dim_sample start_sample;
+	struct dim_sample measuring_sample;
 	struct work_struct work;
 	u8 profile_ix;
 	u8 mode;
@@ -246,6 +251,23 @@ dim_update_sample(u16 event_ctr, u64 packets, u64 bytes, struct dim_sample *s)
 	s->event_ctr = event_ctr;
 }
 
+/**
+ *	dim_update_sample_with_comps - set a sample's fields with given
+ *	values including the completion parameter
+ *	@event_ctr: number of events to set
+ *	@packets: number of packets to set
+ *	@bytes: number of bytes to set
+ *	@comps: number of completions to set
+ *	@s: DIM sample
+ */
+static inline void
+dim_update_sample_with_comps(u16 event_ctr, u64 packets, u64 bytes, u64 comps,
+			     struct dim_sample *s)
+{
+	dim_update_sample(event_ctr, packets, bytes, s);
+	s->comp_ctr = comps;
+}
+
 /* Net DIM */
 
 /*
diff --git a/lib/dim/dim.c b/lib/dim/dim.c
index 17d5236759bd..439d641ec796 100644
--- a/lib/dim/dim.c
+++ b/lib/dim/dim.c
@@ -62,6 +62,8 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
 	u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
 	u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
 			     start->byte_ctr);
+	u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32), end->comp_ctr,
+			     start->comp_ctr);
 
 	if (!delta_us)
 		return;
@@ -70,5 +72,12 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
 	curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
 	curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC,
 					delta_us);
+	curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us);
+	if (curr_stats->epms != 0)
+		curr_stats->cpe_ratio =
+				(curr_stats->cpms * 100) / curr_stats->epms;
+	else
+		curr_stats->cpe_ratio = 0;
+
 }
 EXPORT_SYMBOL(dim_calc_stats);
-- 
2.21.0


  parent reply	other threads:[~2019-06-25 20:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 20:57 [pull request][for-next V2 0/7] Generic DIM lib for netdev and RDMA Saeed Mahameed
2019-06-25 20:57 ` [for-next V2 01/10] linux/dim: Move logic to dim.h Saeed Mahameed
2019-06-25 21:53   ` Sagi Grimberg
2019-06-25 20:57 ` [for-next V2 02/10] linux/dim: Remove "net" prefix from internal DIM members Saeed Mahameed
2019-06-25 21:53   ` Sagi Grimberg
2019-06-25 20:57 ` [for-next V2 03/10] linux/dim: Rename externally exposed macros Saeed Mahameed
2019-06-25 21:54   ` Sagi Grimberg
2019-06-25 20:57 ` [for-next V2 04/10] linux/dim: Rename net_dim_sample() to net_dim_update_sample() Saeed Mahameed
2019-06-25 21:55   ` Sagi Grimberg
2019-06-25 20:57 ` [for-next V2 05/10] linux/dim: Rename externally used net_dim members Saeed Mahameed
2019-06-25 21:57   ` Sagi Grimberg
2019-06-26  6:38     ` Tal Gilboa
2019-06-25 20:57 ` [for-next V2 06/10] linux/dim: Move implementation to .c files Saeed Mahameed
2019-07-02 16:15   ` Geert Uytterhoeven
2019-06-25 20:57 ` Saeed Mahameed [this message]
2019-06-25 20:57 ` [for-next V2 08/10] linux/dim: Implement rdma_dim Saeed Mahameed
2019-06-25 22:02   ` Sagi Grimberg
2019-06-26 11:57     ` Or Gerlitz
2019-06-27  5:25     ` Yamin Friedman
2019-06-25 20:57 ` [for-next V2 09/10] RDMA/nldev: Added configuration of RDMA dynamic interrupt moderation to netlink Saeed Mahameed
2019-06-25 21:15   ` Sagi Grimberg
2019-06-27  5:29     ` Yamin Friedman
2019-06-25 20:57 ` [for-next V2 10/10] RDMA/core: Provide RDMA DIM support for ULPs Saeed Mahameed
2019-06-25 21:14   ` Sagi Grimberg
2019-06-26  7:56     ` Idan Burstein
2019-07-02  5:36       ` Sagi Grimberg
2019-07-02  6:41         ` Leon Romanovsky
2019-07-03 18:56           ` Sagi Grimberg
2019-07-04  7:51             ` Leon Romanovsky
2019-07-04 12:30         ` Idan Burstein
2019-06-27  5:28     ` Yamin Friedman
2019-06-25 21:07 ` [pull request][for-next V2 0/7] Generic DIM lib for netdev and RDMA Saeed Mahameed
2019-06-27 19:43 ` David Miller

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=20190625205701.17849-8-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maxg@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=talgi@mellanox.com \
    --cc=yaminf@mellanox.com \
    /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).