Skip to content

Commit efe2803

Browse files
Mingming Caokuba-moo
authored andcommitted
ibmvnic: Use ndo_get_stats64 to fix inaccurate SAR reporting
VNIC testing on multi-core Power systems showed SAR stats drift and packet rate inconsistencies under load. Implements ndo_get_stats64 to provide safe aggregation of queue-level atomic64 counters into rtnl_link_stats64 for use by tools like 'ip -s', 'ifconfig', and 'sar'. Switch to ndo_get_stats64 to align SAR reporting with the standard kernel interface for retrieving netdev stats. This removes redundant per-adapter stat updates, reduces overhead, eliminates cacheline bouncing from hot path updates, and improves the accuracy of reported packet rates. Signed-off-by: Mingming Cao <[email protected]> Reviewed-by: Brian King <[email protected]> Reviewed-by: Dave Marquardt <[email protected]> Reviewed-by: Simon Horman <[email protected]> ---- Changes since v3: link to v3: https://www.spinics.net/lists/netdev/msg1107999.html -- keep per queue counters as u64 (this patch) and drop off patch 1 in v3 Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0dce684 commit efe2803

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,8 +2312,6 @@ static void ibmvnic_tx_scrq_clean_buffer(struct ibmvnic_adapter *adapter,
23122312
tx_pool->num_buffers - 1 :
23132313
tx_pool->consumer_index - 1;
23142314
tx_buff = &tx_pool->tx_buff[index];
2315-
adapter->netdev->stats.tx_packets--;
2316-
adapter->netdev->stats.tx_bytes -= tx_buff->skb->len;
23172315
adapter->tx_stats_buffers[queue_num].batched_packets--;
23182316
adapter->tx_stats_buffers[queue_num].bytes -=
23192317
tx_buff->skb->len;
@@ -2647,9 +2645,6 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
26472645
}
26482646
out:
26492647
rcu_read_unlock();
2650-
netdev->stats.tx_dropped += tx_dropped;
2651-
netdev->stats.tx_bytes += tx_bytes;
2652-
netdev->stats.tx_packets += tx_bpackets + tx_dpackets;
26532648
adapter->tx_send_failed += tx_send_failed;
26542649
adapter->tx_map_failed += tx_map_failed;
26552650
adapter->tx_stats_buffers[queue_num].batched_packets += tx_bpackets;
@@ -3452,6 +3447,25 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter,
34523447
return -ret;
34533448
}
34543449

3450+
static void ibmvnic_get_stats64(struct net_device *netdev,
3451+
struct rtnl_link_stats64 *stats)
3452+
{
3453+
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3454+
int i;
3455+
3456+
for (i = 0; i < adapter->req_rx_queues; i++) {
3457+
stats->rx_packets += adapter->rx_stats_buffers[i].packets;
3458+
stats->rx_bytes += adapter->rx_stats_buffers[i].bytes;
3459+
}
3460+
3461+
for (i = 0; i < adapter->req_tx_queues; i++) {
3462+
stats->tx_packets += adapter->tx_stats_buffers[i].batched_packets;
3463+
stats->tx_packets += adapter->tx_stats_buffers[i].direct_packets;
3464+
stats->tx_bytes += adapter->tx_stats_buffers[i].bytes;
3465+
stats->tx_dropped += adapter->tx_stats_buffers[i].dropped_packets;
3466+
}
3467+
}
3468+
34553469
static void ibmvnic_tx_timeout(struct net_device *dev, unsigned int txqueue)
34563470
{
34573471
struct ibmvnic_adapter *adapter = netdev_priv(dev);
@@ -3567,8 +3581,6 @@ static int ibmvnic_poll(struct napi_struct *napi, int budget)
35673581

35683582
length = skb->len;
35693583
napi_gro_receive(napi, skb); /* send it up */
3570-
netdev->stats.rx_packets++;
3571-
netdev->stats.rx_bytes += length;
35723584
adapter->rx_stats_buffers[scrq_num].packets++;
35733585
adapter->rx_stats_buffers[scrq_num].bytes += length;
35743586
frames_processed++;
@@ -3678,6 +3690,7 @@ static const struct net_device_ops ibmvnic_netdev_ops = {
36783690
.ndo_set_rx_mode = ibmvnic_set_multi,
36793691
.ndo_set_mac_address = ibmvnic_set_mac,
36803692
.ndo_validate_addr = eth_validate_addr,
3693+
.ndo_get_stats64 = ibmvnic_get_stats64,
36813694
.ndo_tx_timeout = ibmvnic_tx_timeout,
36823695
.ndo_change_mtu = ibmvnic_change_mtu,
36833696
.ndo_features_check = ibmvnic_features_check,

0 commit comments

Comments
 (0)