diff options
Diffstat (limited to 'tools/perf/arch/powerpc/util/kvm-stat.c')
-rw-r--r-- | tools/perf/arch/powerpc/util/kvm-stat.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/perf/arch/powerpc/util/kvm-stat.c b/tools/perf/arch/powerpc/util/kvm-stat.c index f0dbf7b075c8..9cc1c4a9dec4 100644 --- a/tools/perf/arch/powerpc/util/kvm-stat.c +++ b/tools/perf/arch/powerpc/util/kvm-stat.c | |||
@@ -5,9 +5,11 @@ | |||
5 | #include "util/debug.h" | 5 | #include "util/debug.h" |
6 | #include "util/evsel.h" | 6 | #include "util/evsel.h" |
7 | #include "util/evlist.h" | 7 | #include "util/evlist.h" |
8 | #include "util/pmu.h" | ||
8 | 9 | ||
9 | #include "book3s_hv_exits.h" | 10 | #include "book3s_hv_exits.h" |
10 | #include "book3s_hcalls.h" | 11 | #include "book3s_hcalls.h" |
12 | #include <subcmd/parse-options.h> | ||
11 | 13 | ||
12 | #define NR_TPS 4 | 14 | #define NR_TPS 4 |
13 | 15 | ||
@@ -172,3 +174,46 @@ int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused) | |||
172 | 174 | ||
173 | return ret; | 175 | return ret; |
174 | } | 176 | } |
177 | |||
178 | /* | ||
179 | * Incase of powerpc architecture, pmu registers are programmable | ||
180 | * by guest kernel. So monitoring guest via host may not provide | ||
181 | * valid samples with default 'cycles' event. It is better to use | ||
182 | * 'trace_imc/trace_cycles' event for guest profiling, since it | ||
183 | * can track the guest instruction pointer in the trace-record. | ||
184 | * | ||
185 | * Function to parse the arguments and return appropriate values. | ||
186 | */ | ||
187 | int kvm_add_default_arch_event(int *argc, const char **argv) | ||
188 | { | ||
189 | const char **tmp; | ||
190 | bool event = false; | ||
191 | int i, j = *argc; | ||
192 | |||
193 | const struct option event_options[] = { | ||
194 | OPT_BOOLEAN('e', "event", &event, NULL), | ||
195 | OPT_END() | ||
196 | }; | ||
197 | |||
198 | tmp = calloc(j + 1, sizeof(char *)); | ||
199 | if (!tmp) | ||
200 | return -EINVAL; | ||
201 | |||
202 | for (i = 0; i < j; i++) | ||
203 | tmp[i] = argv[i]; | ||
204 | |||
205 | parse_options(j, tmp, event_options, NULL, PARSE_OPT_KEEP_UNKNOWN); | ||
206 | if (!event) { | ||
207 | if (pmu_have_event("trace_imc", "trace_cycles")) { | ||
208 | argv[j++] = strdup("-e"); | ||
209 | argv[j++] = strdup("trace_imc/trace_cycles/"); | ||
210 | *argc += 2; | ||
211 | } else { | ||
212 | free(tmp); | ||
213 | return -EINVAL; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | free(tmp); | ||
218 | return 0; | ||
219 | } | ||