diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-11-26 15:04:47 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-11-26 15:04:47 -0800 |
commit | 3f59dbcace56fae7e4ed303bab90f1bedadcfdf4 (patch) | |
tree | c425529202b9dbe3e3b3dde072c1edf51b1b9e93 /tools/perf/util/data.c | |
parent | df28204bb0f29cc475c0a8893c99b46a11a4903f (diff) | |
parent | ceb9e77324fa661b1001a0ae66f061b5fcb4e4e6 (diff) | |
download | lwn-3f59dbcace56fae7e4ed303bab90f1bedadcfdf4.tar.gz lwn-3f59dbcace56fae7e4ed303bab90f1bedadcfdf4.zip |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar:
"The main kernel side changes in this cycle were:
- Various Intel-PT updates and optimizations (Alexander Shishkin)
- Prohibit kprobes on Xen/KVM emulate prefixes (Masami Hiramatsu)
- Add support for LSM and SELinux checks to control access to the
perf syscall (Joel Fernandes)
- Misc other changes, optimizations, fixes and cleanups - see the
shortlog for details.
There were numerous tooling changes as well - 254 non-merge commits.
Here are the main changes - too many to list in detail:
- Enhancements to core tooling infrastructure, perf.data, libperf,
libtraceevent, event parsing, vendor events, Intel PT, callchains,
BPF support and instruction decoding.
- There were updates to the following tools:
perf annotate
perf diff
perf inject
perf kvm
perf list
perf maps
perf parse
perf probe
perf record
perf report
perf script
perf stat
perf test
perf trace
- And a lot of other changes: please see the shortlog and Git log for
more details"
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (279 commits)
perf parse: Fix potential memory leak when handling tracepoint errors
perf probe: Fix spelling mistake "addrees" -> "address"
libtraceevent: Fix memory leakage in copy_filter_type
libtraceevent: Fix header installation
perf intel-bts: Does not support AUX area sampling
perf intel-pt: Add support for decoding AUX area samples
perf intel-pt: Add support for recording AUX area samples
perf pmu: When using default config, record which bits of config were changed by the user
perf auxtrace: Add support for queuing AUX area samples
perf session: Add facility to peek at all events
perf auxtrace: Add support for dumping AUX area samples
perf inject: Cut AUX area samples
perf record: Add aux-sample-size config term
perf record: Add support for AUX area sampling
perf auxtrace: Add support for AUX area sample recording
perf auxtrace: Move perf_evsel__find_pmu()
perf record: Add a function to test for kernel support for AUX area sampling
perf tools: Add kernel AUX area sampling definitions
perf/core: Make the mlock accounting simple again
perf report: Jump to symbol source view from total cycles view
...
Diffstat (limited to 'tools/perf/util/data.c')
-rw-r--r-- | tools/perf/util/data.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 88fba2ba549f..c47aa34fdc0a 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -76,6 +76,13 @@ int perf_data__open_dir(struct perf_data *data) DIR *dir; int nr = 0; + /* + * Directory containing a single regular perf data file which is already + * open, means there is nothing more to do here. + */ + if (perf_data__is_single_file(data)) + return 0; + if (WARN_ON(!data->is_dir)) return -EINVAL; @@ -96,7 +103,7 @@ int perf_data__open_dir(struct perf_data *data) if (stat(path, &st)) continue; - if (!S_ISREG(st.st_mode) || strncmp(dent->d_name, "data", 4)) + if (!S_ISREG(st.st_mode) || strncmp(dent->d_name, "data.", 5)) continue; ret = -ENOMEM; @@ -306,7 +313,7 @@ static int open_dir(struct perf_data *data) * So far we open only the header, so we can read the data version and * layout. */ - if (asprintf(&data->file.path, "%s/header", data->path) < 0) + if (asprintf(&data->file.path, "%s/data", data->path) < 0) return -1; if (perf_data__is_write(data) && @@ -406,7 +413,7 @@ unsigned long perf_data__size(struct perf_data *data) u64 size = data->file.size; int i; - if (!data->is_dir) + if (perf_data__is_single_file(data)) return size; for (i = 0; i < data->dir.nr; i++) { @@ -417,3 +424,36 @@ unsigned long perf_data__size(struct perf_data *data) return size; } + +int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz) +{ + int ret; + + if (!data->is_dir) + return -1; + + ret = snprintf(buf, buf_sz, "%s/kcore_dir", data->path); + if (ret < 0 || (size_t)ret >= buf_sz) + return -1; + + return mkdir(buf, S_IRWXU); +} + +char *perf_data__kallsyms_name(struct perf_data *data) +{ + char *kallsyms_name; + struct stat st; + + if (!data->is_dir) + return NULL; + + if (asprintf(&kallsyms_name, "%s/kcore_dir/kallsyms", data->path) < 0) + return NULL; + + if (stat(kallsyms_name, &st)) { + free(kallsyms_name); + return NULL; + } + + return kallsyms_name; +} |