Skip to content

Commit a35ee54

Browse files
Yevgeny Petrilindavem330
authored andcommitted
mlx4_en: Adaptive moderation policy change
If the net device is identified as "sender" (number of sent packets is higher then the number of received packets and the incoming packets are small), set the moderation time to its low limit. We do it because the incoming packets are acks, and we don't want to delay them Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6cb8782 commit a35ee54

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/net/mlx4/en_netdev.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
414414
unsigned long avg_pkt_size;
415415
unsigned long rx_packets;
416416
unsigned long rx_bytes;
417+
unsigned long rx_byte_diff;
417418
unsigned long tx_packets;
418419
unsigned long tx_pkt_diff;
419420
unsigned long rx_pkt_diff;
@@ -437,6 +438,8 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
437438
rx_pkt_diff = ((unsigned long) (rx_packets -
438439
priv->last_moder_packets));
439440
packets = max(tx_pkt_diff, rx_pkt_diff);
441+
rx_byte_diff = rx_bytes - priv->last_moder_bytes;
442+
rx_byte_diff = rx_byte_diff ? rx_byte_diff : 1;
440443
rate = packets * HZ / period;
441444
avg_pkt_size = packets ? ((unsigned long) (rx_bytes -
442445
priv->last_moder_bytes)) / packets : 0;
@@ -447,10 +450,13 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
447450
/* If tx and rx packet rates are not balanced, assume that
448451
* traffic is mainly BW bound and apply maximum moderation.
449452
* Otherwise, moderate according to packet rate */
450-
if (2 * tx_pkt_diff > 3 * rx_pkt_diff ||
451-
2 * rx_pkt_diff > 3 * tx_pkt_diff) {
453+
if (2 * tx_pkt_diff > 3 * rx_pkt_diff &&
454+
rx_pkt_diff / rx_byte_diff <
455+
MLX4_EN_SMALL_PKT_SIZE)
456+
moder_time = priv->rx_usecs_low;
457+
else if (2 * rx_pkt_diff > 3 * tx_pkt_diff)
452458
moder_time = priv->rx_usecs_high;
453-
} else {
459+
else {
454460
if (rate < priv->pkt_rate_low)
455461
moder_time = priv->rx_usecs_low;
456462
else if (rate > priv->pkt_rate_high)

0 commit comments

Comments
 (0)