arm64 hwpmc: Support restricting counters to user or kernel mode.
Support the "usr" and "os" qualifiers on arm64 events to restrict event counting to either usermode or the kernel, respectively. If neither qualifier is given, events are counted in both. Reviewed by: emaste Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34527
This commit is contained in:
parent
456d57a66d
commit
6bb7ba4aa1
@ -763,13 +763,20 @@ static struct pmc_event_alias cortex_a57_aliases[] = {
|
||||
static struct pmc_event_alias cortex_a76_aliases[] = {
|
||||
EV_ALIAS(NULL, NULL)
|
||||
};
|
||||
|
||||
static int
|
||||
arm64_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
|
||||
struct pmc_op_pmcallocate *pmc_config __unused)
|
||||
arm64_allocate_pmc(enum pmc_event pe, char *ctrspec,
|
||||
struct pmc_op_pmcallocate *pmc_config)
|
||||
{
|
||||
switch (pe) {
|
||||
default:
|
||||
break;
|
||||
char *p;
|
||||
|
||||
while ((p = strsep(&ctrspec, ",")) != NULL) {
|
||||
if (KWMATCH(p, "os"))
|
||||
pmc_config->pm_caps |= PMC_CAP_SYSTEM;
|
||||
else if (KWMATCH(p, "usr"))
|
||||
pmc_config->pm_caps |= PMC_CAP_USER;
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -187,6 +187,23 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm,
|
||||
if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST))
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
switch (a->pm_caps & (PMC_CAP_SYSTEM | PMC_CAP_USER)) {
|
||||
case PMC_CAP_SYSTEM:
|
||||
config |= PMEVTYPER_U;
|
||||
break;
|
||||
case PMC_CAP_USER:
|
||||
config |= PMEVTYPER_P;
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Trace both USER and SYSTEM if none are specified
|
||||
* (default setting) or if both flags are specified
|
||||
* (user explicitly requested both qualifiers).
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
pm->pm_md.pm_arm64.pm_arm64_evsel = config;
|
||||
PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user