diff mbox series

[for-next] IB/hfi1: Add running average for adaptive pio

Message ID 20190226164609.570.55626.stgit@scvm10.sc.intel.com (mailing list archive)
State Mainlined
Commit 270a9833b2697d455f6ae12669b8220d3ea48f18
Delegated to: Jason Gunthorpe
Headers show
Series [for-next] IB/hfi1: Add running average for adaptive pio | expand

Commit Message

Dennis Dalessandro Feb. 26, 2019, 4:46 p.m. UTC
From: Mike Marciniszyn <mike.marciniszyn@intel.com>

The adaptive PIO implementation only considers the current packet size
when deciding between SDMA and pio for a packet.

This causes credit return forces if small and large packets
are interleaved.

Add a running average to avoid costly credit forces so that a large
sequence of small packets is required to go below the threshold
that chooses pio.

Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/hw/hfi1/qp.c    |    2 ++
 drivers/infiniband/hw/hfi1/verbs.c |    7 ++++---
 drivers/infiniband/hw/hfi1/verbs.h |    1 +
 3 files changed, 7 insertions(+), 3 deletions(-)

Comments

Jason Gunthorpe March 26, 2019, 12:33 p.m. UTC | #1
On Tue, Feb 26, 2019 at 08:46:16AM -0800, Dennis Dalessandro wrote:
> From: Mike Marciniszyn <mike.marciniszyn@intel.com>
> 
> The adaptive PIO implementation only considers the current packet size
> when deciding between SDMA and pio for a packet.
> 
> This causes credit return forces if small and large packets
> are interleaved.
> 
> Add a running average to avoid costly credit forces so that a large
> sequence of small packets is required to go below the threshold
> that chooses pio.
> 
> Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
> ---
>  drivers/infiniband/hw/hfi1/qp.c    |    2 ++
>  drivers/infiniband/hw/hfi1/verbs.c |    7 ++++---
>  drivers/infiniband/hw/hfi1/verbs.h |    1 +
>  3 files changed, 7 insertions(+), 3 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/qp.c b/drivers/infiniband/hw/hfi1/qp.c
index 9b643c2..1390172 100644
--- a/drivers/infiniband/hw/hfi1/qp.c
+++ b/drivers/infiniband/hw/hfi1/qp.c
@@ -742,6 +742,8 @@  void qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter)
 		iowait_wakeup,
 		iowait_sdma_drained,
 		hfi1_init_priority);
+	/* Init to a value to start the running average correctly */
+	priv->s_running_pkt_size = piothreshold / 2;
 	return priv;
 }
 
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 55a56b3..b73ab7c 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1223,15 +1223,16 @@  static inline send_routine get_send_routine(struct rvt_qp *qp,
 	case IB_QPT_UD:
 		break;
 	case IB_QPT_UC:
-	case IB_QPT_RC: {
+	case IB_QPT_RC:
+		priv->s_running_pkt_size =
+			(tx->s_cur_size + priv->s_running_pkt_size) / 2;
 		if (piothreshold &&
-		    tx->s_cur_size <= min(piothreshold, qp->pmtu) &&
+		    priv->s_running_pkt_size <= min(piothreshold, qp->pmtu) &&
 		    (BIT(ps->opcode & OPMASK) & pio_opmask[ps->opcode >> 5]) &&
 		    iowait_sdma_pending(&priv->s_iowait) == 0 &&
 		    !sdma_txreq_built(&tx->txreq))
 			return dd->process_pio_send;
 		break;
-	}
 	default:
 		break;
 	}
diff --git a/drivers/infiniband/hw/hfi1/verbs.h b/drivers/infiniband/hw/hfi1/verbs.h
index 62ace0b..7ecb8ed 100644
--- a/drivers/infiniband/hw/hfi1/verbs.h
+++ b/drivers/infiniband/hw/hfi1/verbs.h
@@ -170,6 +170,7 @@  struct hfi1_qp_priv {
 	struct tid_flow_state flow_state;
 	struct tid_rdma_qp_params tid_rdma;
 	struct rvt_qp *owner;
+	u16 s_running_pkt_size;
 	u8 hdr_type; /* 9B or 16B */
 	struct rvt_sge_state tid_ss;       /* SGE state pointer for 2nd leg */
 	atomic_t n_requests;               /* # of TID RDMA requests in the */