Skip to content

Commit c3164d2

Browse files
talgimellanoxSaeed Mahameed
authored andcommitted
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: cb3c7fd ("net/mlx5e: Support adaptive RX coalescing") Signed-off-by: Tal Gilboa <talgi@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent f729860 commit c3164d2

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,14 @@ struct mlx5e_mpw_info {
458458

459459
struct mlx5e_rx_am_stats {
460460
int ppms; /* packets per msec */
461+
int bpms; /* bytes per msec */
461462
int epms; /* events per msec */
462463
};
463464

464465
struct mlx5e_rx_am_sample {
465466
ktime_t time;
466467
unsigned int pkt_ctr;
468+
unsigned int byte_ctr;
467469
u16 event_ctr;
468470
};
469471

drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,27 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am)
183183
mlx5e_am_step(am);
184184
}
185185

186+
#define IS_SIGNIFICANT_DIFF(val, ref) \
187+
(((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */
188+
186189
static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr,
187190
struct mlx5e_rx_am_stats *prev)
188191
{
189-
int diff;
190-
191-
if (!prev->ppms)
192-
return curr->ppms ? MLX5E_AM_STATS_BETTER :
192+
if (!prev->bpms)
193+
return curr->bpms ? MLX5E_AM_STATS_BETTER :
193194
MLX5E_AM_STATS_SAME;
194195

195-
diff = curr->ppms - prev->ppms;
196-
if (((100 * abs(diff)) / prev->ppms) > 10) /* more than 10% diff */
197-
return (diff > 0) ? MLX5E_AM_STATS_BETTER :
198-
MLX5E_AM_STATS_WORSE;
196+
if (IS_SIGNIFICANT_DIFF(curr->bpms, prev->bpms))
197+
return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER :
198+
MLX5E_AM_STATS_WORSE;
199199

200-
if (!prev->epms)
201-
return curr->epms ? MLX5E_AM_STATS_WORSE :
202-
MLX5E_AM_STATS_SAME;
200+
if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms))
201+
return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER :
202+
MLX5E_AM_STATS_WORSE;
203203

204-
diff = curr->epms - prev->epms;
205-
if (((100 * abs(diff)) / prev->epms) > 10) /* more than 10% diff */
206-
return (diff < 0) ? MLX5E_AM_STATS_BETTER :
207-
MLX5E_AM_STATS_WORSE;
204+
if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms))
205+
return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER :
206+
MLX5E_AM_STATS_WORSE;
208207

209208
return MLX5E_AM_STATS_SAME;
210209
}
@@ -266,6 +265,7 @@ static void mlx5e_am_sample(struct mlx5e_rq *rq,
266265
{
267266
s->time = ktime_get();
268267
s->pkt_ctr = rq->stats.packets;
268+
s->byte_ctr = rq->stats.bytes;
269269
s->event_ctr = rq->cq.event_ctr;
270270
}
271271

@@ -278,12 +278,15 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
278278
/* u32 holds up to 71 minutes, should be enough */
279279
u32 delta_us = ktime_us_delta(end->time, start->time);
280280
unsigned int npkts = end->pkt_ctr - start->pkt_ctr;
281+
unsigned int nbytes = end->byte_ctr - start->byte_ctr;
281282

282283
if (!delta_us)
283284
return;
284285

285-
curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us;
286-
curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us;
286+
curr_stats->ppms = DIV_ROUND_UP(npkts * 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);
287290
}
288291

289292
void mlx5e_rx_am_work(struct work_struct *work)

0 commit comments

Comments
 (0)