forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'perf-tools-for-v6.1-2-2022-10-16' of git://git.kernel.org/…
…pub/scm/linux/kernel/git/acme/linux Pull more perf tools updates from Arnaldo Carvalho de Melo: - Use BPF CO-RE (Compile Once, Run Everywhere) to support old kernels when using bperf (perf BPF based counters) with cgroups. - Support HiSilicon PCIe Performance Monitoring Unit (PMU), that monitors bandwidth, latency, bus utilization and buffer occupancy. Documented in Documentation/admin-guide/perf/hisi-pcie-pmu.rst. - User space tasks can migrate between CPUs, so when tracing selected CPUs, system-wide sideband is still needed, fix it in the setup of Intel PT on hybrid systems. - Fix metricgroups title message in 'perf list', it should state that the metrics groups are to be used with the '-M' option, not '-e'. - Sync the msr-index.h copy with the kernel sources, adding support for using "AMD64_TSC_RATIO" in filter expressions in 'perf trace' as well as decoding it when printing the MSR tracepoint arguments. - Fix program header size and alignment when generating a JIT ELF in 'perf inject'. - Add multiple new Intel PT 'perf test' entries, including a jitdump one. - Fix the 'perf test' entries for 'perf stat' CSV and JSON output when running on PowerPC due to an invalid topology number in that arch. - Fix the 'perf test' for arm_coresight failures on the ARM Juno system. - Fix the 'perf test' attr entry for PERF_FORMAT_LOST, adding this option to the or expression expected in the intercepted perf_event_open() syscall. - Add missing condition flags ('hs', 'lo', 'vc', 'vs') for arm64 in the 'perf annotate' asm parser. - Fix 'perf mem record -C' option processing, it was being chopped up when preparing the underlying 'perf record -e mem-events' and thus being ignored, requiring using '-- -C CPUs' as a workaround. - Improvements and tidy ups for 'perf test' shell infra. - Fix Intel PT information printing segfault in uClibc, where a NULL format was being passed to fprintf. * tag 'perf-tools-for-v6.1-2-2022-10-16' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (23 commits) tools arch x86: Sync the msr-index.h copy with the kernel sources perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet perf auxtrace arm64: Add support for HiSilicon PCIe Tune and Trace device driver perf auxtrace arm: Refactor event list iteration in auxtrace_record__init() perf tests stat+json_output: Include sanity check for topology perf tests stat+csv_output: Include sanity check for topology perf intel-pt: Fix system_wide dummy event for hybrid perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc perf test: Fix attr tests for PERF_FORMAT_LOST perf test: test_intel_pt.sh: Add 9 tests perf inject: Fix GEN_ELF_TEXT_OFFSET for jit perf test: test_intel_pt.sh: Add jitdump test perf test: test_intel_pt.sh: Tidy some alignment perf test: test_intel_pt.sh: Print a message when skipping kernel tracing perf test: test_intel_pt.sh: Tidy some perf record options perf test: test_intel_pt.sh: Fix return checking again perf: Skip and warn on unknown format 'configN' attrs perf list: Fix metricgroups title message perf mem: Fix -C option behavior for perf mem record perf annotate: Add missing condition flags for arm64 ...
- Loading branch information
Showing
36 changed files
with
1,265 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,19 @@ | |
* Author: Mathieu Poirier <[email protected]> | ||
*/ | ||
|
||
#include <dirent.h> | ||
#include <stdbool.h> | ||
#include <linux/coresight-pmu.h> | ||
#include <linux/zalloc.h> | ||
#include <api/fs/fs.h> | ||
|
||
#include "../../../util/auxtrace.h" | ||
#include "../../../util/debug.h" | ||
#include "../../../util/evlist.h" | ||
#include "../../../util/pmu.h" | ||
#include "cs-etm.h" | ||
#include "arm-spe.h" | ||
#include "hisi-ptt.h" | ||
|
||
static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err) | ||
{ | ||
|
@@ -50,42 +53,114 @@ static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err) | |
return arm_spe_pmus; | ||
} | ||
|
||
static struct perf_pmu **find_all_hisi_ptt_pmus(int *nr_ptts, int *err) | ||
{ | ||
const char *sysfs = sysfs__mountpoint(); | ||
struct perf_pmu **hisi_ptt_pmus = NULL; | ||
struct dirent *dent; | ||
char path[PATH_MAX]; | ||
DIR *dir = NULL; | ||
int idx = 0; | ||
|
||
snprintf(path, PATH_MAX, "%s" EVENT_SOURCE_DEVICE_PATH, sysfs); | ||
dir = opendir(path); | ||
if (!dir) { | ||
pr_err("can't read directory '%s'\n", EVENT_SOURCE_DEVICE_PATH); | ||
*err = -EINVAL; | ||
return NULL; | ||
} | ||
|
||
while ((dent = readdir(dir))) { | ||
if (strstr(dent->d_name, HISI_PTT_PMU_NAME)) | ||
(*nr_ptts)++; | ||
} | ||
|
||
if (!(*nr_ptts)) | ||
goto out; | ||
|
||
hisi_ptt_pmus = zalloc(sizeof(struct perf_pmu *) * (*nr_ptts)); | ||
if (!hisi_ptt_pmus) { | ||
pr_err("hisi_ptt alloc failed\n"); | ||
*err = -ENOMEM; | ||
goto out; | ||
} | ||
|
||
rewinddir(dir); | ||
while ((dent = readdir(dir))) { | ||
if (strstr(dent->d_name, HISI_PTT_PMU_NAME) && idx < *nr_ptts) { | ||
hisi_ptt_pmus[idx] = perf_pmu__find(dent->d_name); | ||
if (hisi_ptt_pmus[idx]) | ||
idx++; | ||
} | ||
} | ||
|
||
out: | ||
closedir(dir); | ||
return hisi_ptt_pmus; | ||
} | ||
|
||
static struct perf_pmu *find_pmu_for_event(struct perf_pmu **pmus, | ||
int pmu_nr, struct evsel *evsel) | ||
{ | ||
int i; | ||
|
||
if (!pmus) | ||
return NULL; | ||
|
||
for (i = 0; i < pmu_nr; i++) { | ||
if (evsel->core.attr.type == pmus[i]->type) | ||
return pmus[i]; | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
struct auxtrace_record | ||
*auxtrace_record__init(struct evlist *evlist, int *err) | ||
{ | ||
struct perf_pmu *cs_etm_pmu; | ||
struct perf_pmu *cs_etm_pmu = NULL; | ||
struct perf_pmu **arm_spe_pmus = NULL; | ||
struct perf_pmu **hisi_ptt_pmus = NULL; | ||
struct evsel *evsel; | ||
bool found_etm = false; | ||
struct perf_pmu *found_etm = NULL; | ||
struct perf_pmu *found_spe = NULL; | ||
struct perf_pmu **arm_spe_pmus = NULL; | ||
struct perf_pmu *found_ptt = NULL; | ||
int auxtrace_event_cnt = 0; | ||
int nr_spes = 0; | ||
int i = 0; | ||
int nr_ptts = 0; | ||
|
||
if (!evlist) | ||
return NULL; | ||
|
||
cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME); | ||
arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err); | ||
hisi_ptt_pmus = find_all_hisi_ptt_pmus(&nr_ptts, err); | ||
|
||
evlist__for_each_entry(evlist, evsel) { | ||
if (cs_etm_pmu && | ||
evsel->core.attr.type == cs_etm_pmu->type) | ||
found_etm = true; | ||
|
||
if (!nr_spes || found_spe) | ||
continue; | ||
|
||
for (i = 0; i < nr_spes; i++) { | ||
if (evsel->core.attr.type == arm_spe_pmus[i]->type) { | ||
found_spe = arm_spe_pmus[i]; | ||
break; | ||
} | ||
} | ||
if (cs_etm_pmu && !found_etm) | ||
found_etm = find_pmu_for_event(&cs_etm_pmu, 1, evsel); | ||
|
||
if (arm_spe_pmus && !found_spe) | ||
found_spe = find_pmu_for_event(arm_spe_pmus, nr_spes, evsel); | ||
|
||
if (hisi_ptt_pmus && !found_ptt) | ||
found_ptt = find_pmu_for_event(hisi_ptt_pmus, nr_ptts, evsel); | ||
} | ||
|
||
free(arm_spe_pmus); | ||
free(hisi_ptt_pmus); | ||
|
||
if (found_etm) | ||
auxtrace_event_cnt++; | ||
|
||
if (found_etm && found_spe) { | ||
pr_err("Concurrent ARM Coresight ETM and SPE operation not currently supported\n"); | ||
if (found_spe) | ||
auxtrace_event_cnt++; | ||
|
||
if (found_ptt) | ||
auxtrace_event_cnt++; | ||
|
||
if (auxtrace_event_cnt > 1) { | ||
pr_err("Concurrent AUX trace operation not currently supported\n"); | ||
*err = -EOPNOTSUPP; | ||
return NULL; | ||
} | ||
|
@@ -96,6 +171,9 @@ struct auxtrace_record | |
#if defined(__aarch64__) | ||
if (found_spe) | ||
return arm_spe_recording_init(err, found_spe); | ||
|
||
if (found_ptt) | ||
return hisi_ptt_recording_init(err, found_ptt); | ||
#endif | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.