From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Li RongQing <lirongqing@baidu.com>,
saeedm@nvidia.com, tariqt@nvidia.com, leon@kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org,
edumazet@google.com, davem@davemloft.net, andrew+netdev@lunn.ch
Cc: Shuo Li <lishuo02@baidu.com>
Subject: Re: [PATCH][net-next] net/mlx5e: avoid to call net_dim and dim_update_sample
Date: Mon, 16 Dec 2024 21:11:43 +0000 [thread overview]
Message-ID: <ca8b58c7-d60f-4e55-9fb5-73d9a1359758@linux.dev> (raw)
In-Reply-To: <20241212114723.38844-1-lirongqing@baidu.com>
On 12/12/2024 11:47, Li RongQing wrote:
> High cpu usage for net_dim is seen still after commit 61bf0009a765
> ("dim: pass dim_sample to net_dim() by reference"), the calling
> net_dim can be avoid under network low throughput or pingpong mode by
> checking the event counter, even under high throughput, it maybe only
> rx or tx direction
>
> And don't initialize dim_sample variable, since it will gets
> overwritten by dim_update_sample
dim_update_sample doesn't init dim_sample::comp_ctr, which is later used
in net_dim()->dim_calc_stats(). This change can bring uninitialized
memory to the whole calculation. Keep it initialized.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Signed-off-by: Shuo Li <lishuo02@baidu.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
> index 7610829..7c525e9 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
> @@ -49,11 +49,19 @@ static inline bool mlx5e_channel_no_affinity_change(struct mlx5e_channel *c)
> static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq)
> {
> struct mlx5e_sq_stats *stats = sq->stats;
> - struct dim_sample dim_sample = {};
> + struct dim_sample dim_sample;
> + u16 nevents;
>
> if (unlikely(!test_bit(MLX5E_SQ_STATE_DIM, &sq->state)))
> return;
>
> + if (sq->dim->state == DIM_MEASURE_IN_PROGRESS) {
> + nevents = BIT_GAP(BITS_PER_TYPE(u16), sq->cq.event_ctr,
> + sq->dim->start_sample.event_ctr);
> + if (nevents < DIM_NEVENTS)
> + return;
> + }
> +
> dim_update_sample(sq->cq.event_ctr, stats->packets, stats->bytes, &dim_sample);
> net_dim(sq->dim, &dim_sample);
> }
> @@ -61,11 +69,19 @@ static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq)
> static void mlx5e_handle_rx_dim(struct mlx5e_rq *rq)
> {
> struct mlx5e_rq_stats *stats = rq->stats;
> - struct dim_sample dim_sample = {};
> + struct dim_sample dim_sample;
> + u16 nevents;
>
> if (unlikely(!test_bit(MLX5E_RQ_STATE_DIM, &rq->state)))
> return;
>
> + if (rq->dim->state == DIM_MEASURE_IN_PROGRESS) {
> + nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr,
> + rq->dim->start_sample.event_ctr);
> + if (nevents < DIM_NEVENTS)
> + return;
> + }
> +
> dim_update_sample(rq->cq.event_ctr, stats->packets, stats->bytes, &dim_sample);
> net_dim(rq->dim, &dim_sample);
> }
next prev parent reply other threads:[~2024-12-16 21:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 11:47 [PATCH][net-next] net/mlx5e: avoid to call net_dim and dim_update_sample Li RongQing
2024-12-16 5:09 ` Przemek Kitszel
2024-12-16 21:11 ` Vadim Fedorenko [this message]
2024-12-17 1:58 ` 答复: [外部邮件] " Li,Rongqing
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=ca8b58c7-d60f-4e55-9fb5-73d9a1359758@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=lirongqing@baidu.com \
--cc=lishuo02@baidu.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.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.