From: Jakub Kicinski <kuba@kernel.org>
To: Mingming Cao <mmc@linux.ibm.com>
Cc: netdev@vger.kernel.org, horms@kernel.org, bjking1@linux.ibm.com,
haren@linux.ibm.com, ricklind@linux.ibm.com,
davemarq@linux.ibm.com
Subject: Re: [PATCH v3 net-next 1/2] ibmvnic: Use atomic64_t for queue stats
Date: Tue, 15 Jul 2025 17:14:52 -0700 [thread overview]
Message-ID: <20250715171452.193ac348@kernel.org> (raw)
In-Reply-To: <20250714173507.73096-2-mmc@linux.ibm.com>
On Mon, 14 Jul 2025 13:35:06 -0400 Mingming Cao wrote:
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index 92647e137cf8..79fdba4293a4 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -2314,9 +2314,17 @@ static void ibmvnic_tx_scrq_clean_buffer(struct ibmvnic_adapter *adapter,
> tx_buff = &tx_pool->tx_buff[index];
> adapter->netdev->stats.tx_packets--;
> adapter->netdev->stats.tx_bytes -= tx_buff->skb->len;
> - adapter->tx_stats_buffers[queue_num].batched_packets--;
> - adapter->tx_stats_buffers[queue_num].bytes -=
> - tx_buff->skb->len;
> + atomic64_dec(&adapter->tx_stats_buffers[queue_num].batched_packets);
> + if (atomic64_sub_return(tx_buff->skb->len,
> + &adapter->tx_stats_buffers[queue_num].bytes) < 0) {
> + atomic64_set(&adapter->tx_stats_buffers[queue_num].bytes, 0);
> + netdev_warn(adapter->netdev,
Any datapath print needs to be rate limited, otherwise it may flood
the logs.
> + "TX stats underflow on queue %u: bytes (%lld) < skb->len (%u),\n"
> + "clamping to 0\n",
> + queue_num,
> + atomic64_read(&adapter->tx_stats_buffers[queue_num].bytes),
> + tx_buff->skb->len);
> + }
> dev_kfree_skb_any(tx_buff->skb);
> tx_buff->skb = NULL;
> adapter->netdev->stats.tx_dropped++;
> @@ -2652,10 +2660,10 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
> netdev->stats.tx_packets += tx_bpackets + tx_dpackets;
> adapter->tx_send_failed += tx_send_failed;
> adapter->tx_map_failed += tx_map_failed;
> - adapter->tx_stats_buffers[queue_num].batched_packets += tx_bpackets;
> - adapter->tx_stats_buffers[queue_num].direct_packets += tx_dpackets;
> - adapter->tx_stats_buffers[queue_num].bytes += tx_bytes;
> - adapter->tx_stats_buffers[queue_num].dropped_packets += tx_dropped;
> + atomic64_add(tx_bpackets, &adapter->tx_stats_buffers[queue_num].batched_packets);
> + atomic64_add(tx_dpackets, &adapter->tx_stats_buffers[queue_num].direct_packets);
> + atomic64_add(tx_bytes, &adapter->tx_stats_buffers[queue_num].bytes);
> + atomic64_add(tx_dropped, &adapter->tx_stats_buffers[queue_num].dropped_packets);
Are atomics really cheap on your platform? Normally having these many
atomic ops per packet would bring performance concerns.
I assume queue accesses are already protected by some sort of a lock
so isn't it enough to make the stats per queue without making them
atomic?
--
pw-bot: cr
next prev parent reply other threads:[~2025-07-16 0:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 17:35 [PATCH v3 net-next resubmit 0/2] ibmvnic: Fix/Improve queue stats Mingming Cao
2025-07-14 17:35 ` [PATCH v3 net-next 1/2] ibmvnic: Use atomic64_t for " Mingming Cao
2025-07-15 13:21 ` Simon Horman
2025-07-16 0:14 ` Jakub Kicinski [this message]
2025-07-14 17:35 ` [PATCH v3 net-next 2/2] ibmvnic: Use ndo_get_stats64 to fix inaccurate SAR reporting Mingming Cao
2025-07-15 13:22 ` Simon Horman
-- strict thread matches above, loose matches on Subject: below --
2025-07-09 18:40 [PATCH v3 net-next 0/2] ibmvnic: Fix/Improve queue stats Mingming Cao
2025-07-09 18:40 ` [PATCH v3 net-next 1/2] ibmvnic: Use atomic64_t for " Mingming Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250715171452.193ac348@kernel.org \
--to=kuba@kernel.org \
--cc=bjking1@linux.ibm.com \
--cc=davemarq@linux.ibm.com \
--cc=haren@linux.ibm.com \
--cc=horms@kernel.org \
--cc=mmc@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=ricklind@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.