DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
To: Matan Azrad <matan@mellanox.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] net/failsafe: improve stats accuracy
Date: Thu, 19 Oct 2017 17:08:49 +0200	[thread overview]
Message-ID: <20171019150849.GG3596@bidouze.vm.6wind.com> (raw)
In-Reply-To: <1508423514-28557-1-git-send-email-matan@mellanox.com>

Hello Matan,

Adding the time delta should have been done in a separate commit.
Can you please divide this patch in two?

The first one will only attempt the ultimate stat read, the second one
would add the delay warning.

Small nit below for your v3.

On Thu, Oct 19, 2017 at 02:31:54PM +0000, Matan Azrad wrote:
> The stats_get API was changed to signal a potential failure to read
> stats. Furthermore, some PMDs are able to provide statistics even after
> a removal event occurred.
> 
> Considering this, the fail-safe can try to access the latest statistics
> of a PMD to improve statistics accuracy.
> 
> Attempt an ultimate statistics read on removal time; if that fails, use
> the latest recorded snapshot.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/failsafe/failsafe_ether.c   | 19 +++++++++++++++++--
>  drivers/net/failsafe/failsafe_ops.c     | 10 ++++++++--
>  drivers/net/failsafe/failsafe_private.h |  7 ++++++-
>  3 files changed, 31 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
> index f4db423..df38360 100644
> --- a/drivers/net/failsafe/failsafe_ether.c
> +++ b/drivers/net/failsafe/failsafe_ether.c
> @@ -35,6 +35,7 @@
>  
>  #include <rte_flow.h>
>  #include <rte_flow_driver.h>
> +#include <rte_cycles.h>
>  
>  #include "failsafe_private.h"
>  
> @@ -312,9 +313,23 @@
>  static void
>  fs_dev_stats_save(struct sub_device *sdev)
>  {
> +	struct rte_eth_stats stats;
> +	int err;
> +
> +	/* Attempt to read current stats. */
> +	err = rte_eth_stats_get(PORT_ID(sdev), &stats);
> +	if (err) {
> +		uint64_t cycles = sdev->stats_snapshot.cycles;
> +
> +		WARN("Could not access latest statistics from sub-device %d.\n",
> +			 SUB_ID(sdev));
> +		if (cycles != 0)
> +			WARN("Using latest snapshot taken before %lu seconds.\n",
> +				 (rte_rdtsc() - cycles) / rte_get_tsc_hz());
> +	}
>  	failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator,
> -			&sdev->stats_snapshot);
> -	memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
> +			err ? &sdev->stats_snapshot.stats : &stats);
> +	memset(&sdev->stats_snapshot, 0, sizeof(sdev->stats_snapshot));
>  }
>  
>  static inline int
> diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
> index d360965..818f12d 100644
> --- a/drivers/net/failsafe/failsafe_ops.c
> +++ b/drivers/net/failsafe/failsafe_ops.c
> @@ -38,6 +38,7 @@
>  #include <rte_ethdev.h>
>  #include <rte_malloc.h>
>  #include <rte_flow.h>
> +#include <rte_cycles.h>
>  
>  #include "failsafe_private.h"
>  
> @@ -592,13 +593,18 @@
>  
>  	rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
>  	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
> -		ret = rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot);
> +		struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats;
> +		uint64_t *cycles = &sdev->stats_snapshot.cycles;
> +
> +		ret = rte_eth_stats_get(PORT_ID(sdev), snapshot);
>  		if (ret) {
>  			ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
>  				  i, ret);
> +			*cycles = 0;
>  			return ret;
>  		}
> -		failsafe_stats_increment(stats, &sdev->stats_snapshot);
> +		*cycles = rte_rdtsc();
> +		failsafe_stats_increment(stats, snapshot);
>  	}
>  	return 0;
>  }
> diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
> index d343ebf..1df52f4 100644
> --- a/drivers/net/failsafe/failsafe_private.h
> +++ b/drivers/net/failsafe/failsafe_private.h
> @@ -93,6 +93,11 @@ enum dev_state {
>  	DEV_STARTED,
>  };
>  
> +struct fs_stats {
> +	struct rte_eth_stats stats;
> +	uint64_t cycles;

What do you think of the name "timestamp" for this field?
It would be more descriptive of its use.

> +};
> +
>  struct sub_device {
>  	/* Exhaustive DPDK device description */
>  	struct rte_devargs devargs;
> @@ -103,7 +108,7 @@ struct sub_device {
>  	/* Device state machine */
>  	enum dev_state state;
>  	/* Last stats snapshot passed to user */
> -	struct rte_eth_stats stats_snapshot;
> +	struct fs_stats stats_snapshot;
>  	/* Some device are defined as a command line */
>  	char *cmdline;
>  	/* fail-safe device backreference */
> -- 
> 1.8.3.1
> 

Thanks,

-- 
Gaëtan Rivet
6WIND

  reply	other threads:[~2017-10-19 15:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16  7:41 [dpdk-dev] [PATCH] " Matan Azrad
2017-10-16  8:27 ` Gaëtan Rivet
2017-10-16  8:51   ` Matan Azrad
2017-10-19 14:31 ` [dpdk-dev] [PATCH v2] " Matan Azrad
2017-10-19 15:08   ` Gaëtan Rivet [this message]
2017-10-21 20:54   ` [dpdk-dev] [PATCH v3 1/2] " Matan Azrad
2017-10-21 20:54     ` [dpdk-dev] [PATCH v3 2/2] net/failsafe: add timestamp to stats snapshot Matan Azrad
2017-10-23  8:46       ` Gaëtan Rivet
2017-10-23  8:46     ` [dpdk-dev] [PATCH v3 1/2] net/failsafe: improve stats accuracy Gaëtan Rivet
2017-10-23 21:01       ` Ferruh Yigit

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=20171019150849.GG3596@bidouze.vm.6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).