pmcstat: set initial counter value to zero

For an infrequent event, pmcstat may report (u_long)-1 for CPUs where
the counter was never incremented. Just set this to zero, instead.

ev->ev_count is passed as the 'count' argument to pmc_allocate(3), but
this wasn't always the case.

Reviewed by:	gnn
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29887
This commit is contained in:
Mitchell Horne 2021-04-21 17:28:12 -03:00
parent 50f6c13997
commit edcf9e59c3

View File

@ -675,7 +675,7 @@ main(int argc, char **argv)
if (option == 'S' || option == 'P')
ev->ev_count = current_sampling_count ? current_sampling_count : pmc_pmu_sample_rate_get(ev->ev_spec);
else
ev->ev_count = -1;
ev->ev_count = 0;
if (option == 'S' || option == 's')
ev->ev_cpu = CPU_FFS(&cpumask) - 1;