[dpdk-dev,v3,1/2] net/failsafe: improve stats accuracy

Message ID 1508619286-7096-1-git-send-email-matan@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad Oct. 21, 2017, 8:54 p.m. UTC
  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 | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

V2:
Improve commit message.
Add warning massage when using stats snapshot.
Add time report from last snapshot.

V3:
Separate patch.
Replace "cycles" by "timestamp".
  

Comments

Gaëtan Rivet Oct. 23, 2017, 8:46 a.m. UTC | #1
Thanks Matan,

On Sat, Oct 21, 2017 at 08:54:45PM +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>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  drivers/net/failsafe/failsafe_ether.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> V2:
> Improve commit message.
> Add warning massage when using stats snapshot.
> Add time report from last snapshot.
> 
> V3:
> Separate patch.
> Replace "cycles" by "timestamp".
> 
> diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
> index f4db423..0282891 100644
> --- a/drivers/net/failsafe/failsafe_ether.c
> +++ b/drivers/net/failsafe/failsafe_ether.c
> @@ -312,8 +312,16 @@
>  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)
> +		WARN("Could not access latest statistics from sub-device %d,"
> +			 " using latest snapshot.\n", SUB_ID(sdev));
>  	failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator,
> -			&sdev->stats_snapshot);
> +			err ? &sdev->stats_snapshot : &stats);
>  	memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
>  }
>  
> -- 
> 1.8.3.1
>
  
Ferruh Yigit Oct. 23, 2017, 9:01 p.m. UTC | #2
On 10/23/2017 1:46 AM, Gaëtan Rivet wrote:
> Thanks Matan,
> 
> On Sat, Oct 21, 2017 at 08:54:45PM +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>
> Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>

Series applied to dpdk-next-net/master, thanks.


(Fixed build error for 32bits [1] while applying, please check.)

[1]
.../dpdk/drivers/net/failsafe/failsafe_ether.c: In function ‘fs_dev_stats_save’:
.../dpdk/drivers/net/failsafe/failsafe_ether.c:328:50: error: format ‘%lu’
expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t
{aka long long unsigned int}’ [-Werror=format=]
      (rte_rdtsc() - timestamp) / rte_get_tsc_hz());
                                                  ^
.../dpdk/i686-native-linuxapp-gcc/include/rte_log.h:345:25: note: in definition
of macro ‘RTE_LOG’
    RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__)
                         ^
.../dpdk/drivers/net/failsafe/failsafe_private.h:299:26: note: in expansion of
macro ‘LOG__’
 #define LOG_(level, ...) LOG__(level, __VA_ARGS__, '\n')
                          ^~~~~
.../dpdk/drivers/net/failsafe/failsafe_private.h:302:19: note: in expansion of
macro ‘LOG_’
 #define WARN(...) LOG_(WARNING, __VA_ARGS__)
                   ^~~~
.../dpdk/drivers/net/failsafe/failsafe_ether.c:327:4: note: in expansion of
macro ‘WARN’
    WARN("Using latest snapshot taken before %lu seconds.\n",
    ^~~~
  

Patch

diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
index f4db423..0282891 100644
--- a/drivers/net/failsafe/failsafe_ether.c
+++ b/drivers/net/failsafe/failsafe_ether.c
@@ -312,8 +312,16 @@ 
 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)
+		WARN("Could not access latest statistics from sub-device %d,"
+			 " using latest snapshot.\n", SUB_ID(sdev));
 	failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator,
-			&sdev->stats_snapshot);
+			err ? &sdev->stats_snapshot : &stats);
 	memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
 }