From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v3 2/2] net/failsafe: add timestamp to stats snapshot Date: Mon, 23 Oct 2017 10:46:37 +0200 Message-ID: <20171023084637.GM3596@bidouze.vm.6wind.com> References: <1508423514-28557-1-git-send-email-matan@mellanox.com> <1508619286-7096-1-git-send-email-matan@mellanox.com> <1508619286-7096-2-git-send-email-matan@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org To: Matan Azrad Return-path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id C87821B3BE for ; Mon, 23 Oct 2017 10:46:49 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id u138so7951915wmu.5 for ; Mon, 23 Oct 2017 01:46:49 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1508619286-7096-2-git-send-email-matan@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sat, Oct 21, 2017 at 08:54:46PM +0000, Matan Azrad wrote: > Fail-safe attempts to read an ultimate statistics on removal time; if > that fails, it uses the latest recorded snapshot. > > This patch adds timestamp for each stats snapshot to allow a time report > since the last snapshot in case of the above failure. > > By this way, the user can estimate the stats read accuracy. > > Signed-off-by: Matan Azrad Acked-by: Gaetan Rivet > --- > drivers/net/failsafe/failsafe_ether.c | 17 ++++++++++++----- > drivers/net/failsafe/failsafe_ops.c | 10 ++++++++-- > drivers/net/failsafe/failsafe_private.h | 7 ++++++- > 3 files changed, 26 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c > index 0282891..6cb435f 100644 > --- a/drivers/net/failsafe/failsafe_ether.c > +++ b/drivers/net/failsafe/failsafe_ether.c > @@ -35,6 +35,7 @@ > > #include > #include > +#include > > #include "failsafe_private.h" > > @@ -317,12 +318,18 @@ > > /* Attempt to read current stats. */ > err = rte_eth_stats_get(PORT_ID(sdev), &stats); > - if (err) > - WARN("Could not access latest statistics from sub-device %d," > - " using latest snapshot.\n", SUB_ID(sdev)); > + if (err) { > + uint64_t timestamp = sdev->stats_snapshot.timestamp; > + > + WARN("Could not access latest statistics from sub-device %d.\n", > + SUB_ID(sdev)); > + if (timestamp != 0) > + WARN("Using latest snapshot taken before %lu seconds.\n", > + (rte_rdtsc() - timestamp) / rte_get_tsc_hz()); > + } > failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator, > - err ? &sdev->stats_snapshot : &stats); > - 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..f460551 100644 > --- a/drivers/net/failsafe/failsafe_ops.c > +++ b/drivers/net/failsafe/failsafe_ops.c > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > > #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 *timestamp = &sdev->stats_snapshot.timestamp; > + > + 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); > + *timestamp = 0; > return ret; > } > - failsafe_stats_increment(stats, &sdev->stats_snapshot); > + *timestamp = 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..d81cc3c 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 timestamp; > +}; > + > 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 > -- Gaëtan Rivet 6WIND