bitrate: fix integer roundoff
In the absence of traffic, it is possible for the bitrate moving average
to get stuck at a non-zero value, due to the calculated delta being less
than what an integer can represent.
Fixes: 2ad7ba9a65
("bitrate: add bitrate statistics library")
Signed-off-by: Remy Horton <remy.horton@intel.com>
This commit is contained in:
parent
917f49cfd0
commit
0caf728114
@ -118,6 +118,11 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
|
||||
else
|
||||
delta = (delta * alpha_percent - 50) / 100;
|
||||
port_data->ewma_ibits += delta;
|
||||
/* Integer roundoff prevents EWMA between 0 and (100/alpha_percent)
|
||||
* ever reaching zero in no-traffic conditions
|
||||
*/
|
||||
if (cnt_bits == 0 && delta == 0)
|
||||
port_data->ewma_ibits = 0;
|
||||
port_data->mean_ibits = cnt_bits;
|
||||
|
||||
/* Outgoing bitrate (also EWMA) */
|
||||
@ -132,6 +137,8 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
|
||||
else
|
||||
delta = (delta * alpha_percent - 50) / 100;
|
||||
port_data->ewma_obits += delta;
|
||||
if (cnt_bits == 0 && delta == 0)
|
||||
port_data->ewma_obits = 0;
|
||||
port_data->mean_obits = cnt_bits;
|
||||
|
||||
values[0] = port_data->ewma_ibits;
|
||||
|
Loading…
Reference in New Issue
Block a user