diff options
author | Kevin Traynor <ktraynor@redhat.com> | 2023-01-24 09:59:32 +0000 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2023-01-27 16:57:27 +0100 |
commit | 7db18054ffee964b5a32c5f88e7dd3a0ee60b82e (patch) | |
tree | b80142d924d279d97106119b9ed0c622d3ddb710 /lib | |
parent | 4f0a728a590d34e65bcfcf7efe130f8905ea5857 (diff) | |
download | openvswitch-7db18054ffee964b5a32c5f88e7dd3a0ee60b82e.tar.gz |
dpif-netdev-perf: Remove not a number stat value.
Some stats in pmd-perf-show don't check for divide by zero
which results in not a number (-nan).
This is a normal case for some of the stats when there are
no Rx queues assigned to the PMD thread core.
It is not obvious what -nan is to a user so add a check for
divide by zero and set stat to 0 if present.
Before patch:
pmd thread numa_id 1 core_id 9:
Iterations: 0 (-nan us/it)
- Used TSC cycles: 0 ( 0.0 % of total cycles)
- idle iterations: 0 ( -nan % of used cycles)
- busy iterations: 0 ( -nan % of used cycles)
After patch:
pmd thread numa_id 1 core_id 9:
Iterations: 0 (0.00 us/it)
- Used TSC cycles: 0 ( 0.0 % of total cycles)
- idle iterations: 0 ( 0.0 % of used cycles)
- busy iterations: 0 ( 0.0 % of used cycles)
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpif-netdev-perf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/dpif-netdev-perf.c b/lib/dpif-netdev-perf.c index 1a7bab04c..a552948ac 100644 --- a/lib/dpif-netdev-perf.c +++ b/lib/dpif-netdev-perf.c @@ -241,12 +241,14 @@ pmd_perf_format_overall_stats(struct ds *str, struct pmd_perf_stats *s, " - sleep iterations: %12"PRIu64" (%5.1f %% of iterations)\n" " Sleep time (us): %12.0f (%3.0f us/iteration avg.)\n", tot_iter, - (tot_cycles + tot_sleep_cycles) * us_per_cycle / tot_iter, + tot_iter + ? (tot_cycles + tot_sleep_cycles) * us_per_cycle / tot_iter + : 0, tot_cycles, 100.0 * (tot_cycles / duration) / tsc_hz, idle_iter, - 100.0 * stats[PMD_CYCLES_ITER_IDLE] / tot_cycles, + tot_cycles ? 100.0 * stats[PMD_CYCLES_ITER_IDLE] / tot_cycles : 0, busy_iter, - 100.0 * stats[PMD_CYCLES_ITER_BUSY] / tot_cycles, + tot_cycles ? 100.0 * stats[PMD_CYCLES_ITER_BUSY] / tot_cycles : 0, sleep_iter, tot_iter ? 100.0 * sleep_iter / tot_iter : 0, tot_sleep_cycles * us_per_cycle, sleep_iter ? (tot_sleep_cycles * us_per_cycle) / sleep_iter : 0); |