Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / arch / x86 / util / topdown.c
blob2f3d96aa92a58af79d9933f378eb7317bf16d83f
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include "api/fs/fs.h"
4 #include "util/pmu.h"
5 #include "util/topdown.h"
7 /*
8 * Check whether we can use a group for top down.
9 * Without a group may get bad results due to multiplexing.
11 bool arch_topdown_check_group(bool *warn)
13 int n;
15 if (sysctl__read_int("kernel/nmi_watchdog", &n) < 0)
16 return false;
17 if (n > 0) {
18 *warn = true;
19 return false;
21 return true;
24 void arch_topdown_group_warn(void)
26 fprintf(stderr,
27 "nmi_watchdog enabled with topdown. May give wrong results.\n"
28 "Disable with echo 0 > /proc/sys/kernel/nmi_watchdog\n");
31 #define TOPDOWN_SLOTS 0x0400
33 static bool is_topdown_slots_event(struct evsel *counter)
35 if (!counter->pmu_name)
36 return false;
38 if (strcmp(counter->pmu_name, "cpu"))
39 return false;
41 if (counter->core.attr.config == TOPDOWN_SLOTS)
42 return true;
44 return false;
48 * Check whether a topdown group supports sample-read.
50 * Only Topdown metic supports sample-read. The slots
51 * event must be the leader of the topdown group.
54 bool arch_topdown_sample_read(struct evsel *leader)
56 if (!pmu_have_event("cpu", "slots"))
57 return false;
59 if (is_topdown_slots_event(leader))
60 return true;
62 return false;