perf fixes
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
# HEAD: 7977fed974d60a72733243cf54d7955cd6dccd91 Merge tag 'perf-urgent-for-mingo-5.6-20200228' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
No kernel side changes, the rest is tooling fixes plus two tooling cleanups that were committed late in the merge window alongside the perf annotate fixes, delayed by Arnaldo's European trip.
Thanks,
Ingo
------------------>
Adrian Hunter (2):
perf arm-spe: Fix endless record after being terminated perf auxtrace: Add auxtrace_record__read_finish()
Arnaldo Carvalho de Melo (4):
perf bpf: Remove bpf/ subdir from bpf.h headers used to build bpf events perf arch powerpc: Sync powerpc syscall.tbl with the kernel sources tools arch x86: Sync the msr-index.h copy with the kernel sources tools headers UAPI: Update tools's copy of kvm.h headers
He Zhe (1):
perf probe: Check return value of strlist__add() for -ENOMEM
Ravi Bangoria (12):
perf annotate/tui: Re-render title bar after switching back from script browser perf annotate: Fix --show-total-period for tui/stdio2
perf annotate: Fix --show-nr-samples for tui/stdio2
perf config: Introduce perf_config_u8()
perf annotate: Make perf config effective
perf annotate: Prefer cmdline option over default config
perf annotate: Fix perf config option description
perf config: Document missing config options
perf annotate: Remove privsize from symbol__annotate() args
perf annotate: Simplify disasm_line allocation and freeing code perf annotate: Align struct annotate_args
perf annotate: Fix segfault with source toggle
Thomas Richter (1):
perf test: Fix test trace+probe_vfs_getname.sh on s390
Wei Li (3):
perf intel-pt: Fix endless record after being terminated perf intel-bts: Fix endless record after being terminated perf cs-etm: Fix endless record after being terminated
tools/arch/x86/include/asm/msr-index.h | 2 + tools/arch/x86/include/uapi/asm/kvm.h | 1 + tools/perf/Documentation/perf-config.txt | 74 +++++++- tools/perf/arch/arm/util/cs-etm.c | 18 +- tools/perf/arch/arm64/util/arm-spe.c | 17 +- tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 2 + tools/perf/arch/x86/util/intel-bts.c | 17 +- tools/perf/arch/x86/util/intel-pt.c | 17 +- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-probe.c | 6 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 4 +- tools/perf/include/bpf/pid_filter.h | 2 +- tools/perf/include/bpf/stdio.h | 2 +- tools/perf/include/bpf/unistd.h | 2 +- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 2 +- tools/perf/ui/browsers/annotate.c | 19 +- tools/perf/ui/gtk/annotate.c | 2 +- tools/perf/util/annotate.c | 194 ++++++++------------- tools/perf/util/annotate.h | 9 +- tools/perf/util/auxtrace.c | 22 ++- tools/perf/util/auxtrace.h | 6 + tools/perf/util/config.c | 12 ++ tools/perf/util/config.h | 1 + tools/perf/util/probe-file.c | 28 ++- 25 files changed, 251 insertions(+), 214 deletions(-)
tools/arch/x86/include/asm/msr-index.h +2 -0
@@ -512,6 +512,8 @@#define MSR_K7_HWCR 0xc0010015#define MSR_K7_HWCR_SMMLOCK_BIT 0#define MSR_K7_HWCR_SMMLOCK BIT_ULL(MSR_K7_HWCR_SMMLOCK_BIT) +#define MSR_K7_HWCR_IRPERF_EN_BIT 30 +#define MSR_K7_HWCR_IRPERF_EN BIT_ULL(MSR_K7_HWCR_IRPERF_EN_BIT)#define MSR_K7_FID_VID_CTL 0xc0010041#define MSR_K7_FID_VID_STATUS 0xc0010042
tools/arch/x86/include/uapi/asm/kvm.h +1 -0
@@ -390,6 +390,7 @@ struct kvm_sync_regs {#define KVM_STATE_NESTED_GUEST_MODE 0x00000001#define KVM_STATE_NESTED_RUN_PENDING 0x00000002#define KVM_STATE_NESTED_EVMCS 0x00000004 +#define KVM_STATE_NESTED_MTF_PENDING 0x00000008#define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001#define KVM_STATE_NESTED_SMM_VMXON 0x00000002
tools/perf/Documentation/perf-config.txt +73 -1
145 lines not on this page · raw message
tools/perf/arch/arm/util/cs-etm.c +2 -16
@@ -858,21 +858,6 @@ static void cs_etm_recording_free(struct auxtrace_record *itr)free (ptr); } -static int cs_etm_read_finish (struct auxtrace_record *itr,int idx) -{ -struct cs_etm_recording *ptr = - container_of(itr, struct cs_etm_recording, itr); -struct evsel *evsel; - -evlist__for_each_entry (ptr->evlist, evsel) { -if (evsel->core.attr.type == ptr->cs_etm_pmu->type) -return perf_evlist__enable_event_idx (ptr->evlist, - evsel, idx); - } - -return -EINVAL ; -} -struct auxtrace_record *cs_etm_record_init (int *err) {struct perf_pmu *cs_etm_pmu;
@@ -892,6 +877,7 @@ struct auxtrace_record *cs_etm_record_init(int *err) } ptr->cs_etm_pmu = cs_etm_pmu; + ptr->itr.pmu = cs_etm_pmu; ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size;
@@ -901,7 +887,7 @@ struct auxtrace_record *cs_etm_record_init(int *err) ptr->itr.snapshot_finish = cs_etm_snapshot_finish; ptr->itr.reference = cs_etm_reference; ptr->itr.free = cs_etm_recording_free; - ptr->itr.read_finish = cs_etm_read_finish; + ptr->itr.read_finish = auxtrace_record__read_finish; *err =0 ;return &ptr->itr;
tools/perf/arch/arm64/util/arm-spe.c +2 -15
@@ -158,20 +158,6 @@ static void arm_spe_recording_free(struct auxtrace_record *itr)free (sper); } -static int arm_spe_read_finish (struct auxtrace_record *itr,int idx) -{ -struct arm_spe_recording *sper = - container_of(itr, struct arm_spe_recording, itr); -struct evsel *evsel; - -evlist__for_each_entry (sper->evlist, evsel) { -if (evsel->core.attr.type == sper->arm_spe_pmu->type) -return perf_evlist__enable_event_idx (sper->evlist, - evsel, idx); - } -return -EINVAL ; -} -struct auxtrace_record *arm_spe_recording_init (int *err,struct perf_pmu *arm_spe_pmu) {
@@ -189,12 +175,13 @@ struct auxtrace_record *arm_spe_recording_init(int *err, } sper->arm_spe_pmu = arm_spe_pmu; + sper->itr.pmu = arm_spe_pmu; sper->itr.recording_options = arm_spe_recording_options; sper->itr.info_priv_size = arm_spe_info_priv_size; sper->itr.info_fill = arm_spe_info_fill; sper->itr.free = arm_spe_recording_free; sper->itr.reference = arm_spe_reference; - sper->itr.read_finish = arm_spe_read_finish; + sper->itr.read_finish = auxtrace_record__read_finish; sper->itr.alignment =0 ; *err =0 ;
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +2 -0
@@ -517,3 +517,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 nospu clone3 ppc_clone3 +437 common openat2 sys_openat2 +438 common pidfd_getfd sys_pidfd_getfd
tools/perf/arch/x86/util/intel-bts.c +2 -15
@@ -413,20 +413,6 @@ static int intel_bts_find_snapshot(struct auxtrace_record *itr, int idx,return err; } -static int intel_bts_read_finish (struct auxtrace_record *itr,int idx) -{ -struct intel_bts_recording *btsr = - container_of(itr, struct intel_bts_recording, itr); -struct evsel *evsel; - -evlist__for_each_entry (btsr->evlist, evsel) { -if (evsel->core.attr.type == btsr->intel_bts_pmu->type) -return perf_evlist__enable_event_idx (btsr->evlist, - evsel, idx); - } -return -EINVAL ; -} -struct auxtrace_record *intel_bts_recording_init (int *err) {struct perf_pmu *intel_bts_pmu =perf_pmu__find (INTEL_BTS_PMU_NAME );
@@ -447,6 +433,7 @@ struct auxtrace_record *intel_bts_recording_init(int *err) } btsr->intel_bts_pmu = intel_bts_pmu; + btsr->itr.pmu = intel_bts_pmu; btsr->itr.recording_options = intel_bts_recording_options; btsr->itr.info_priv_size = intel_bts_info_priv_size; btsr->itr.info_fill = intel_bts_info_fill;
@@ -456,7 +443,7 @@ struct auxtrace_record *intel_bts_recording_init(int *err) btsr->itr.find_snapshot = intel_bts_find_snapshot; btsr->itr.parse_snapshot_options = intel_bts_parse_snapshot_options; btsr->itr.reference = intel_bts_reference; - btsr->itr.read_finish = intel_bts_read_finish; + btsr->itr.read_finish = auxtrace_record__read_finish; btsr->itr.alignment =sizeof (struct branch );return &btsr->itr; }
tools/perf/arch/x86/util/intel-pt.c +2 -15
@@ -1166,20 +1166,6 @@ static u64 intel_pt_reference(struct auxtrace_record *itr __maybe_unused)return rdtsc (); } -static int intel_pt_read_finish (struct auxtrace_record *itr,int idx) -{ -struct intel_pt_recording *ptr = - container_of(itr, struct intel_pt_recording, itr); -struct evsel *evsel; - -evlist__for_each_entry (ptr->evlist, evsel) { -if (evsel->core.attr.type == ptr->intel_pt_pmu->type) -return perf_evlist__enable_event_idx (ptr->evlist, evsel, - idx); - } -return -EINVAL ; -} -struct auxtrace_record *intel_pt_recording_init (int *err) {struct perf_pmu *intel_pt_pmu =perf_pmu__find (INTEL_PT_PMU_NAME );
@@ -1200,6 +1186,7 @@ struct auxtrace_record *intel_pt_recording_init(int *err) } ptr->intel_pt_pmu = intel_pt_pmu; + ptr->itr.pmu = intel_pt_pmu; ptr->itr.recording_options = intel_pt_recording_options; ptr->itr.info_priv_size = intel_pt_info_priv_size; ptr->itr.info_fill = intel_pt_info_fill;
@@ -1209,7 +1196,7 @@ struct auxtrace_record *intel_pt_recording_init(int *err) ptr->itr.find_snapshot = intel_pt_find_snapshot; ptr->itr.parse_snapshot_options = intel_pt_parse_snapshot_options; ptr->itr.reference = intel_pt_reference; - ptr->itr.read_finish = intel_pt_read_finish; + ptr->itr.read_finish = auxtrace_record__read_finish;/* * Decoding starts at a PSB packet. Minimum PSB period is 2K so 4K * should give at least 1 PSB per sample.
tools/perf/builtin-annotate.c +2 -2
@@ -566,6 +566,8 @@ int cmd_annotate(int argc, const char **argv)if (ret <0 )return ret; +annotation_config__init (&annotate.opts); + argc =parse_options (argc, argv, options, annotate_usage,0 );if (argc) {/*
@@ -605,8 +607,6 @@ int cmd_annotate(int argc, const char **argv)if (ret <0 ) goto out_delete; -annotation_config__init (); - symbol_conf.try_vmlinux_path = true; ret =symbol__init (&annotate.session->header.env);
tools/perf/builtin-probe.c +4 -2
@@ -449,7 +449,8 @@ static int perf_del_probe_events(struct strfilter *filter) ret =probe_file__del_strlist (kfd, klist);if (ret <0 ) goto error; - } + }else if (ret == -ENOMEM ) + goto error; ret2 =probe_file__get_events (ufd, filter, ulist);if (ret2 ==0 ) {
@@ -459,7 +460,8 @@ static int perf_del_probe_events(struct strfilter *filter) ret2 =probe_file__del_strlist (ufd, ulist);if (ret2 <0 ) goto error; - } + }else if (ret2 == -ENOMEM ) + goto error;if (ret == -ENOENT && ret2 == -ENOENT )pr_warning ("\"%s\" does not hit any event.\n" , str);
tools/perf/builtin-report.c +1 -1
@@ -1507,7 +1507,7 @@ int cmd_report(int argc, const char **argv) symbol_conf.priv_size +=sizeof (u32); symbol_conf.sort_by_name = true; } -annotation_config__init (); +annotation_config__init (&report.annotation_opts); }if (symbol__init (&session->header.env) <0 )
tools/perf/builtin-top.c +2 -2
@@ -143,7 +143,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)return err; } - err =symbol__annotate (&he->ms, evsel,0 , &top->annotation_opts,NULL ); + err =symbol__annotate (&he->ms, evsel, &top->annotation_opts,NULL );if (err ==0 ) { top->sym_filter_entry = he; }else {
@@ -1683,7 +1683,7 @@ int cmd_top(int argc, const char **argv)if (status <0 ) goto out_delete_evlist; -annotation_config__init (); +annotation_config__init (&top.annotation_opts); symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name ==NULL ); status =symbol__init (NULL );
tools/perf/include/bpf/pid_filter.h +1 -1
@@ -3,7 +3,7 @@#ifndef _PERF_BPF_PID_FILTER_#define _PERF_BPF_PID_FILTER_ -#include <bpf/bpf.h> +#include <bpf.h> #define pid_filter (name) pid_map(name, bool)
tools/perf/include/bpf/stdio.h +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 -#include <bpf/bpf.h> +#include <bpf.h> struct bpf_map SEC("maps") __bpf_stdout__ = { .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
tools/perf/include/bpf/unistd.h +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: LGPL-2.1 -#include <bpf/bpf.h> +#include <bpf.h> static int (*bpf_get_current_pid_tgid)(void ) = (void *)BPF_FUNC_get_current_pid_tgid;
tools/perf/tests/shell/lib/probe_vfs_getname.sh +1 -1
@@ -14,7 +14,7 @@ add_probe_vfs_getname() { if [ $had_vfs_getname -eq 1 ] ; then line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \ - perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string" + perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring" fi }
tools/perf/ui/browsers/annotate.c +9 -10
@@ -754,10 +754,9 @@ static int annotate_browser__run(struct annotate_browser *browser, "? Search string backwards\n");continue ;case 'r' : - { -script_browse (NULL ,NULL ); -continue ; - } +script_browse (NULL ,NULL ); +annotate_browser__show (&browser->b, title, help); +continue ;case 'k' : notes->options->show_linenr = !notes->options->show_linenr;break ;
@@ -834,13 +833,13 @@ static int annotate_browser__run(struct annotate_browser *browser,map_symbol__annotation_dump (ms, evsel, browser->opts);continue ;case 't' : -if (notes->options->show_total_period) { - notes->options->show_total_period = false; - notes->options->show_nr_samples = true; - }else if (notes->options->show_nr_samples) - notes->options->show_nr_samples = false; +if (symbol_conf.show_total_period) { + symbol_conf.show_total_period = false; + symbol_conf.show_nr_samples = true; + }else if (symbol_conf.show_nr_samples) + symbol_conf.show_nr_samples = false;else - notes->options->show_total_period = true; + symbol_conf.show_total_period = true;annotation__update_column_widths (notes);continue ;case 'c' :
tools/perf/ui/gtk/annotate.c +1 -1
@@ -174,7 +174,7 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,if (ms->map->dso->annotate_warned)return -1 ; - err =symbol__annotate (ms, evsel,0 , &annotation__default_options,NULL ); + err =symbol__annotate (ms, evsel, &annotation__default_options,NULL );if (err) {char msg[BUFSIZ ];symbol__strerror_disassemble (ms, err, msg,sizeof (msg));
tools/perf/util/annotate.c +75 -119
294 lines not on this page · raw message
tools/perf/util/annotate.h +3 -6
@@ -83,8 +83,6 @@ struct annotation_options { full_path, show_linenr, show_nr_jumps, - show_nr_samples, - show_total_period, show_minmax_cycle, show_asm_raw, annotate_src;
@@ -141,7 +139,6 @@ struct annotation_line {u64 cycles;u64 cycles_max;u64 cycles_min; -size_t privsize;char *path;u32 idx;int idx_asm;
@@ -309,7 +306,7 @@ static inline int annotation__cycles_width(struct annotation *notes)static inline int annotation__pcnt_width (struct annotation *notes) { -return (notes->options->show_total_period ?12 :7 ) * notes->nr_events; +return (symbol_conf.show_total_period ?12 :7 ) * notes->nr_events; }static inline bool annotation_line__filter (struct annotation_line *al,struct annotation *notes)
@@ -352,7 +349,7 @@ struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists);void symbol__annotate_zero_histograms (struct symbol *sym);int symbol__annotate (struct map_symbol *ms, -struct evsel *evsel,size_t privsize, +struct evsel *evsel,struct annotation_options *options,struct arch **parch); int symbol__annotate2(struct map_symbol *ms,
@@ -413,7 +410,7 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused, }#endif -void annotation_config__init (void ); +void annotation_config__init (struct annotation_options *opt);int annotate_parse_percent_type (const struct option *opt,const char *_str,int unset);
tools/perf/util/auxtrace.c +21 -1
@@ -629,8 +629,10 @@ int auxtrace_record__options(struct auxtrace_record *itr,struct evlist *evlist, struct record_opts *opts) { - if (itr) + if (itr) { + itr->evlist = evlist;return itr->recording_options (itr, evlist, opts); + }return 0 ; }
@@ -664,6 +666,24 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,return -EINVAL ; } +int auxtrace_record__read_finish (struct auxtrace_record *itr,int idx) +{ +struct evsel *evsel; + +if (!itr->evlist || !itr->pmu) +return -EINVAL ; + +evlist__for_each_entry (itr->evlist, evsel) { +if (evsel->core.attr.type == itr->pmu->type) { +if (evsel->disabled) +return 0 ; +return perf_evlist__enable_event_idx (itr->evlist, evsel, + idx); + } + } +return -EINVAL ; +} +/* * Event record size is 16-bit which results in a maximum size of about 64KiB. * Allow about 4KiB for the rest of the sample record, to give a maximum
tools/perf/util/auxtrace.h +6 -0
@@ -29,6 +29,7 @@ struct record_opts;struct perf_record_auxtrace_error ;struct perf_record_auxtrace_info ;struct events_stats ; +struct perf_pmu ;enum auxtrace_error_type {PERF_AUXTRACE_ERROR_ITRACE =1 ,
@@ -322,6 +323,8 @@ struct auxtrace_mmap_params {* @read_finish: called after reading from an auxtrace mmap * @alignment: alignment (if any) for AUX area data * @default_aux_sample_size: default sample size for --aux sample option +* @pmu: associated pmu +* @evlist: selected events list */ struct auxtrace_record { int (*recording_options)(struct auxtrace_record *itr,
@@ -346,6 +349,8 @@ struct auxtrace_record {int (*read_finish)(struct auxtrace_record *itr,int idx);unsigned int alignment;unsigned int default_aux_sample_size; +struct perf_pmu *pmu; +struct evlist *evlist; };/**
@@ -537,6 +542,7 @@ int auxtrace_record__find_snapshot(struct auxtrace_record *itr, int idx,struct auxtrace_mmap *mm, unsigned char *data, u64 *head, u64 *old);u64 auxtrace_record__reference (struct auxtrace_record *itr); +int auxtrace_record__read_finish (struct auxtrace_record *itr,int idx);int auxtrace_index__auxtrace_event (struct list_head *head,union perf_event *event,off_t file_offset);
tools/perf/util/config.c +12 -0
@@ -374,6 +374,18 @@ int perf_config_int(int *dest, const char *name, const char *value)return 0 ; } +int perf_config_u8 (u8 *dest,const char *name,const char *value) +{ +long ret =0 ; + +if (!perf_parse_long (value, &ret)) { +bad_config (name); +return -1 ; + } + *dest = ret; +return 0 ; +} +static int perf_config_bool_or_int (const char *name,const char *value,int *is_bool) {int ret;
tools/perf/util/config.h +1 -0
@@ -29,6 +29,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);int perf_default_config (const char *,const char *,void *);int perf_config (config_fn_t fn,void *);int perf_config_int (int *dest,const char *,const char *); +int perf_config_u8 (u8 *dest,const char *name,const char *value);int perf_config_u64 (u64 *dest,const char *,const char *);int perf_config_bool (const char *,const char *);int config_error_nonbool (const char *);
tools/perf/util/probe-file.c +24 -4
@@ -301,10 +301,15 @@ int probe_file__get_events(int fd, struct strfilter *filter, p =strchr (ent->s,':' );if ((p &&strfilter__compare (filter, p +1 )) ||strfilter__compare (filter, ent->s)) { -strlist__add (plist, ent->s); + ret =strlist__add (plist, ent->s); +if (ret == -ENOMEM ) { +pr_err ("strlist__add failed with -ENOMEM\n" ); + goto out; + } ret =0 ; } } +out:strlist__delete (namelist);return ret;
@@ -511,7 +516,11 @@ static int probe_cache__load(struct probe_cache *pcache) ret = -EINVAL ; goto out; } -strlist__add (entry->tevlist, buf); + ret =strlist__add (entry->tevlist, buf); +if (ret == -ENOMEM ) { +pr_err ("strlist__add failed with -ENOMEM\n" ); + goto out; + } } } out:
@@ -672,7 +681,12 @@ int probe_cache__add_entry(struct probe_cache *pcache, command =synthesize_probe_trace_command (&tevs[i]);if (!command) goto out_err; -strlist__add (entry->tevlist, command); + ret =strlist__add (entry->tevlist, command); +if (ret == -ENOMEM ) { +pr_err ("strlist__add failed with -ENOMEM\n" ); + goto out_err; + } +free (command); }list_add_tail (&entry->node, &pcache->entries);
@@ -853,9 +867,15 @@ int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)break ; } -strlist__add (entry->tevlist, buf); + ret =strlist__add (entry->tevlist, buf); +free (buf); entry =NULL ; + +if (ret == -ENOMEM ) { +pr_err ("strlist__add failed with -ENOMEM\n" ); +break ; + } }if (entry) {list_del_init (&entry->node);
The pull request you sent on Mon, 2 Mar 2020 08:23:14 +0100:
The pull request you sent on Mon, 2 Mar 2020 08:23:14 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitperf-urgent-for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/852fb4a72822b6c03bcf6cf1d51fb05b319d301e
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker