xref: /openbmc/linux/tools/perf/arch/x86/util/evsel.c (revision 94d964e5)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "util/evsel.h"
5 #include "util/env.h"
6 #include "linux/string.h"
7 
8 void arch_evsel__set_sample_weight(struct evsel *evsel)
9 {
10 	evsel__set_sample_bit(evsel, WEIGHT_STRUCT);
11 }
12 
13 void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr)
14 {
15 	struct perf_env env = { .total_mem = 0, } ;
16 
17 	if (!perf_env__cpuid(&env))
18 		return;
19 
20 	/*
21 	 * On AMD, precise cycles event sampling internally uses IBS pmu.
22 	 * But IBS does not have filtering capabilities and perf by default
23 	 * sets exclude_guest = 1. This makes IBS pmu event init fail and
24 	 * thus perf ends up doing non-precise sampling. Avoid it by clearing
25 	 * exclude_guest.
26 	 */
27 	if (env.cpuid && strstarts(env.cpuid, "AuthenticAMD"))
28 		attr->exclude_guest = 0;
29 
30 	free(env.cpuid);
31 }
32