public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: brenohl@br.ibm.com
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] ehea: Remove sleep at .ndo_get_stats
Date: Mon, 26 Sep 2011 21:42:59 +0200	[thread overview]
Message-ID: <1317066179.2796.9.camel@edumazet-laptop> (raw)
In-Reply-To: <1317064918-1481-1-git-send-email-brenohl@br.ibm.com>

Le lundi 26 septembre 2011 à 16:21 -0300, brenohl@br.ibm.com a écrit :
> Currently ehea ndo_get_stats can sleep in two places, in a hcall
> and in a GFP_KERNEL alloc, which is not correct.
> This patch creates a delayed workqueue that grabs the information each 1
> sec from the hardware, and place it into the device structure, so that,
> .ndo_get_stats quickly returns the device structure statistics block.
> 
> Signed-off-by: Breno Leitao <brenohl@br.ibm.com>
> ---
>  drivers/net/ethernet/ibm/ehea/ehea.h      |    1 +
>  drivers/net/ethernet/ibm/ehea/ehea_main.c |   53 ++++++++++++++++------------
>  2 files changed, 31 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/ehea/ehea.h b/drivers/net/ethernet/ibm/ehea/ehea.h
> index 7dd5e6a..0b8e6a9 100644
> --- a/drivers/net/ethernet/ibm/ehea/ehea.h
> +++ b/drivers/net/ethernet/ibm/ehea/ehea.h
> @@ -459,6 +459,7 @@ struct ehea_port {
>  	struct ehea_mc_list *mc_list;	 /* Multicast MAC addresses */
>  	struct ehea_eq *qp_eq;
>  	struct work_struct reset_task;
> +	struct delayed_work stats_work;
>  	struct mutex port_lock;
>  	char int_aff_name[EHEA_IRQ_NAME_SIZE];
>  	int allmulti;			 /* Indicates IFF_ALLMULTI state */
> diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
> index 583bcd3..976988d 100644
> --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
> +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
> @@ -331,16 +331,34 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
>  {
>  	struct ehea_port *port = netdev_priv(dev);
>  	struct net_device_stats *stats = &port->stats;
> -	struct hcp_ehea_port_cb2 *cb2;
> -	u64 hret, rx_packets, tx_packets, rx_bytes = 0, tx_bytes = 0;
>  	int i;
>  
> -	memset(stats, 0, sizeof(*stats));
> +	for (i = 0; i < port->num_def_qps; i++) {
> +		stats->rx_packets += port->port_res[i].rx_packets;
> +		stats->rx_bytes   += port->port_res[i].rx_bytes;
> +	}
> +

No.

You _really_ need the temporary variables, and set stats->field once
final result is known. Right now, you are adding data over and over.

Please test your patches :(

> +	for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) {
> +		stats->tx_packets += port->port_res[i].tx_packets;
> +		stats->tx_bytes   += port->port_res[i].tx_bytes;
> +	}
> +
> +	return &port->stats;

	return stats;

> +}
> +

  reply	other threads:[~2011-09-26 19:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 14:10 [PATCH net-next] ehea: Remove sleep at .ndo_get_stats brenohl
2011-09-22 15:14 ` Eric Dumazet
2011-09-26 17:15   ` [PATCH] " brenohl
2011-09-26 18:02     ` Eric Dumazet
2011-09-26 18:56       ` Breno Leitao
2011-09-26 19:21       ` brenohl
2011-09-26 19:42         ` Eric Dumazet [this message]
2011-09-26 20:11           ` brenohl
2011-09-26 20:28             ` Eric Dumazet
2011-09-27  4:47               ` David Miller

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=1317066179.2796.9.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=brenohl@br.ibm.com \
    --cc=davem@davemloft.net \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox