perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling, more to come,
- Arnaldo
The following changes since commit 107eb964d8c04417e8bce9e9ec2ed61d9261aec6:
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-03-13 13:30:10 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
for you to fetch changes up to 0c8c20779c5d56b93b8cb4cd30ba129a927ab437:
perf report: Don't allow empty argument for '-t'. (2015-03-19 13:53:28 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Bash completion for subcommands (Yunlong Song)
- Allow annotating entries in callchains in the hists browser (top/report).
TODO: give some visual cue to what entries in callchains have samples and thus can be annotated and/or allow showing the source code for functions without samples (Arnaldo Carvalho de Melo)
- Don't allow empty argument for '-t' in perf report, fixing segfault (Wang Nan)
Infrastructure:
- Prep work for moving the perf feature tests build system to tools/build (Jiri Olsa)
- Fix perf-read-vdsox32 not building and lib64 install dir (H.J. Lu)
- ARM64: fix building error and eh/debug frame offset cache fixes (Wang Nan)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
perf hists browser: Simplify symbol annotation menu setup perf hists browser: Fix up some branch alignment perf hists: Remove hist_entry->used, not used anymore perf hists browser: Allow annotating entries in callchains
H.J. Lu (1):
perf tools: Fix perf-read-vdsox32 not building and lib64 install dir
Jiri Olsa (10):
perf build: Disable default check for libbabeltrace perf build: Move features build output under features directory perf build: Fix pthread-attr-setaffinity-np include in test-all perf build: Get rid of LIB_INCLUDE variable
perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS perf build: Get rid of VF_FEATURE_TESTS
perf build: Rename display_lib into feature_display perf build: Rename display_vf to feature_verbose perf build: Rename PERF-FEATURES into FEATURE-DUMP perf build: Rename feature_print_var_code to print_var_code
Wang Nan (3):
perf tools: Fix building error for arm64. perf callchain: Separate eh/debug frame offset cache. perf report: Don't allow empty argument for '-t'.
Yunlong Song (13):
perf tools: Fix the bash completion for listing options of perf subcommand
perf tools: Fix the bash completion for listing subsubcommands of perf subcommand perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand perf tools: Fix the bash completion for listing events of perf subcommand record|stat|top -e perf tools: Fix the bash completion to support listing events for --event
perf tools: Fix the bash completion for listing subcommands of perf
perf tools: Add the bash completion for listing subsubcommands of perf data
perf tools: Add the bash completion for listing subsubcommands of perf help
perf tools: Add the bash completion for listing subsubcommands of perf script perf tools: Add the bash completion for listing subsubcommands of perf test
perf tools: Add the bash completion for listing subsubcommands of perf timechart perf tools: Add the bash completion for listing subsubcommands of perf trace
perf tools: Avoid confusion with preloaded bash function for perf bash completion
tools/perf/Makefile.perf | 3 +- tools/perf/builtin-data.c | 6 +- tools/perf/builtin-help.c | 17 ++++- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-script.c | 5 +- tools/perf/builtin-timechart.c | 7 +- tools/perf/builtin-trace.c | 7 +- tools/perf/config/Makefile | 111 ++++++++++++---------------- tools/perf/config/Makefile.arch | 2 +- tools/perf/config/feature-checks/Makefile | 7 +- tools/perf/config/feature-checks/test-all.c | 11 ++- tools/perf/perf-completion.sh | 88 +++++++++++++++++----- tools/perf/tests/builtin-test.c | 5 +- tools/perf/tests/make | 2 +- tools/perf/ui/browsers/annotate.c | 8 +- tools/perf/ui/browsers/hists.c | 59 +++++++-------- tools/perf/util/dso.h | 3 +- tools/perf/util/hist.c | 8 +- tools/perf/util/hist.h | 9 +++ tools/perf/util/parse-options.c | 21 +++++- tools/perf/util/parse-options.h | 2 + tools/perf/util/sort.h | 1 - tools/perf/util/unwind-libunwind.c | 8 +- 23 files changed, 237 insertions(+), 155 deletions(-)
Arnaldo Carvalho de Melo
maintainerPATCH 1/31 perf hists browser: Simplify symbol annotation menu setup
From: Arnaldo Carvalho de Melo <[email protected]>
No need to repeat some tests, skip annotation instead.
--- tools/perf/ui/browsers/hists.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
tools/perf/ui/browsers/hists.c +11 -9
@@ -1612,19 +1612,22 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,if (!sort__has_sym) goto add_exit_option; +if (browser->selection ==NULL ) + goto skip_annotation; +if (sort__mode ==SORT_MODE__BRANCH ) { bi = browser->he_selection->branch_info; -if (browser->selection !=NULL && - bi && - bi->from.sym !=NULL && + +if (bi ==NULL ) + goto skip_annotation; + +if (bi->from.sym !=NULL && !bi->from.map->dso->annotate_warned &&asprintf (&options[nr_options],"Annotate %s" , bi->from.sym->name) >0 ) annotate_f = nr_options++; - if (browser->selection != NULL && - bi && - bi->to.sym != NULL && + if (bi->to.sym != NULL && !bi->to.map->dso->annotate_warned && (bi->to.sym != bi->from.sym || bi->to.map->dso != bi->from.map->dso) &&
@@ -1632,8 +1635,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, bi->to.sym->name) > 0) annotate_t = nr_options++; }else { -if (browser->selection !=NULL && - browser->selection->sym !=NULL && +if (browser->selection->sym !=NULL && !browser->selection->map->dso->annotate_warned) {struct annotation *notes;
@@ -1645,7 +1647,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, annotate = nr_options++; } } - +skip_annotation:if (thread !=NULL && asprintf(&options[nr_options], "Zoom %s %s(%d) thread", (browser->hists->thread_filter ? "out of" : "into"),
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 2/31 perf hists browser: Fix up some branch alignment
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Those asprintf return checks should be aligned with the other conditionals, fix it.
Also add {} blocks to further clarify.
Cc: Adrian Hunter <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Stephane Eranian <[email protected]>
echo Link: http://lkml.kernel.org/n/tip-ranpwd -l 24@git.kernel.org
--- tools/perf/ui/browsers/hists.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tools/perf/ui/browsers/hists.c +6 -5
@@ -1623,17 +1623,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,if (bi->from.sym !=NULL && !bi->from.map->dso->annotate_warned && -asprintf (&options[nr_options],"Annotate %s" , - bi->from.sym->name) >0 ) +asprintf (&options[nr_options],"Annotate %s" , bi->from.sym->name) >0 ) { annotate_f = nr_options++; + }if (bi->to.sym !=NULL && !bi->to.map->dso->annotate_warned && (bi->to.sym != bi->from.sym || bi->to.map->dso != bi->from.map->dso) && -asprintf (&options[nr_options],"Annotate %s" , - bi->to.sym->name) >0 ) +asprintf (&options[nr_options],"Annotate %s" , bi->to.sym->name) >0 ) { annotate_t = nr_options++; + } }else {if (browser->selection->sym !=NULL && !browser->selection->map->dso->annotate_warned) {
@@ -1643,8 +1643,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,if (notes->src &&asprintf (&options[nr_options],"Annotate %s" , - browser->selection->sym->name) >0 ) + browser->selection->sym->name) >0 ) { annotate = nr_options++; + } } } skip_annotation:
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 3/31 perf hists: Remove hist_entry->used, not used anymore
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Since hist_entry__delete() nowadays doesn't actually frees anything that may be in use by the annotation code.
Eventually we will solve this for good by reference counting struct symbol.
--- tools/perf/ui/browsers/hists.c | 5 ----- tools/perf/util/hist.c | 8 +------- tools/perf/util/sort.h | 1 - 3 files changed, 1 insertion(+), 13 deletions(-)
tools/perf/ui/browsers/hists.c +0 -5
@@ -1731,12 +1731,7 @@ do_annotate:if (!notes->src)continue ; -/* -* Don't let this be freed, say, by hists__decay_entry. -*/ - he->used = true; err =hist_entry__tui_annotate (he, evsel, hbt); - he->used = false;/* * offer option to annotate the other branch source or target * (if they exists) when returning from annotate
tools/perf/util/hist.c +1 -7
@@ -263,15 +263,9 @@ void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)while (next) { n = rb_entry(next, struct hist_entry, rb_node); next =rb_next (&n->rb_node); -/* -* We may be annotating this, for instance, so keep it here in -* case some it gets new samples, we'll eventually free it when -* the user stops browsing and it agains gets fully decayed. -*/ if (((zap_user && n->level =='.' ) || (zap_kernel && n->level !='.' ) || -hists__decay_entry (hists, n)) && - !n->used) { +hists__decay_entry (hists, n))) {hists__delete_entry (hists, n); } }
tools/perf/util/sort.h +0 -1
@@ -102,7 +102,6 @@ struct hist_entry {bool init_have_children;char level; -bool used;u8 filtered;char *srcline;struct symbol *parent;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 4/31 perf hists browser: Allow annotating entries in callchains
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Instead of annotating just the top level hist_entry, allow instead annotating a map_symbol, i.e. the top level hist_entry or one of the callchains for which there were samples.
--- tools/perf/ui/browsers/annotate.c | 8 +++++++- tools/perf/ui/browsers/hists.c | 23 ++++++++++------------- tools/perf/util/hist.h | 9 +++++++++ 3 files changed, 26 insertions(+), 14 deletions(-)
tools/perf/ui/browsers/annotate.c +7 -1
@@ -829,10 +829,16 @@ out:return key; } +int map_symbol__tui_annotate (struct map_symbol *ms,struct perf_evsel *evsel, +struct hist_browser_timer *hbt) +{ +return symbol__tui_annotate (ms->sym, ms->map, evsel, hbt); +} +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt) { -return symbol__tui_annotate (he->ms.sym, he->ms.map, evsel, hbt); +return map_symbol__tui_annotate (&he->ms, evsel, hbt); } static void annotate_browser__mark_jump_targets(struct annotate_browser *browser,
tools/perf/ui/browsers/hists.c +10 -13
@@ -1704,6 +1704,7 @@ retry_popup_menu:if (choice == annotate || choice == annotate_t || choice == annotate_f) {struct hist_entry *he;struct annotation *notes; +struct map_symbol ms;int err; do_annotate:if (!objdump_path &&perf_session_env__lookup_objdump (env))
@@ -1713,25 +1714,21 @@ do_annotate:if (he ==NULL )continue ; -/* -* we stash the branch_info symbol + map into the -* the ms so we don't have to rewrite all the annotation -* code to use branch_info. -* in branch mode, the ms struct is not used -*/ if (choice == annotate_f) { - he->ms.sym = he->branch_info->from.sym; - he->ms.map = he->branch_info->from.map; - }else if (choice == annotate_t) { - he->ms.sym = he->branch_info->to.sym; - he->ms.map = he->branch_info->to.map; + ms.map = he->branch_info->from.map; + ms.sym = he->branch_info->from.sym; + }else if (choice == annotate_t) { + ms.map = he->branch_info->to.map; + ms.sym = he->branch_info->to.sym; + }else { + ms = *browser->selection; } - notes =symbol__annotation (he->ms.sym); + notes =symbol__annotation (ms.sym);if (!notes->src)continue ; - err =hist_entry__tui_annotate (he, evsel, hbt); + err =map_symbol__tui_annotate (&ms, evsel, hbt);/* * offer option to annotate the other branch source or target * (if they exists) when returning from annotate
tools/perf/util/hist.h +9 -0
@@ -303,6 +303,9 @@ struct hist_browser_timer {#ifdef HAVE_SLANG_SUPPORT #include "../ui/keysyms.h" +int map_symbol__tui_annotate (struct map_symbol *ms,struct perf_evsel *evsel, +struct hist_browser_timer *hbt); +int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt);
@@ -321,6 +324,12 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, {return 0 ; } +static inline int map_symbol__tui_annotate (struct map_symbol *ms__maybe_unused , +struct perf_evsel *evsel__maybe_unused , +struct hist_browser_timer *hbt__maybe_unused ) +{ +return 0 ; +} static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused, struct perf_evsel *evsel __maybe_unused,
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 5/31 perf tools: Fix building error for arm64.
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Commit b11db6581beaccef8ae9a388ae96074aa5cc144f ("perf tools: Fix build error on ARCH=i386/x86_64/sparc64") uses sed on ARCH, which triggers a bug in sequence of sed expression, where 's/arm.*/arm/' will replace 'arm64' to 'arm', causes arm64 building failure.
This patch prevent 'arm64' to be mached for 'arm.*' case.
--- tools/perf/config/Makefile.arch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/Makefile.arch +1 -1
@@ -4,7 +4,7 @@ endif ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ -e s/sun4u/sparc/ -e s/sparc64/sparc/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 6/31 perf build: Disable default check for libbabeltrace
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Remove libbabeltrace check from default features set, because the requested version is not released yet in most distributions. We'll enable later.
Calling libbabeltrace check manually via feature_check before $(feature-libbabeltrace) is used.
--- tools/perf/config/Makefile | 11 +++++------ tools/perf/config/feature-checks/Makefile | 2 +- tools/perf/config/feature-checks/test-all.c | 9 ++++++++- 3 files changed, 14 insertions(+), 8 deletions(-)
tools/perf/config/Makefile +5 -6
@@ -227,7 +227,6 @@ CORE_FEATURE_TESTS = \ stackprotector-all \ timerfd \ libdw-dwarf-unwind \ - libbabeltrace \ zlib LIB_FEATURE_TESTS = \
@@ -243,7 +242,6 @@ LIB_FEATURE_TESTS = \ libslang \ libunwind \ libdw-dwarf-unwind \ - libbabeltrace \ zlib VF_FEATURE_TESTS = \
@@ -705,14 +703,15 @@ else endif ifndef NO_LIBBABELTRACE - ifeq ($(feature-libbabeltrace), 0) - msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); - NO_LIBBABELTRACE := 1 - else + $(call feature_check,libbabeltrace) + ifeq ($(feature-libbabeltrace), 1) CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS) LDFLAGS += $(LIBBABELTRACE_LDFLAGS) EXTLIBS += -lbabeltrace-ctf $(call detected,CONFIG_LIBBABELTRACE) + else + msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev); + NO_LIBBABELTRACE := 1 endif endif
tools/perf/config/feature-checks/Makefile +1 -1
@@ -44,7 +44,7 @@ BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $( ############################### test-all.bin: - $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -lbabeltrace + $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz test-hello.bin: $(BUILD)
tools/perf/config/feature-checks/test-all.c +8 -1
@@ -101,9 +101,17 @@# include "test-pthread_attr_setaffinity_np.c" #undef main +# if 0 +/* +* Disable libbabeltrace check for test-all, because the requested +* library version is not released yet in most distributions. Will +* reenable later. +*/ +#define main main_test_libbabeltrace# include "test-libbabeltrace.c" #undef main +#endif int main (int argc,char *argv[]) {
@@ -130,7 +138,6 @@ int main(int argc, char *argv[])main_test_sync_compare_and_swap (argc, argv);main_test_zlib ();main_test_pthread_attr_setaffinity_np (); -main_test_libbabeltrace ();return 0 ; }
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 7/31 perf build: Move features build output under features directory
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Following commit introduced features build dump:
443a70541c56 perf tools: Output feature detection's gcc output to a file
Moving them into to have code more compact and renaming build dump files. For each feature 'test-X' new file 'test-X.make.output' is created and contains the build out. It's created in the same directory as the feature itself.
--- tools/perf/Makefile.perf | 1 - tools/perf/config/Makefile | 2 +- tools/perf/config/feature-checks/Makefile | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/Makefile.perf +0 -1
@@ -529,7 +529,6 @@ clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean $(Q)$(RM) .config-detected $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-FEATURES $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* - $(call QUIET_CLEAN, feature-detect) $(RM) $(OUTPUT)config/feature-checks/.make-*.output $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean $(python-clean)
tools/perf/config/Makefile +1 -1
@@ -184,7 +184,7 @@ endif feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin > $(OUTPUT)config/feature-checks/.make-$(1).output 2>&1 && echo 1 || echo 0) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) endef feature_set = $(eval $(feature_set_code))
tools/perf/config/feature-checks/Makefile +3 -2
@@ -39,7 +39,8 @@ PKG_CONFIG := $(CROSS_COMPILE)pkg-config all: $(FILES) -BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS) +__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS) + BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1 ###############################
@@ -156,4 +157,4 @@ test-zlib.bin: ############################### clean: - rm -f $(FILES) *.d + rm -f $(FILES) *.d $(FILES:.bin=.make.output)
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 8/31 perf build: Fix pthread-attr-setaffinity-np include in test-all
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
The test-all fails to build due to type in pthread-attr-setaffinity-np include.
--- tools/perf/config/feature-checks/test-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/feature-checks/test-all.c +1 -1
@@ -98,7 +98,7 @@#undef main#define main main_test_pthread_attr_setaffinity_np -# include "test-pthread_attr_setaffinity_np.c" +# include "test-pthread-attr-setaffinity-np.c" #undef main# if 0
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 9/31 perf build: Get rid of LIB_INCLUDE variable
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
It has no use, so we can directly use the value for CFLAGS.
--- tools/perf/config/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/config/Makefile +1 -2
@@ -15,7 +15,6 @@ $(shell echo -n > .config-detected) detected = $(shell echo "$(1)=y" >> .config-detected) detected_var = $(shell echo "$(1)=$($(1))" >> .config-detected) -LIB_INCLUDE := $(srctree)/tools/lib/ CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) include $(src-perf)/config/Makefile.arch
@@ -320,7 +319,7 @@ endif CFLAGS += -I$(src-perf)/util CFLAGS += -I$(src-perf) -CFLAGS += -I$(LIB_INCLUDE) +CFLAGS += -I$(srctree)/tools/lib/ CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 10/31 perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'FEATURE*' namespace.
--- tools/perf/config/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/config/Makefile +6 -6
@@ -203,7 +203,7 @@ endef # the rule that uses them - an example for that is the 'bionic' # feature check. ] # -CORE_FEATURE_TESTS = \ +FEATURE_TESTS = \ backtrace \ dwarf \ fortify-source \
@@ -262,7 +262,7 @@ VF_FEATURE_TESTS = \ compile-32 \ compile-x32 -# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features. +# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. # If in the future we need per-feature checks/flags for features not # mentioned in this list we need to refactor this ;-). set_test_all_flags = $(eval $(set_test_all_flags_code))
@@ -271,7 +271,7 @@ define set_test_all_flags_code FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1)) endef -$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat))) +$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat))) # # Special fast-path for the 'all features are available' case:
@@ -286,10 +286,10 @@ ifeq ($(feature-all), 1) # # test-all.c passed - just set all the core feature flags to 1: # - $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat))) + $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) else - $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(CORE_FEATURE_TESTS)) >/dev/null 2>&1) - $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat))) + $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1) + $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) endif ifeq ($(feature-stackprotector-all), 1)
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 11/31 perf build: Get rid of VF_FEATURE_TESTS
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
It only contains (FEATURE_TESTS - FEATURE_DISPLAY) tests to display the rest of the checks on 'make VF=1'. But we can actually compute this list, which is less confusing.
Also renaming LIB_FEATURE_TESTS into FEATURE_DISPLAY, so it reflects what this variable actually does - display its tests status to user.
--- tools/perf/config/Makefile | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-)
tools/perf/config/Makefile +7 -25
@@ -228,7 +228,7 @@ FEATURE_TESTS = \ libdw-dwarf-unwind \ zlib -LIB_FEATURE_TESTS = \ +FEATURE_DISPLAY = \ dwarf \ glibc \ gtk2 \
@@ -243,25 +243,6 @@ LIB_FEATURE_TESTS = \ libdw-dwarf-unwind \ zlib -VF_FEATURE_TESTS = \ - backtrace \ - fortify-source \ - sync-compare-and-swap \ - gtk2-infobar \ - libelf-getphdrnum \ - libelf-mmap \ - libpython-version \ - pthread-attr-setaffinity-np \ - stackprotector-all \ - timerfd \ - libunwind-debug-frame \ - bionic \ - liberty \ - liberty-z \ - cplus-demangle \ - compile-32 \ - compile-x32 - # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. # If in the future we need per-feature checks/flags for features not # mentioned in this list we need to refactor this ;-).
@@ -805,7 +786,7 @@ define feature_print_text_code MSG = $(shell printf '...%30s: %s' $(1) $(2)) endef -PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat)))) +PERF_FEATURES := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES) ifeq ($(dwarf-post-unwind),1)
@@ -816,7 +797,7 @@ endif # output. It's set if: # - detected features differes from stored features from # last build (in PERF-FEATURES file) -# - one of the $(LIB_FEATURE_TESTS) is not detected +# - one of the $(FEATURE_DISPLAY) is not detected # - VF is enabled ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
@@ -831,7 +812,7 @@ define feature_check_code endif endef -$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat))) +$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat))) ifeq ($(VF),1) display_lib := 1
@@ -841,7 +822,7 @@ endif ifeq ($(display_lib),1) $(info ) $(info Auto-detecting system features:) - $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),)) + $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) ifeq ($(dwarf-post-unwind),1) $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
@@ -849,7 +830,8 @@ ifeq ($(display_lib),1) endif ifeq ($(display_vf),1) - $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),)) + TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) + $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) $(info ) $(call feature_print_var,prefix) $(call feature_print_var,bindir)
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 12/31 perf build: Rename display_lib into feature_display
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'feature*' namespace.
--- tools/perf/config/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/config/Makefile +6 -6
@@ -793,7 +793,7 @@ ifeq ($(dwarf-post-unwind),1) PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text)) endif -# The $(display_lib) controls the default detection message +# The $(feature_display) controls the default detection message # output. It's set if: # - detected features differes from stored features from # last build (in PERF-FEATURES file)
@@ -802,24 +802,24 @@ endif ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)") $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES) - display_lib := 1 + feature_display := 1 endif feature_check = $(eval $(feature_check_code)) define feature_check_code ifneq ($(feature-$(1)), 1) - display_lib := 1 + feature_display := 1 endif endef $(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat))) ifeq ($(VF),1) - display_lib := 1 + feature_display := 1 display_vf := 1 endif -ifeq ($(display_lib),1) +ifeq ($(feature_display),1) $(info ) $(info Auto-detecting system features:) $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
@@ -841,7 +841,7 @@ ifeq ($(display_vf),1) $(call feature_print_var,LIBDW_DIR) endif -ifeq ($(display_lib),1) +ifeq ($(feature_display),1) $(info ) endif
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 13/31 perf build: Rename display_vf to feature_verbose
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'feature*' namespace.
--- tools/perf/config/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -816,7 +816,7 @@ $(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat))) ifeq ($(VF),1) feature_display := 1 - display_vf := 1 + feature_verbose := 1 endif ifeq ($(feature_display),1)
@@ -829,7 +829,7 @@ ifeq ($(feature_display),1) endif endif -ifeq ($(display_vf),1) +ifeq ($(feature_verbose),1) TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) $(info )
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 14/31 perf build: Rename PERF-FEATURES into FEATURE-DUMP
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'FEATURE*' namespace.
--- tools/perf/Makefile.perf | 2 +- tools/perf/config/Makefile | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile.perf +1 -1
@@ -528,7 +528,7 @@ clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) .config-detected $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 - $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-FEATURES $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* + $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean $(python-clean)
tools/perf/config/Makefile +6 -6
@@ -786,22 +786,22 @@ define feature_print_text_code MSG = $(shell printf '...%30s: %s' $(1) $(2)) endef -PERF_FEATURES := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) -PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES) +FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) +FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP) ifeq ($(dwarf-post-unwind),1) - PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text)) + FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text)) endif # The $(feature_display) controls the default detection message # output. It's set if: # - detected features differes from stored features from -# last build (in PERF-FEATURES file) +# last build (in FEATURE-DUMP file) # - one of the $(FEATURE_DISPLAY) is not detected # - VF is enabled -ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)") - $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES) +ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)") + $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP) feature_display := 1 endif
Signature · 1 line
1.9.3
Re: [PATCH 14/31] perf build: Rename PERF-FEATURES into FEATURE-DUMP
Quoted 5 lines · Arnaldo Carvalho de Melo
From: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'FEATURE*' namespace.
Quoted 8 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
So I think the various capital letter files in $(cwd) are highly suboptimal:
FEATURE-DUMP
PERF-CFLAGS
PERF-VERSION-FILE
I think we should standardize on something less pushy (no shouting), plus more standardized, more logical, more coherent names, i.e. something like:
.build.features.cache
.build.cflags
.build.version
?
.build.features.* would be reserved to the generic feature detection machinery.
.build.cflags and .build.version could be used by the perf build - hopefully exported to tools/build/ as well in the future! :-)
That way the .gitignore could just ignore .build.* and we'd not have to update it much.
Btw., another small nit: could we please do a (git-)rename of tools/build/feature/ to tools/build/features/?
Plural is what is used typically for generic frameworks that deal with a set of items (features in this case) - for example we have tools/tests/, and tools/perf/scripts/, not tools/test/ and tools/perf/script/.
Thanks,
Ingo
Re: [PATCH 14/31] perf build: Rename PERF-FEATURES into FEATURE-DUMP
Quoted 17 lines · Ingo Molnar
Quoted 5 lines · Arnaldo Carvalho de Melo
From: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'FEATURE*' namespace.
Quoted 8 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Quoted 6 lines
So I think the various capital letter files in $(cwd) are highly suboptimal:
FEATURE-DUMP
PERF-CFLAGS
PERF-VERSION-FILE
we no longer have the PERF-CFLAGS file:
db8486626246 perf build: Remove PERF-CFLAGS file
forgot to update the .gitignore file, will do
Quoted 8 lines
I think we should standardize on something less pushy (no shouting), plus more standardized, more logical, more coherent names, i.e. something like:
.build.features.cache
.build.cflags
.build.version
Quoted 7 lines
?
.build.features.* would be reserved to the generic feature detection machinery.
.build.cflags and .build.version could be used by the perf build - hopefully exported to
tools/build/as well in the future! :-)
ok, noted ;-)
Quoted 2 lines
That way the .gitignore could just ignore .build.* and we'd not have to update it much.
agreed
Quoted 8 lines
Btw., another small nit: could we please do a (git-)rename of
tools/build/feature/totools/build/features/?Plural is what is used typically for generic frameworks that deal with a set of items (features in this case) - for example we have
tools/tests/, andtools/perf/scripts/, nottools/test/andtools/perf/script/.
ok, I'll try to address all this in the next build update
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 14/31] perf build: Rename PERF-FEATURES into FEATURE-DUMP
In reply to Ingo MolnarEm Sun, Mar 22, 2015 at 11:19:33AM +0100, Ingo Molnar escreveu:
Quoted 34 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
From: Jiri Olsa <[email protected]>
Preparing for feature checks separation, moving related stuff under 'FEATURE*' namespace.
Quoted 8 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>So I think the various capital letter files in $(cwd) are highly suboptimal:
FEATURE-DUMP
PERF-CFLAGS
PERF-VERSION-FILEI think we should standardize on something less pushy (no shouting), plus more standardized, more logical, more coherent names, i.e. something like:
.build.features.cache
.build.cflags
.build.version?
Quoted 8 lines
.build.features.* would be reserved to the generic feature detection machinery.
.build.cflags and .build.version could be used by the perf build - hopefully exported to
tools/build/as well in the future! :-)That way the .gitignore could just ignore .build.* and we'd not have to update it much.
Agreed, Jiri?
Quoted 7 lines
Btw., another small nit: could we please do a (git-)rename of
tools/build/feature/totools/build/features/?Plural is what is used typically for generic frameworks that deal with a set of items (features in this case) - for example we have
tools/tests/, andtools/perf/scripts/, nottools/test/andtools/perf/script/.
This one is easy enough, will do in my next pull req.
- Arnaldo
Arnaldo Carvalho de Melo
maintainerPATCH 15/31 perf build: Rename feature_print_var_code to print_var_code
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
As it has nothing to do with features and won't be moved into tools/build.
--- tools/perf/config/Makefile | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
tools/perf/config/Makefile +12 -11
@@ -776,8 +776,8 @@ define feature_print_status_code endif endef -feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG)) -define feature_print_var_code +print_var = $(eval $(print_var_code)) $(info $(MSG)) +define print_var_code MSG = $(shell printf '...%30s: %s' $(1) $($(1))) endef
@@ -827,21 +827,22 @@ ifeq ($(feature_display),1) ifeq ($(dwarf-post-unwind),1) $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) endif + + ifneq ($(feature_verbose),1) + $(info ) + endif endif ifeq ($(feature_verbose),1) TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) $(info ) - $(call feature_print_var,prefix) - $(call feature_print_var,bindir) - $(call feature_print_var,libdir) - $(call feature_print_var,sysconfdir) - $(call feature_print_var,LIBUNWIND_DIR) - $(call feature_print_var,LIBDW_DIR) -endif - -ifeq ($(feature_display),1) + $(call print_var,prefix) + $(call print_var,bindir) + $(call print_var,libdir) + $(call print_var,sysconfdir) + $(call print_var,LIBUNWIND_DIR) + $(call print_var,LIBDW_DIR) $(info ) endif
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 17/31 perf tools: Fix the bash completion for listing options of perf subcommand
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing options for 'perf kvm|kmem|mem|lock|sched --<TAB>', where 'kvm|kmem|mem|lock|sched' are all subcommands of perf.
Example:
Before this patch:
$ perf kvm --<TAB> $
As shown above, the options of perf kvm does not come out.
After this patch:
$ perf kvm --<TAB> --alloc --caller --input --line --raw-ip --sort --verbose
As shown above, the options of perf kvm can come out now.
--- tools/perf/perf-completion.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
tools/perf/perf-completion.sh +12 -9
@@ -119,15 +119,18 @@ __perf_main () elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" - # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then - subcmds=$($cmd $prev --list-cmds) - __perfcomp_colon "$subcmds" "$cur" - # List long option names - elif [[ $cur == --* ]]; then - subcmd=${words[1]} - opts=$($cmd $subcmd --list-opts) - __perfcomp "$opts" "$cur" + else + # List subcommands for perf commands + if [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then + subcmds=$($cmd $prev --list-cmds) + __perfcomp_colon "$subcmds" "$cur" + fi + # List long option names + if [[ $cur == --* ]]; then + subcmd=${words[1]} + opts=$($cmd $subcmd --list-opts) + __perfcomp "$opts" "$cur" + fi fi }
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 18/31 perf tools: Fix the bash completion for listing subsubcommands of perf subcommand
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf kvm|kmem|mem|lock|sched --<long option> <TAB>', where 'kvm|kmem|mem| lock|sched' are all subcommands of perf.
Example:
Before this patch:
$ perf kvm --verbose <TAB> $
As shown above, the subsubcommands of perf kvm does not come out.
After this patch:
$ perf kvm --verbose <TAB> buildid-list diff record report stat top
As shown above, the subsubcommands of perf kvm can come out now.
--- tools/perf/perf-completion.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
tools/perf/perf-completion.sh +21 -2
@@ -100,6 +100,23 @@ __perfcomp_colon () __ltrim_colon_completions $cur } +__perf_prev_skip_opts () +{ + local i cmd_ cmds_ + + let i=cword-1 + cmds_=$($cmd --list-cmds) + prev_skip_opts=() + while [ $i -ge 0 ]; do + for cmd_ in $cmds_; do + if [[ ${words[i]} == $cmd_ ]]; then + prev_skip_opts=${words[i]} + return + fi + done + ((i--)) + done +} __perf_main () { local cmd
@@ -107,6 +124,8 @@ __perf_main () cmd=${words[0]} COMPREPLY=() + # Skip options backward and find the last perf command + __perf_prev_skip_opts # List perf subcommands or long options if [ $cword -eq 1 ]; then if [[ $cur == --* ]]; then
@@ -121,8 +140,8 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then - subcmds=$($cmd $prev --list-cmds) + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched) ]]; then + subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi # List long option names
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 19/31 perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion gives wrong options for 'perf kvm|kmem|mem|lock| sched subsubcommand --<TAB>', where 'kvm|kmem|mem|lock|sched' are all subcommands of perf and 'subsubcommand' is a subcommand of 'kvm|kmem|mem |lock|sched'. In fact, the result incorrectly lists the bash completion of 'perf subcommand' rather than 'perf subcommand subsubcommand'.
Example:
Before this patch:
$ perf kvm record --<TAB> --guest --guestkallsyms --guestmodules --guestmount --guestvmlinux --host --input --output --verbose
As shown above, the result is the options of kvm rather than record.
After this patch:
$ perf kvm record --<TAB> --all-cpus --cgroup --delay --group --no-buildid --output --quiet --stat --uid --branch-any --count --event --intr-regs --no-buildid-cache --period --raw-samples --tid --verbose --branch-filter --cpu --filter --mmap-pages --no-inherit --per-thread --realtime --timestamp --weight --call-graph --data --freq --no-buffering --no-samples --pid --running-time --transaction
As shown above, the result is exactly the options of record as we wished.
--- tools/perf/perf-completion.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/perf-completion.sh +7 -2
@@ -105,9 +105,12 @@ __perf_prev_skip_opts () local i cmd_ cmds_ let i=cword-1 - cmds_=$($cmd --list-cmds) + cmds_=$($cmd $1 --list-cmds) prev_skip_opts=() while [ $i -ge 0 ]; do + if [[ ${words[i]} == $1 ]]; then + return + fi for cmd_ in $cmds_; do if [[ ${words[i]} == $cmd_ ]]; then prev_skip_opts=${words[i]}
@@ -146,7 +149,9 @@ __perf_main () fi # List long option names if [[ $cur == --* ]]; then - subcmd=${words[1]} + subcmd=$prev_skip_opts + __perf_prev_skip_opts $subcmd + subcmd=$subcmd" "$prev_skip_opts opts=$($cmd $subcmd --list-opts) __perfcomp "$opts" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 20/31 perf tools: Fix the bash completion for listing events of perf subcommand record|stat|top -e
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing events for 'perf kvm|kmem| mem|lock|sched record|stat|top -e <TAB>', where 'kvm|kmem|mem|lock|sched' are all subcommands of perf.
Example:
Before this patch:
$ perf kvm record -e <TAB> $
As shown above, the events of record does not come out.
After this patch:
$ perf kvm record -e <TAB> alignment-faults cpu/instructions/ L1-dcache-prefetch-misses node-prefetches uncore_rbox_0/qpi0_idle_filt/ branch-instructions cpu/mem-loads/ L1-dcache-store-misses node-prefetch-misses uncore_rbox_0/qpi1_date_response/ branch-load-misses cpu-migrations L1-dcache-stores node-store-misses uncore_rbox_0/qpi1_filt_send/ branch-loads dTLB-load-misses L1-icache-load-misses node-stores uncore_rbox_0/qpi1_idle_filt/ ...
As shown above, the events of record can come out now.
--- tools/perf/perf-completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf-completion.sh +1 -1
@@ -138,7 +138,7 @@ __perf_main () fi __perfcomp "$cmds" "$cur" # List possible events for -e option - elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then + elif [[ $prev == "-e" && $prev_skip_opts == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" else
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 21/31 perf tools: Fix the bash completion to support listing events for --event
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion only supports -e rather than --event, so fix it.
Example:
Before this patch:
$ perf record --event <TAB> $
As shown above, the events of record does not come out.
After this patch:
$ perf record --event <TAB> lignment-faults cpu/instructions/ L1-dcache-prefetch-misses node-prefetches uncore_rbox_0/qpi0_idle_filt/ branch-instructions cpu/mem-loads/ L1-dcache-store-misses node-prefetch-misses uncore_rbox_0/qpi1_date_response/ branch-load-misses cpu-migrations L1-dcache-stores node-store-misses uncore_rbox_0/qpi1_filt_send/ branch-loads dTLB-load-misses L1-icache-load-misses node-stores uncore_rbox_0/qpi1_idle_filt/ ...
As shown above, the events of record can come out now.
--- tools/perf/perf-completion.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf-completion.sh +2 -2
@@ -137,8 +137,8 @@ __perf_main () cmds=$($cmd --list-cmds) fi __perfcomp "$cmds" "$cur" - # List possible events for -e option - elif [[ $prev == "-e" && $prev_skip_opts == @(record|stat|top) ]]; then + # List possible events for -e and --event option + elif [[ $prev == @("-e"|"--event") && $prev_skip_opts == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" else
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 22/31 perf tools: Fix the bash completion for listing subcommands of perf
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subcommands for 'perf --<long option> <TAB>'.
Example:
Before this patch:
$ perf --debug <TAB> $
As shown above, the subcommands of perf does not come out.
After this patch:
$ perf --debug <TAB> annotate buildid-cache data evlist inject kvm lock probe report script test top version bench buildid-list diff help kmem list mem record sched stat timechart trace
As shown above, the subcommands of perf can come out now.
--- tools/perf/perf-completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf-completion.sh +1 -1
@@ -130,7 +130,7 @@ __perf_main () # Skip options backward and find the last perf command __perf_prev_skip_opts # List perf subcommands or long options - if [ $cword -eq 1 ]; then + if [ -z $prev_skip_opts ]; then if [[ $cur == --* ]]; then cmds=$($cmd --list-opts) else
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 23/31 perf tools: Add the bash completion for listing subsubcommands of perf data
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf data <TAB>', so fix it.
Example:
Before this patch:
$ perf data <TAB> $
As shown above, the subsubcommands of perf data does not come out.
After this patch:
$ perf data <TAB> convert
As shown above, the subsubcommands of perf data can come out now.
--- tools/perf/builtin-data.c | 6 ++++-- tools/perf/perf-completion.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/builtin-data.c +4 -2
@@ -22,7 +22,9 @@ static const struct option data_options[] = { OPT_END() }; -static const char *const data_usage[] = { +static const char *const data_subcommands[] = {"convert" ,NULL }; + +static const char *data_usage[] = {"perf data [<common options>] <command> [<options>]" ,NULL };
@@ -98,7 +100,7 @@ int cmd_data(int argc, const char **argv, const char *prefix)if (argc <2 ) goto usage; - argc =parse_options (argc, argv, data_options, data_usage, + argc =parse_options_subcommand (argc, argv, data_options, data_subcommands, data_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (argc <1 ) goto usage;
tools/perf/perf-completion.sh +1 -1
@@ -143,7 +143,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 24/31 perf tools: Add the bash completion for listing subsubcommands of perf help
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf help <TAB>', so fix it.
Example:
Before this patch:
$ perf help <TAB> $
As shown above, the subsubcommands of perf help does not come out.
After this patch:
$ perf help <TAB> annotate buildid-cache data evlist inject kvm lock probe report script test top bench buildid-list diff help kmem list mem record sched stat timechart trace
As shown above, the subsubcommands of perf help can come out now.
--- tools/perf/builtin-help.c | 17 ++++++++++++++--- tools/perf/perf-completion.sh | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-)
tools/perf/builtin-help.c +14 -3
@@ -437,7 +437,18 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) HELP_FORMAT_INFO), OPT_END(), }; -const char *const builtin_help_usage[] = { +const char *const builtin_help_subcommands[] = { +"buildid-cache" ,"buildid-list" ,"diff" ,"evlist" ,"help" ,"list" , +"record" ,"report" ,"bench" ,"stat" ,"timechart" ,"top" ,"annotate" , +"script" ,"sched" ,"kmem" ,"lock" ,"kvm" ,"test" ,"inject" ,"mem" ,"data" , +#ifdef HAVE_LIBELF_SUPPORT +"probe" , +#endif +#ifdef HAVE_LIBAUDIT_SUPPORT +"trace" , +#endif +NULL }; +const char *builtin_help_usage[] = {"perf help [--all] [--man|--web|--info] [command]" ,NULL };
@@ -448,8 +459,8 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)perf_config (perf_help_config, &help_format); - argc =parse_options (argc, argv, builtin_help_options, - builtin_help_usage,0 ); + argc =parse_options_subcommand (argc, argv, builtin_help_options, + builtin_help_subcommands, builtin_help_usage,0 );if (show_all) {printf ("\n usage: %s\n\n" , perf_usage_string);
tools/perf/perf-completion.sh +1 -1
@@ -143,7 +143,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 25/31 perf tools: Add the bash completion for listing subsubcommands of perf script
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf script <TAB>', so fix it.
Example:
Before this patch:
$ perf script <TAB> $
As shown above, the subsubcommands of perf script does not come out.
After this patch:
$ perf script <TAB> record report
As shown above, the subsubcommands of perf script can come out now.
--- tools/perf/builtin-script.c | 5 +++-- tools/perf/perf-completion.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
tools/perf/builtin-script.c +3 -2
@@ -1572,7 +1572,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "Show the mmap events"),OPT_END () }; -const char *const script_usage[] = { +const char *const script_subcommands[] = {"record" ,"report" ,NULL }; +const char *script_usage[] = {"perf script [<options>]" ,"perf script [<options>] record <script> [<record-options>] <command>" ,"perf script [<options>] report <script> [script-args]" ,
@@ -1586,7 +1587,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)setup_scripting (); - argc =parse_options (argc, argv, options, script_usage, + argc =parse_options_subcommand (argc, argv, options, script_subcommands, script_usage,PARSE_OPT_STOP_AT_NON_OPTION ); file.path = input_name;
tools/perf/perf-completion.sh +1 -1
@@ -143,7 +143,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 26/31 perf tools: Add the bash completion for listing subsubcommands of perf test
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf test <TAB>', so fix it.
Example:
Before this patch:
$ perf test <TAB> $
As shown above, the subsubcommands of perf test does not come out.
After this patch:
$ perf test <TAB> list
As shown above, the subsubcommands of perf test can come out now.
--- tools/perf/perf-completion.sh | 2 +- tools/perf/tests/builtin-test.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
tools/perf/perf-completion.sh +1 -1
@@ -143,7 +143,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
tools/perf/tests/builtin-test.c +3 -2
@@ -291,7 +291,7 @@ static int perf_test__list(int argc, const char **argv)int cmd_test (int argc,const char **argv,const char *prefix__maybe_unused ) { -const char *const test_usage[] = { +const char *test_usage[] = {"perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]" ,NULL , };
@@ -302,13 +302,14 @@ int cmd_test(int argc, const char **argv, const char *prefix __maybe_unused) "be more verbose (show symbol address, etc)"), OPT_END() }; +const char *const test_subcommands[] = {"list" ,NULL };struct intlist *skiplist =NULL ;int ret =hists__init ();if (ret <0 )return ret; - argc =parse_options (argc, argv, test_options, test_usage,0 ); + argc =parse_options_subcommand (argc, argv, test_options, test_subcommands, test_usage,0 );if (argc >=1 && !strcmp (argv[0 ],"list" ))return perf_test__list (argc, argv);
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 27/31 perf tools: Add the bash completion for listing subsubcommands of perf timechart
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf timechart <TAB>', so fix it.
Example:
Before this patch:
$ perf timechart <TAB> $
As shown above, the subsubcommands of perf timechart does not come out.
After this patch:
$ perf timechart <TAB> record
As shown above, the subsubcommands of perf timechart can come out now.
--- tools/perf/builtin-timechart.c | 7 ++++--- tools/perf/perf-completion.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
tools/perf/builtin-timechart.c +4 -3
@@ -1958,7 +1958,8 @@ int cmd_timechart(int argc, const char **argv, parse_time), OPT_END() }; -const char *const timechart_usage[] = { +const char *const timechart_subcommands[] = {"record" ,NULL }; +const char *timechart_usage[] = {"perf timechart [<options>] {record}" ,NULL };
@@ -1976,8 +1977,8 @@ int cmd_timechart(int argc, const char **argv,"perf timechart record [<options>]" , NULL }; - argc =parse_options (argc, argv, timechart_options, timechart_usage, -PARSE_OPT_STOP_AT_NON_OPTION ); + argc =parse_options_subcommand (argc, argv, timechart_options, timechart_subcommands, + timechart_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (tchart.power_only && tchart.tasks_only) {pr_err ("-P and -T options cannot be used at the same time.\n" );
tools/perf/perf-completion.sh +1 -1
@@ -143,7 +143,7 @@ __perf_main () __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test|timechart) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 28/31 perf tools: Add the bash completion for listing subsubcommands of perf trace
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
The bash completion does not support listing subsubcommands for 'perf trace <TAB>', so fix it.
Example:
Before this patch:
$ perf trace <TAB> $
As shown above, the subsubcommands of perf trace does not come out.
After this patch:
$ perf trace <TAB> record
As shown above, the subsubcommands of perf trace can come out now.
--- tools/perf/builtin-trace.c | 7 ++++--- tools/perf/perf-completion.sh | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
tools/perf/builtin-trace.c +4 -3
@@ -2609,7 +2609,7 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler)int cmd_trace (int argc,const char **argv,const char *prefix__maybe_unused ) { -const char *const trace_usage[] = { +const char *trace_usage[] = {"perf trace [<options>] [<command>]" ,"perf trace [<options>] -- <command> [<options>]" ,"perf trace record [<options>] [<command>]" ,
@@ -2684,6 +2684,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"syscalls" , &trace.trace_syscalls,"Trace syscalls" ), OPT_END() }; +const char *const trace_subcommands[] = {"record" ,NULL };int err;char bf[BUFSIZ ];
@@ -2699,8 +2700,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - argc =parse_options (argc, argv, trace_options, trace_usage, -PARSE_OPT_STOP_AT_NON_OPTION ); + argc =parse_options_subcommand (argc, argv, trace_options, trace_subcommands, + trace_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (trace.trace_pgfaults) { trace.opts.sample_address = true;
tools/perf/perf-completion.sh +6 -3
@@ -120,6 +120,7 @@ __perf_prev_skip_opts () ((i--)) done } + __perf_main () { local cmd
@@ -137,13 +138,15 @@ __perf_main () cmds=$($cmd --list-cmds) fi __perfcomp "$cmds" "$cur" - # List possible events for -e and --event option - elif [[ $prev == @("-e"|"--event") && $prev_skip_opts == @(record|stat|top) ]]; then + # List possible events for -e option + elif [[ $prev == @("-e"|"--event") && + $prev_skip_opts == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" else # List subcommands for perf commands - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test|timechart) ]]; then + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| + |data|help|script|test|timechart|trace) ]]; then subcmds=$($cmd $prev_skip_opts --list-cmds) __perfcomp_colon "$subcmds" "$cur" fi
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 29/31 perf tools: Avoid confusion with preloaded bash function for perf bash completion
In reply to Arnaldo Carvalho de MeloFrom: Yunlong Song <[email protected]>
Since some functions (e.g. '_get_comp_words_by_ref()') in perf bash completion script are originally taken from git bash completion script, these functions may be preloaded before perf bash completion script runs.
In order to avoid repeating loading the same function twice, some test constraints are used before these function definitions in the perf bash completion script (e.g. 'type _get_comp_words_by_ref &>/dev/null ||').
The problem is that, if these functions in perf bash completion script are changed for some reason, perf will still use the preloaded bash functions rather than the customized functions of its own.
As a result, the perf bash completion will behave incorrectly. To get rid of this problem, a flag can be defined to determine the proper situation.
And to avoid overwriting the preloaded functions, the names of these functions in perf bash completion script should be renamed to the perf-customized ones.
Example:
Before this patch:
$ type _get_comp_words_by_ref
_get_comp_words_by_ref is a function
_get_comp_words_by_ref ()
{
local exclude flag i OPTIND=1;
local cur cword words=();
local upargs=() upvars=() vcur vcword vprev vwords;
while getopts "c:i:n:p:w:" flag "$@"; do
case $flag in
c)
vcur=$OPTARG
;;
i)
vcword=$OPTARG
;;
n)
exclude=$OPTARG
;;
p)
vprev=$OPTARG
;;
w)
vwords=$OPTARG
;;
esac;
done;
while [[ $# -ge $OPTIND ]]; do
case ${!OPTIND} in
cur)
vcur=cur
;;
prev)
vprev=prev
;;
cword)
vcword=cword
;;
words)
vwords=words
;;
*)
echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2;
return 1
;;
esac;
let "OPTIND += 1";
done;
__get_cword_at_cursor_by_ref "$exclude" words cword cur;
[[ -n $vcur ]] && {
upvars+=("$vcur");
upargs+=(-v $vcur "$cur")
};
[[ -n $vcword ]] && {
upvars+=("$vcword");
upargs+=(-v $vcword "$cword")
};
[[ -n $vprev && $cword -ge 1 ]] && {
upvars+=("$vprev");
upargs+=(-v $vprev "${words[cword - 1]}")
};
[[ -n $vwords ]] && {
upvars+=("$vwords");
upargs+=(-a${#words[@]} $vwords "${words[@]}")
};
(( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}"
}As shown above, the _get_comp_words_by_ref is the preloaded function in fact, rather than the function defined in perf-completion.sh. So if we happen to change the function for some reason, the result will behave in a wrong state.
After this patch:
We can set preload_get_comp_words_by_ref="false" to not use the preloaded function. Instead, it will use the function defined in perf-completion.sh, which is renamed as __perf_get_comp_words_by_ref to avoid overwriting the preloaded function _get_comp_words_by_ref.
$ type __perf_get_comp_words_by_ref
__perf_get_comp_words_by_ref is a function
__perf_get_comp_words_by_ref ()
{
local exclude cur_ words_ cword_;
if [ "$1" = "-n" ]; then
exclude=$2;
shift 2;
fi;
__my_reassemble_comp_words_by_ref "$exclude";
cur_=${words_[cword_]};
while [ $# -gt 0 ]; do
case "$1" in
cur)
cur=$cur_
;;
prev)
prev=${words_[$cword_-1]}
;;
words)
words=("${words_[@]}")
;;
cword)
cword=$cword_
;;
esac;
shift;
done
}As shown above, the function __perf_get_comp_words_by_ref is loaded and can work this time.
Note that we do not change the original behavior when those functions are not preloaded before perf bash completion script runs. In this case, although the flag is set to "true", the code will still change it to "false" to use the function defined in perf-completion.sh.
--- tools/perf/perf-completion.sh | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
tools/perf/perf-completion.sh +30 -6
@@ -47,8 +47,16 @@ __my_reassemble_comp_words_by_ref() done } -type _get_comp_words_by_ref &>/dev/null || -_get_comp_words_by_ref() +# Define preload_get_comp_words_by_ref="false", if the function +# __perf_get_comp_words_by_ref() is required instead. +preload_get_comp_words_by_ref="true" + +if [ $preload_get_comp_words_by_ref = "true" ]; then + type _get_comp_words_by_ref &>/dev/null || + preload_get_comp_words_by_ref="false" +fi +[ $preload_get_comp_words_by_ref = "true" ] || +__perf_get_comp_words_by_ref() { local exclude cur_ words_ cword_ if [ "$1" = "-n" ]; then
@@ -76,8 +84,16 @@ _get_comp_words_by_ref() done } -type __ltrim_colon_completions &>/dev/null || -__ltrim_colon_completions() +# Define preload__ltrim_colon_completions="false", if the function +# __perf__ltrim_colon_completions() is required instead. +preload__ltrim_colon_completions="true" + +if [ $preload__ltrim_colon_completions = "true" ]; then + type __ltrim_colon_completions &>/dev/null || + preload__ltrim_colon_completions="false" +fi +[ $preload__ltrim_colon_completions = "true" ] || +__perf__ltrim_colon_completions() { if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then # Remove colon-word prefix from COMPREPLY items
@@ -97,7 +113,11 @@ __perfcomp () __perfcomp_colon () { __perfcomp "$1" "$2" - __ltrim_colon_completions $cur + if [ $preload__ltrim_colon_completions = "true" ]; then + __ltrim_colon_completions $cur + else + __perf__ltrim_colon_completions $cur + fi } __perf_prev_skip_opts ()
@@ -226,7 +246,11 @@ type perf &>/dev/null && _perf() { local cur words cword prev - _get_comp_words_by_ref -n =: cur words cword prev + if [ $preload_get_comp_words_by_ref = "true" ]; then + _get_comp_words_by_ref -n =: cur words cword prev + else + __perf_get_comp_words_by_ref -n =: cur words cword prev + fi __perf_main } &&
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 30/31 perf callchain: Separate eh/debug frame offset cache.
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Commit f1f13af99a90 ("perf callchain: Cache eh/debug frame offset for dwarf unwind") introduces a cache for .debug_frame and .eh_frame_hdr. Unfortunately, it makes them share a same cache (dso->frame_offset). Which causes unwind failure on ARM:
$ perf test unwind Test dwarf unwind: FAILED!
The reason is that, if a dso has '.debug_frame' but doesn't have '.eh_frame_hdr' (like ARM), dso->frame_offset will be filled by offset of '.debug_frame' during the first time calling of find_proc_info() -> read_unwind_spec_debug_frame(), and be regarded to '.eh_frame_hdr' when the second time calling of find_proc_info() -> read_unwind_spec_eh_frame(), since '.eh_frame_hdr' is checked prior to '.debug_frame'.
This patch solves the problem by creating two cache fields for '.eh_frame_hdr' and '.debug_frame'.
--- tools/perf/util/dso.h | 3 ++- tools/perf/util/unwind-libunwind.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
tools/perf/util/dso.h +2 -1
@@ -139,7 +139,8 @@ struct dso {u32 status_seen;size_t file_size;struct list_head open_entry; -u64 frame_offset; +u64 debug_frame_offset; +u64 eh_frame_hdr_offset; } data;union {/* Tool specific area */
tools/perf/util/unwind-libunwind.c +4 -4
@@ -266,7 +266,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, u64 *fde_count) {int ret = -EINVAL , fd; -u64 offset = dso->data.frame_offset; +u64 offset = dso->data.eh_frame_hdr_offset;if (offset ==0 ) { fd =dso__data_fd (dso, machine);
@@ -275,7 +275,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,/* Check the .eh_frame section for unwinding info */ offset =elf_section_offset (fd,".eh_frame_hdr" ); - dso->data.frame_offset = offset; + dso->data.eh_frame_hdr_offset = offset; }if (offset)
@@ -291,7 +291,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, struct machine *machine, u64 *offset) { int fd; -u64 ofs = dso->data.frame_offset; +u64 ofs = dso->data.debug_frame_offset;if (ofs ==0 ) { fd =dso__data_fd (dso, machine);
@@ -300,7 +300,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,/* Check the .debug_frame section for unwinding info */ ofs =elf_section_offset (fd,".debug_frame" ); - dso->data.frame_offset = ofs; + dso->data.debug_frame_offset = ofs; } *offset = ofs;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 31/31 perf report: Don't allow empty argument for '-t'.
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
Without this patch, perf report cause segfault if pass "" as '-t':
$ perf report -t ""
# To display the perf.data header info, please use --header/--header-only options. #
# Samples: 37 of event 'syscalls:sys_enter_write'
# Event count (approx.): 37
#
# Children SelfCommand Shared Object Symbol
Segmentation fault
Since -t is used to add field-separator for generate table, -t "" is actually meanless. This patch defines a new OPT_STRING_NOEMPTY() option generator to ensure user never pass empty string to that option.
--- tools/perf/builtin-report.c | 2 +- tools/perf/util/parse-options.c | 21 +++++++++++++++++++-- tools/perf/util/parse-options.h | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-)
tools/perf/builtin-report.c +1 -1
@@ -676,7 +676,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)OPT_STRING ('w' ,"column-widths" , &symbol_conf.col_width_list_str,"width[,width...]" ,"don't try to adjust column width, use these fixed values" ), -OPT_STRING ('t' ,"field-separator" , &symbol_conf.field_sep,"separator" , +OPT_STRING_NOEMPTY ('t' ,"field-separator" , &symbol_conf.field_sep,"separator" ,"separator for columns, no spaces will be added between " "columns '.' is reserved." ), OPT_BOOLEAN('U', "hide-unresolved", &report.hide_unresolved,
tools/perf/util/parse-options.c +19 -2
@@ -37,6 +37,7 @@ static int get_value(struct parse_opt_ctx_t *p, {const char *s, *arg =NULL ;const int unset = flags &OPT_UNSET ; +int err;if (unset && p->opt)return opterror (opt,"takes no value" , flags);
@@ -114,13 +115,29 @@ static int get_value(struct parse_opt_ctx_t *p,return 0 ;case OPTION_STRING : + err =0 ;if (unset) *(const char **)opt->value =NULL ;else if (opt->flags &PARSE_OPT_OPTARG && !p->opt) *(const char **)opt->value = (const char *)opt->defval;else -return get_arg (p, opt, flags, (const char **)opt->value); -return 0 ; + err =get_arg (p, opt, flags, (const char **)opt->value); + +/* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */ +if (opt->flags &PARSE_OPT_NOEMPTY ) { +const char *val = *(const char **)opt->value; + +if (!val) +return err; + +/* Similar to unset if we are given an empty string. */ +if (val[0 ] =='\0' ) { + *(const char **)opt->value =NULL ; +return 0 ; + } + } + +return err;case OPTION_CALLBACK :if (unset)
tools/perf/util/parse-options.h +2 -0
@@ -40,6 +40,7 @@ enum parse_opt_option_flags {PARSE_OPT_LASTARG_DEFAULT =16 ,PARSE_OPT_DISABLED =32 ,PARSE_OPT_EXCLUSIVE =64 , + PARSE_OPT_NOEMPTY = 128, };struct option ;
@@ -122,6 +123,7 @@ struct option {#define OPT_LONG (s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = check_vtype(v, long *), .help = (h) }#define OPT_U64 (s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }#define OPT_STRING (s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) } +#define OPT_STRING_NOEMPTY (s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}#define OPT_DATE (s, l, v, h) \ { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }#define OPT_CALLBACK (s, l, v, a, h, f) \
Signature · 1 line
1.9.3
Quoted 101 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling, more to come,
- Arnaldo
The following changes since commit
107eb964d8c04417e8bce9e9ec2ed61d9261aec6:Merge tag 'perf-core-for-mingo' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2015-03-13 13:30:10 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingofor you to fetch changes up to
0c8c20779c5d56b93b8cb4cd30ba129a927ab437:perf report: Don't allow empty argument for '-t'. (2015-03-19 13:53:28 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:User visible:
- Bash completion for subcommands (Yunlong Song)
- Allow annotating entries in callchains in the hists browser (top/report).
TODO: give some visual cue to what entries in callchains have samples and thus can be annotated and/or allow showing the source code for functions without samples (Arnaldo Carvalho de Melo)- Don't allow empty argument for '-t' in perf report, fixing segfault (Wang Nan)
Infrastructure:
- Prep work for moving the perf feature tests build system to
tools/build(Jiri Olsa)- Fix perf-read-vdsox32 not building and lib64 install dir (H.J. Lu)
- ARM64: fix building error and eh/debug frame offset cache fixes (Wang Nan)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
perf hists browser: Simplify symbol annotation menu setup perf hists browser: Fix up some branch alignment perf hists: Removehist_entry->used, not used anymore perf hists browser: Allow annotating entries in callchainsH.J. Lu (1):
perf tools: Fix perf-read-vdsox32 not building and lib64 install dirJiri Olsa (10):
perf build: Disable default check for libbabeltrace perf build: Move features build output under features directory perf build: Fix pthread-attr-setaffinity-np include in test-all perf build: Get rid ofLIB_INCLUDEvariable
perf build: RenameCORE_FEATURE_TESTStoFEATURE_TESTSperf build: Get rid ofVF_FEATURE_TESTS
perf build: Renamedisplay_libintofeature_displayperf build: Renamedisplay_vftofeature_verboseperf build: Rename PERF-FEATURES into FEATURE-DUMP perf build: Renamefeature_print_var_codetoprint_var_codeWang Nan (3):
perf tools: Fix building error for arm64. perf callchain: Separate eh/debug frame offset cache. perf report: Don't allow empty argument for '-t'.Yunlong Song (13):
perf tools: Fix the bash completion for listing options of perf subcommand
perf tools: Fix the bash completion for listing subsubcommands of perf subcommand perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand perf tools: Fix the bash completion for listing events of perf subcommand record|stat|top -e perf tools: Fix the bash completion to support listing events for --event
perf tools: Fix the bash completion for listing subcommands of perf
perf tools: Add the bash completion for listing subsubcommands of perf data
perf tools: Add the bash completion for listing subsubcommands of perf help
perf tools: Add the bash completion for listing subsubcommands of perf script perf tools: Add the bash completion for listing subsubcommands of perf test
perf tools: Add the bash completion for listing subsubcommands of perf timechart perf tools: Add the bash completion for listing subsubcommands of perf trace
perf tools: Avoid confusion with preloaded bash function for perf bash completiontools/perf/Makefile.perf | 3 +- tools/perf/builtin-data.c | 6 +- tools/perf/builtin-help.c | 17 ++++- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-script.c | 5 +- tools/perf/builtin-timechart.c | 7 +- tools/perf/builtin-trace.c | 7 +- tools/perf/config/Makefile | 111 ++++++++++++---------------- tools/perf/config/Makefile.arch | 2 +- tools/perf/config/feature-checks/Makefile | 7 +- tools/perf/config/feature-checks/test-all.c | 11 ++- tools/perf/perf-completion.sh | 88 +++++++++++++++++----- tools/perf/tests/builtin-test.c | 5 +- tools/perf/tests/make | 2 +- tools/perf/ui/browsers/annotate.c | 8 +- tools/perf/ui/browsers/hists.c | 59 +++++++--------
Quoted 8 lines
tools/perf/util/dso.h | 3 +- tools/perf/util/hist.c | 8 +- tools/perf/util/hist.h | 9 +++ tools/perf/util/parse-options.c | 21 +++++- tools/perf/util/parse-options.h | 2 + tools/perf/util/sort.h | 1 - tools/perf/util/unwind-libunwind.c | 8 +- 23 files changed, 237 insertions(+), 155 deletions(-)
Pulled, thanks a lot Arnaldo!
Ingo