prof_state_toggle: keep a count of CPUs with profiling enabled
authorcheloha <cheloha@openbsd.org>
Tue, 25 Apr 2023 01:32:36 +0000 (01:32 +0000)
committercheloha <cheloha@openbsd.org>
Tue, 25 Apr 2023 01:32:36 +0000 (01:32 +0000)
commit0c617055fdbf512b216ce7871dd551e09333098d
tree8f1ae82635ba43976e029d847362601d685b668d
parentd624e113b0ce84e371a65fa5285d02714cfed918
prof_state_toggle: keep a count of CPUs with profiling enabled

On MULTIPROCESSOR systems, the following sequence of kgmon(8)
invocations leaves the statclock() frequency at stathz when there is
still a CPU on the system where the gmon state is GMON_PROF_ON:

# kgmon -c 0 -b
# kgmon -c 1 -b
# kgmon -c 0 -h

The problem is that we aren't counting CPUs with profiling enabled.
Add "gmon_cpu_count" to keep a count.  Call startprofclock() for the
first CPU to enable profiling and stopprofclock() for the last CPU to
disable profiling.
sys/kern/subr_prof.c