hwpmc: set default rate if event description lacks one / filter rate against misuse
Not all event descriptions have a sample rate (such as inst_retired.any) this will restore the legacy behavior of using 65536 in that case. It also prevents accidental API misuse that could lead to panic. PR: 230985 Reported by: markj Reviewed by: markj Approved by: re (gjb) Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D16958
This commit is contained in:
parent
3b9156971f
commit
0204d85a62
@ -237,6 +237,7 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin)
|
||||
return (ENOMEM);
|
||||
r = event;
|
||||
bzero(ped, sizeof(*ped));
|
||||
ped->ped_period = DEFAULT_SAMPLE_COUNT;
|
||||
ped->ped_umask = -1;
|
||||
while ((kvp = strsep(&event, ",")) != NULL) {
|
||||
key = strsep(&kvp, "=");
|
||||
|
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sx.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
@ -3942,9 +3943,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
|
||||
pmc->pm_flags = pa.pm_flags;
|
||||
|
||||
/* XXX set lower bound on sampling for process counters */
|
||||
if (PMC_IS_SAMPLING_MODE(mode))
|
||||
pmc->pm_sc.pm_reloadcount = pa.pm_count;
|
||||
else
|
||||
if (PMC_IS_SAMPLING_MODE(mode)) {
|
||||
/*
|
||||
* Don't permit requested sample rate to be less than 1000
|
||||
*/
|
||||
if (pa.pm_count < 1000)
|
||||
log(LOG_WARNING,
|
||||
"pmcallocate: passed sample rate %ju - setting to 1000\n",
|
||||
(uintmax_t)pa.pm_count);
|
||||
pmc->pm_sc.pm_reloadcount = MAX(1000, pa.pm_count);
|
||||
} else
|
||||
pmc->pm_sc.pm_initial = pa.pm_count;
|
||||
|
||||
/* switch thread to CPU 'cpu' */
|
||||
@ -4460,9 +4468,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
|
||||
break;
|
||||
}
|
||||
|
||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
|
||||
pm->pm_sc.pm_reloadcount = sc.pm_count;
|
||||
else
|
||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) {
|
||||
/*
|
||||
* Don't permit requested sample rate to be less than 1000
|
||||
*/
|
||||
if (sc.pm_count < 1000)
|
||||
log(LOG_WARNING,
|
||||
"pmcsetcount: passed sample rate %ju - setting to 1000\n",
|
||||
(uintmax_t)sc.pm_count);
|
||||
pm->pm_sc.pm_reloadcount = MAX(1000, sc.pm_count);
|
||||
} else
|
||||
pm->pm_sc.pm_initial = sc.pm_count;
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user