Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "joe@perches.com" <joe@perches.com>, "leon@kernel.org" <leon@kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] mlx5: Use proper logging and tracing line terminations
Date: Tue, 14 Jan 2020 20:30:55 +0000
Message-ID: <8cc2d212a2cbad7f8a91e93d1da91494505d7321.camel@mellanox.com> (raw)
In-Reply-To: <3b91c274164d1ae9d81dce9f3b398d691cc6765e.camel@perches.com>

On Sun, 2020-01-12 at 23:30 -0800, Joe Perches wrote:
> netdev_err should use newline termination but mlx5_health_report
> is used in a trace output function devlink_health_report where
> no newline should be used.
> 
> Remove the newlines from a couple formats and add a format string
> of "%s\n" to the netdev_err call to not directly output the
> logging string.
> 
> Also use snprintf to avoid any possible output string overrun.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/health.c      |  2 +-
>  drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c |  9 +++++-
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 10 +++++-
> ----
>  3 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
> index 3a9756..75a35f1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
> @@ -197,7 +197,7 @@ int mlx5e_health_report(struct mlx5e_priv *priv,
>  			struct devlink_health_reporter *reporter, char
> *err_str,
>  			struct mlx5e_err_ctx *err_ctx)
>  {
> -	netdev_err(priv->netdev, err_str);
> +	netdev_err(priv->netdev, "%s\n", err_str);
>  
>  	if (!reporter)
>  		return err_ctx->recover(&err_ctx->ctx);
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
> index 6c72b59..67d2f70 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
> @@ -110,7 +110,7 @@ void mlx5e_reporter_icosq_cqe_err(struct
> mlx5e_icosq *icosq)
>  
>  	err_ctx.ctx = icosq;
>  	err_ctx.recover = mlx5e_rx_reporter_err_icosq_cqe_recover;
> -	sprintf(err_str, "ERR CQE on ICOSQ: 0x%x", icosq->sqn);
> +	snprintf(err_str, sizeof(err_str), "ERR CQE on ICOSQ: 0x%x",
> icosq->sqn);
>  
>  	mlx5e_health_report(priv, priv->rx_reporter, err_str,
> &err_ctx);
>  }
> @@ -179,7 +179,7 @@ void mlx5e_reporter_rq_cqe_err(struct mlx5e_rq
> *rq)
>  
>  	err_ctx.ctx = rq;
>  	err_ctx.recover = mlx5e_rx_reporter_err_rq_cqe_recover;
> -	sprintf(err_str, "ERR CQE on RQ: 0x%x", rq->rqn);
> +	snprintf(err_str, sizeof(err_str), "ERR CQE on RQ: 0x%x", rq-
> >rqn);
>  
>  	mlx5e_health_report(priv, priv->rx_reporter, err_str,
> &err_ctx);
>  }
> @@ -210,8 +210,9 @@ void mlx5e_reporter_rx_timeout(struct mlx5e_rq
> *rq)
>  
>  	err_ctx.ctx = rq;
>  	err_ctx.recover = mlx5e_rx_reporter_timeout_recover;
> -	sprintf(err_str, "RX timeout on channel: %d, ICOSQ: 0x%x RQ:
> 0x%x, CQ: 0x%x\n",
> -		icosq->channel->ix, icosq->sqn, rq->rqn, rq-
> >cq.mcq.cqn);
> +	snprintf(err_str, sizeof(err_str),
> +		 "RX timeout on channel: %d, ICOSQ: 0x%x RQ: 0x%x, CQ:
> 0x%x",
> +		 icosq->channel->ix, icosq->sqn, rq->rqn, rq-
> >cq.mcq.cqn);
>  
>  	mlx5e_health_report(priv, priv->rx_reporter, err_str,
> &err_ctx);
>  }
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
> index b46854..5ecb986 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
> @@ -90,7 +90,7 @@ void mlx5e_reporter_tx_err_cqe(struct mlx5e_txqsq
> *sq)
>  
>  	err_ctx.ctx = sq;
>  	err_ctx.recover = mlx5e_tx_reporter_err_cqe_recover;
> -	sprintf(err_str, "ERR CQE on SQ: 0x%x", sq->sqn);
> +	snprintf(err_str, sizeof(err_str), "ERR CQE on SQ: 0x%x", sq-
> >sqn);
>  
>  	mlx5e_health_report(priv, priv->tx_reporter, err_str,
> &err_ctx);
>  }
> @@ -118,10 +118,10 @@ int mlx5e_reporter_tx_timeout(struct
> mlx5e_txqsq *sq)
>  
>  	err_ctx.ctx = sq;
>  	err_ctx.recover = mlx5e_tx_reporter_timeout_recover;
> -	sprintf(err_str,
> -		"TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons:
> 0x%x SQ Prod: 0x%x, usecs since last trans: %u\n",
> -		sq->channel->ix, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq-
> >pc,
> -		jiffies_to_usecs(jiffies - sq->txq->trans_start));
> +	snprintf(err_str, sizeof(err_str),
> +		 "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons:
> 0x%x SQ Prod: 0x%x, usecs since last trans: %u",
> +		 sq->channel->ix, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq-
> >pc,
> +		 jiffies_to_usecs(jiffies - sq->txq->trans_start));
>  
>  	return mlx5e_health_report(priv, priv->tx_reporter, err_str,
> &err_ctx);
>  }
> 
> 
> 

LGTM, Applied to net-next-mlx5.

Thanks,
Saeed.

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13  7:30 Joe Perches
2020-01-14 20:30 ` Saeed Mahameed [this message]

Reply instructions:

You may reply publically 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=8cc2d212a2cbad7f8a91e93d1da91494505d7321.camel@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git