diff options
author | Tal Gilboa <talgi@mellanox.com> | 2017-05-15 07:13:16 -0400 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2017-06-11 06:10:36 -0400 |
commit | c3164d2fc48fd4fa0477ab658b644559c3fe9073 (patch) | |
tree | cc73863d662e8e8063977c3d0c6e60109c19e588 | |
parent | f729860a177d097ac44321fb2f7d927a0c54c5a3 (diff) |
net/mlx5e: Added BW check for DIM decision mechanism
DIM (Dynamically-tuned Interrupt Moderation) is a mechanism designed for
changing the channel interrupt moderation values in order to reduce CPU
overhead for all traffic types.
Until now only interrupt and packet rate were sampled.
We found a scenario on which we get a false indication since a change in
DIM caused more aggregation and reduced packet rate while increasing BW.
We now regard a change as succesfull iff:
current_BW > (prev_BW + threshold) or
current_BW ~= prev_BW and current_PR > (prev_PR + threshold) or
current_BW ~= prev_BW and current_PR ~= prev_PR and
current_IR < (prev_IR - threshold)
Where BW = Bandwidth, PR = Packet rate and IR = Interrupt rate
Improvements (ConnectX-4Lx 25GbE, single RX queue, LRO off)
--------------------------------------------------
packet size | before[Mb/s] | after[Mb/s] | gain |
2B | 343.4 | 359.4 | 4.5% |
16B | 2739.7 | 2814.8 | 2.7% |
64B | 9739 | 10185.3 | 4.5% |
Fixes: cb3c7fd4f839 ("net/mlx5e: Support adaptive RX coalescing")
Signed-off-by: Tal Gilboa <talgi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | 37 |
2 files changed, 22 insertions, 17 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 2fd044b23875..429da21a583d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h | |||
@@ -458,12 +458,14 @@ struct mlx5e_mpw_info { | |||
458 | 458 | ||
459 | struct mlx5e_rx_am_stats { | 459 | struct mlx5e_rx_am_stats { |
460 | int ppms; /* packets per msec */ | 460 | int ppms; /* packets per msec */ |
461 | int bpms; /* bytes per msec */ | ||
461 | int epms; /* events per msec */ | 462 | int epms; /* events per msec */ |
462 | }; | 463 | }; |
463 | 464 | ||
464 | struct mlx5e_rx_am_sample { | 465 | struct mlx5e_rx_am_sample { |
465 | ktime_t time; | 466 | ktime_t time; |
466 | unsigned int pkt_ctr; | 467 | unsigned int pkt_ctr; |
468 | unsigned int byte_ctr; | ||
467 | u16 event_ctr; | 469 | u16 event_ctr; |
468 | }; | 470 | }; |
469 | 471 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c index 02dd3a95ed8f..54cdda957f9a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | |||
@@ -183,28 +183,27 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am) | |||
183 | mlx5e_am_step(am); | 183 | mlx5e_am_step(am); |
184 | } | 184 | } |
185 | 185 | ||
186 | #define IS_SIGNIFICANT_DIFF(val, ref) \ | ||
187 | (((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */ | ||
188 | |||
186 | static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, | 189 | static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, |
187 | struct mlx5e_rx_am_stats *prev) | 190 | struct mlx5e_rx_am_stats *prev) |
188 | { | 191 | { |
189 | int diff; | 192 | if (!prev->bpms) |
190 | 193 | return curr->bpms ? MLX5E_AM_STATS_BETTER : | |
191 | if (!prev->ppms) | ||
192 | return curr->ppms ? MLX5E_AM_STATS_BETTER : | ||
193 | MLX5E_AM_STATS_SAME; | 194 | MLX5E_AM_STATS_SAME; |
194 | 195 | ||
195 | diff = curr->ppms - prev->ppms; | 196 | if (IS_SIGNIFICANT_DIFF(curr->bpms, prev->bpms)) |
196 | if (((100 * abs(diff)) / prev->ppms) > 10) /* more than 10% diff */ | 197 | return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER : |
197 | return (diff > 0) ? MLX5E_AM_STATS_BETTER : | 198 | MLX5E_AM_STATS_WORSE; |
198 | MLX5E_AM_STATS_WORSE; | ||
199 | 199 | ||
200 | if (!prev->epms) | 200 | if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms)) |
201 | return curr->epms ? MLX5E_AM_STATS_WORSE : | 201 | return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER : |
202 | MLX5E_AM_STATS_SAME; | 202 | MLX5E_AM_STATS_WORSE; |
203 | 203 | ||
204 | diff = curr->epms - prev->epms; | 204 | if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms)) |
205 | if (((100 * abs(diff)) / prev->epms) > 10) /* more than 10% diff */ | 205 | return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER : |
206 | return (diff < 0) ? MLX5E_AM_STATS_BETTER : | 206 | MLX5E_AM_STATS_WORSE; |
207 | MLX5E_AM_STATS_WORSE; | ||
208 | 207 | ||
209 | return MLX5E_AM_STATS_SAME; | 208 | return MLX5E_AM_STATS_SAME; |
210 | } | 209 | } |
@@ -266,6 +265,7 @@ static void mlx5e_am_sample(struct mlx5e_rq *rq, | |||
266 | { | 265 | { |
267 | s->time = ktime_get(); | 266 | s->time = ktime_get(); |
268 | s->pkt_ctr = rq->stats.packets; | 267 | s->pkt_ctr = rq->stats.packets; |
268 | s->byte_ctr = rq->stats.bytes; | ||
269 | s->event_ctr = rq->cq.event_ctr; | 269 | s->event_ctr = rq->cq.event_ctr; |
270 | } | 270 | } |
271 | 271 | ||
@@ -278,12 +278,15 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start, | |||
278 | /* u32 holds up to 71 minutes, should be enough */ | 278 | /* u32 holds up to 71 minutes, should be enough */ |
279 | u32 delta_us = ktime_us_delta(end->time, start->time); | 279 | u32 delta_us = ktime_us_delta(end->time, start->time); |
280 | unsigned int npkts = end->pkt_ctr - start->pkt_ctr; | 280 | unsigned int npkts = end->pkt_ctr - start->pkt_ctr; |
281 | unsigned int nbytes = end->byte_ctr - start->byte_ctr; | ||
281 | 282 | ||
282 | if (!delta_us) | 283 | if (!delta_us) |
283 | return; | 284 | return; |
284 | 285 | ||
285 | curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us; | 286 | curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us); |
286 | curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us; | 287 | curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us); |
288 | curr_stats->epms = DIV_ROUND_UP(MLX5E_AM_NEVENTS * USEC_PER_MSEC, | ||
289 | delta_us); | ||
287 | } | 290 | } |
288 | 291 | ||
289 | void mlx5e_rx_am_work(struct work_struct *work) | 292 | void mlx5e_rx_am_work(struct work_struct *work) |