Message ID | 20200617144307.9961-4-honnappa.nagarahalli@arm.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/5] app/testpmd: clock gettime call in throughput calculation | expand |
> -----Original Message----- > From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> > Sent: Wednesday, June 17, 2020 10:43 PM > To: dev@dpdk.org; Honnappa Nagarahalli > <Honnappa.Nagarahalli@arm.com>; alialnu@mellanox.com; > orgerlitz@mellanox.com; wenzhuo.lu@intel.com; beilei.xing@intel.com; > bernard.iremonger@intel.com > Cc: hemant.agrawal@nxp.com; jerinj@marvell.com; > viacheslavo@mellanox.com; thomas@monjalon.net; Ruifeng Wang > <Ruifeng.Wang@arm.com>; Phil Yang <Phil.Yang@arm.com>; nd > <nd@arm.com>; stable@dpdk.org > Subject: [PATCH 4/5] app/testpmd: fix burst percentage calculation > > The burst % calculation can over flow due to multiplication. > Fix the multiplication and increase the size of variables to > 64b. > > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org > > Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> > Reviewed-by: Phil Yang <phil.yang@arm.com> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> > --- Tested-by: Phil Yang <phil.yang@arm.com>
> -----Original Message----- > From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> > Sent: Wednesday, June 17, 2020 5:43 PM > To: dev@dpdk.org; honnappa.nagarahalli@arm.com; Ali Alnubani > <alialnu@mellanox.com>; orgerlitz@mellanox.com; wenzhuo.lu@intel.com; > beilei.xing@intel.com; bernard.iremonger@intel.com > Cc: hemant.agrawal@nxp.com; jerinj@marvell.com; Slava Ovsiienko > <viacheslavo@mellanox.com>; Thomas Monjalon <thomas@monjalon.net>; > ruifeng.wang@arm.com; phil.yang@arm.com; nd@arm.com; > stable@dpdk.org > Subject: [PATCH 4/5] app/testpmd: fix burst percentage calculation > > The burst % calculation can over flow due to multiplication. > Fix the multiplication and increase the size of variables to 64b. > > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org > > Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> > Reviewed-by: Phil Yang <phil.yang@arm.com> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> Tested-by: Ali Alnubani <alialnu@mellanox.com>
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4989d22ca..2e1493da2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1692,9 +1692,9 @@ init_fwd_streams(void) static void pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) { - unsigned int total_burst; - unsigned int nb_burst; - unsigned int burst_stats[3]; + uint64_t total_burst; + uint64_t nb_burst; + uint64_t burst_stats[3]; uint16_t pktnb_stats[3]; uint16_t nb_pkt; int burst_percent[3]; @@ -1723,8 +1723,8 @@ pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) } if (total_burst == 0) return; - burst_percent[0] = (burst_stats[0] * 100) / total_burst; - printf(" %s-bursts : %u [%d%% of %d pkts", rx_tx, total_burst, + burst_percent[0] = (double)burst_stats[0] / total_burst * 100; + printf(" %s-bursts : %"PRIu64" [%d%% of %d pkts", rx_tx, total_burst, burst_percent[0], (int) pktnb_stats[0]); if (burst_stats[0] == total_burst) { printf("]\n"); @@ -1735,7 +1735,7 @@ pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) 100 - burst_percent[0], pktnb_stats[1]); return; } - burst_percent[1] = (burst_stats[1] * 100) / total_burst; + burst_percent[1] = (double)burst_stats[1] / total_burst * 100; burst_percent[2] = 100 - (burst_percent[0] + burst_percent[1]); if ((burst_percent[1] == 0) || (burst_percent[2] == 0)) { printf(" + %d%% of others]\n", 100 - burst_percent[0]);