net: mana: Fix perf regression: remove rx_cqes, tx_cqes counters
Subsystems (7)
Haiyang Zhang
maintainerPATCH 1/1 net: mana: Fix perf regression: remove rx_cqes, tx_cqes counters
The apc->eth_stats.rx_cqes is one per NIC (vport), and it's on the frequent and parallel code path of all queues. So, r/w into this single shared variable by many threads on different CPUs creates a lot caching and memory overhead, hence perf regression. And, it's not accurate due to the high volume concurrent r/w.
Since the error path of mana_poll_rx_cq() already has warnings, so keeping the counter and convert it to a per-queue variable is not necessary. So, just remove this counter from this high frequency code path.
Also, remove the tx_cqes counter for the same reason. We have warnings & other counters for errors on that path, and don't need to count every normal cqe processing.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 10 ---------- drivers/net/ethernet/microsoft/mana/mana_ethtool.c | 2 -- include/net/mana/mana.h | 2 -- 3 files changed, 14 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +0 -10
@@ -1279,8 +1279,6 @@ static void mana_poll_tx_cq(struct mana_cq *cq)if (comp_read <1 )return ; - apc->eth_stats.tx_cqes = comp_read; -for (i =0 ; i < comp_read; i++) {struct mana_tx_comp_oob *cqe_oob;
@@ -1363,8 +1361,6 @@ static void mana_poll_tx_cq(struct mana_cq *cq)WARN_ON_ONCE (1 ); cq->work_done = pkt_transmitted; - - apc->eth_stats.tx_cqes -= pkt_transmitted; }static void mana_post_pkt_rxq (struct mana_rxq *rxq)
@@ -1626,15 +1622,11 @@ static void mana_poll_rx_cq(struct mana_cq *cq) {struct gdma_comp *comp = cq->gdma_comp_buf;struct mana_rxq *rxq = cq->rxq; -struct mana_port_context *apc;int comp_read, i; - apc =netdev_priv (rxq->ndev); - comp_read =mana_gd_poll_cq (cq->gdma_cq, comp,CQE_POLLING_BUFFER );WARN_ON_ONCE (comp_read >CQE_POLLING_BUFFER ); - apc->eth_stats.rx_cqes = comp_read; rxq->xdp_flush = false;for (i =0 ; i < comp_read; i++) {
@@ -1646,8 +1638,6 @@ static void mana_poll_rx_cq(struct mana_cq *cq)return ;mana_process_rx_cqe (rxq, cq, &comp[i]); - - apc->eth_stats.rx_cqes--; }if (rxq->xdp_flush)
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +0 -2
@@ -13,11 +13,9 @@ static const struct { } mana_eth_stats[] = { {"stop_queue", offsetof(struct mana_ethtool_stats, stop_queue)}, {"wake_queue", offsetof(struct mana_ethtool_stats, wake_queue)}, - {"tx_cqes", offsetof(struct mana_ethtool_stats, tx_cqes)}, {"tx_cq_err", offsetof(struct mana_ethtool_stats, tx_cqe_err)}, {"tx_cqe_unknown_type", offsetof(struct mana_ethtool_stats, tx_cqe_unknown_type)}, - {"rx_cqes", offsetof(struct mana_ethtool_stats, rx_cqes)}, {"rx_coalesced_err", offsetof(struct mana_ethtool_stats, rx_coalesced_err)}, {"rx_cqe_unknown_type", offsetof(struct mana_ethtool_stats,
include/net/mana/mana.h +0 -2
@@ -347,10 +347,8 @@ struct mana_tx_qp {struct mana_ethtool_stats {u64 stop_queue;u64 wake_queue; -u64 tx_cqes;u64 tx_cqe_err;u64 tx_cqe_unknown_type; -u64 rx_cqes;u64 rx_coalesced_err;u64 rx_cqe_unknown_type; };
Signature · 1 line
2.25.1
The 05/24/2023 14:22, Haiyang Zhang wrote:
Hi Haiyang,
Quoted 6 lines
The
apc->eth_stats.rx_cqesis one per NIC (vport), and it's on the frequent and parallel code path of all queues. So, r/w into this single shared variable by many threads on different CPUs creates a lot caching and memory overhead, hence perf regression. And, it's not accurate due to the high volume concurrent r/w.
Do you have any numbers to show the improvement of this change?
Quoted 9 lines
Since the error path of
mana_poll_rx_cq()already has warnings, so keeping the counter and convert it to a per-queue variable is not necessary. So, just remove this counter from this high frequency code path.Also, remove the
tx_cqescounter for the same reason. We have warnings & other counters for errors on that path, and don't need to count every normal cqe processing.
Will you not have problems with the counter 'apc->eth_stats.tx_cqe_err'? It is not in the hot path but you will have concurrent access to it.
Quoted 92 lines
Fixes bd7fc6e1957c ("net: mana: Add new MANA VF performance counters for easier troubleshooting")Signed-off-by Haiyang Zhang <[email protected]>--- drivers/net/ethernet/microsoft/mana/mana_en.c | 10 ---------- drivers/net/ethernet/microsoft/mana/mana_ethtool.c | 2 -- include/net/mana/mana.h | 2 -- 3 files changed, 14 deletions(-)drivers/net/ethernet/microsoft/mana/mana_en.c +0
-10@@ -1279,8 +1279,6 @@ static void mana_poll_tx_cq(struct mana_cq *cq)if (comp_read <1 )return ; - apc->eth_stats.tx_cqes = comp_read; -for (i =0 ; i < comp_read; i++) {struct mana_tx_comp_oob *cqe_oob;@@ -1363,8 +1361,6 @@ static void mana_poll_tx_cq(struct mana_cq *cq)WARN_ON_ONCE (1 ); cq->work_done = pkt_transmitted; - - apc->eth_stats.tx_cqes -= pkt_transmitted; }static void mana_post_pkt_rxq (struct mana_rxq *rxq)@@ -1626,15 +1622,11 @@ static void mana_poll_rx_cq(struct mana_cq *cq) {struct gdma_comp *comp = cq->gdma_comp_buf;struct mana_rxq *rxq = cq->rxq; -struct mana_port_context *apc;int comp_read, i; - apc =netdev_priv (rxq->ndev); - comp_read =mana_gd_poll_cq (cq->gdma_cq, comp,CQE_POLLING_BUFFER );WARN_ON_ONCE (comp_read >CQE_POLLING_BUFFER ); - apc->eth_stats.rx_cqes = comp_read; rxq->xdp_flush = false;for (i =0 ; i < comp_read; i++) {@@ -1646,8 +1638,6 @@ static void mana_poll_rx_cq(struct mana_cq *cq)return ;mana_process_rx_cqe (rxq, cq, &comp[i]); - - apc->eth_stats.rx_cqes--; }if (rxq->xdp_flush)drivers/net/ethernet/microsoft/mana/mana_ethtool.c +0
-2@@ -13,11 +13,9 @@ static const struct { } mana_eth_stats[] = { {"stop_queue", offsetof(struct mana_ethtool_stats, stop_queue)}, {"wake_queue", offsetof(struct mana_ethtool_stats, wake_queue)}, - {"tx_cqes", offsetof(struct mana_ethtool_stats, tx_cqes)}, {"tx_cq_err", offsetof(struct mana_ethtool_stats, tx_cqe_err)}, {"tx_cqe_unknown_type", offsetof(struct mana_ethtool_stats, tx_cqe_unknown_type)}, - {"rx_cqes", offsetof(struct mana_ethtool_stats, rx_cqes)}, {"rx_coalesced_err", offsetof(struct mana_ethtool_stats, rx_coalesced_err)}, {"rx_cqe_unknown_type", offsetof(struct mana_ethtool_stats,include/net/mana/mana.h +0
-3@@ -347,10 +347,8 @@ struct mana_tx_qp {struct mana_ethtool_stats {u64 stop_queue;u64 wake_queue; -u64 tx_cqes;u64 tx_cqe_err;u64 tx_cqe_unknown_type; -u64 rx_cqes;u64 rx_coalesced_err;u64 rx_cqe_unknown_type; }; --2.25.1
Signature · 1 line
/Horatiu
Haiyang Zhang
maintainerQuoted 28 lines
-----Original Message-----
From: Horatiu Vultur <[email protected]>
Sent: Thursday, May 25, 2023 2:49 AM
To: Haiyang Zhang <[email protected]>
Cc: [email protected]; [email protected]; Dexuan Cui <[email protected]>; KY Srinivasan <[email protected]>; Paul Rosswurm <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Long Li <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ajay Sharma <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH net] net: mana: Fix perf regression: removerx_cqes,tx_cqescounters[Some people who received this message don't often get email from [email protected]. Learn why this is important at
https://aka.ms/LearnAboutSenderIdentification ]The 05/24/2023 14:22, Haiyang Zhang wrote:
Hi Haiyang,
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
The
apc->eth_stats.rx_cqesis one per NIC (vport), and it's on the frequent and parallel code path of all queues. So, r/w into this single shared variable by many threads on different CPUs creates a lot caching and memory overhead, hence perf regression. And, it's not accurate due to the high volume concurrent r/w.Do you have any numbers to show the improvement of this change?
The numbers are not published. The perf regression of the previous patch is very significant, and this patch eliminates the regression.
Quoted 7 lines
Quoted 7 lines
Since the error path of
mana_poll_rx_cq()already has warnings, so keeping the counter and convert it to a per-queue variable is not necessary. So, just remove this counter from this high frequency code path.
Quoted 6 lines
Quoted 3 lines
Also, remove the
tx_cqescounter for the same reason. We have warnings & other counters for errors on that path, and don't need to count every normal cqe processing.Will you not have problems with the counter '
apc->eth_stats.tx_cqe_err'? It is not in the hot path but you will have concurrent access to it.
Yes, but that error happens rarely, so a shared variable is good enough. So, I don't change it in this patch.
Thanks,
- Haiyang
Quoted 49 lines · Haiyang Zhang
Quoted 27 lines
-----Original Message-----
From: Horatiu Vultur <[email protected]>
Sent: Thursday, May 25, 2023 2:49 AM
To: Haiyang Zhang <[email protected]>
Cc: [email protected]; [email protected]; Dexuan Cui <[email protected]>; KY Srinivasan <[email protected]>; Paul Rosswurm <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Long Li <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ajay Sharma <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH net] net: mana: Fix perf regression: removerx_cqes,tx_cqescounters[Some people who received this message don't often get email from [email protected]. Learn why this is important at
https://aka.ms/LearnAboutSenderIdentification ]The 05/24/2023 14:22, Haiyang Zhang wrote:
Hi Haiyang,
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
The
apc->eth_stats.rx_cqesis one per NIC (vport), and it's on the frequent and parallel code path of all queues. So, r/w into this single shared variable by many threads on different CPUs creates a lot caching and memory overhead, hence perf regression. And, it's not accurate due to the high volume concurrent r/w.Do you have any numbers to show the improvement of this change?
The numbers are not published. The perf regression of the previous patch is very significant, and this patch eliminates the regression.
Quoted 11 lines
Quoted 10 lines
Since the error path of
mana_poll_rx_cq()already has warnings, so keeping the counter and convert it to a per-queue variable is not necessary. So, just remove this counter from this high frequency code path.Also, remove the
tx_cqescounter for the same reason. We have warnings & other counters for errors on that path, and don't need to count every normal cqe processing.
Quoted 5 lines
Quoted 2 lines
Will you not have problems with the counter '
apc->eth_stats.tx_cqe_err'? It is not in the hot path but you will have concurrent access to it.Yes, but that error happens rarely, so a shared variable is good enough. So, I don't change it in this patch.
OK, I understand.
Maybe this can be fixed in a different patch at a later point. Thanks.
Quoted 4 lines
Thanks,
- Haiyang
Signature · 1 line
/Horatiu
Quoted 11 lines · Wed, May 24, 2023 at 11:22:00PM CEST, [email protected] wrote:
The
apc->eth_stats.rx_cqesis one per NIC (vport), and it's on the frequent and parallel code path of all queues. So, r/w into this single shared variable by many threads on different CPUs creates a lot caching and memory overhead, hence perf regression. And, it's not accurate due to the high volume concurrent r/w.Since the error path of
mana_poll_rx_cq()already has warnings, so keeping the counter and convert it to a per-queue variable is not necessary. So, just remove this counter from this high frequency code path.
Quoted 7 lines
Also, remove the
tx_cqescounter for the same reason. We have warnings & other counters for errors on that path, and don't need to count every normal cqe processing.Fixes bd7fc6e1957c ("net: mana: Add new MANA VF performance counters for easier troubleshooting")Signed-off-by Haiyang Zhang <[email protected]>