perf tools: Few fixes
Jiri Olsa
reviewercover perf tools: Few fixes
hi,
sending some assorted fixes.
Available also here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (5):
perf build: Add special fixdep cleaning rule
perf tools: Move new_term arguments into struct parse_events_term template perf tools: Fail on using multiple bits long terms without value perf stat: Add -a as a default target
perf record: Add -a as a default target
tools/build/Makefile | 4 ++-- tools/build/Makefile.include | 3 +++ tools/perf/Documentation/perf-record.txt | 2 +- tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/Makefile.perf | 4 ++-- tools/perf/builtin-record.c | 6 ++++-- tools/perf/builtin-stat.c | 6 ++++-- tools/perf/util/parse-events.c | 71 +++++++++++++++++++++++++++++++++++++++++------------------------------ tools/perf/util/parse-events.h | 2 ++ tools/perf/util/parse-events.y | 14 +++++++------- tools/perf/util/pmu.c | 13 +++++++++++-- 11 files changed, 78 insertions(+), 49 deletions(-)
Jiri Olsa
reviewerPATCH 1/5 perf build: Add special fixdep cleaning rule
From: Jiri Olsa <[email protected]>
Ingo reported following build failure:
Quoted 31 lines · Ingo Molnar
So I had this oldish 32-bit 15.10 Ubuntu installation around (fully updated), and trying to build perf gave me:
deimos:~/tip/tools/perf> make
BUILD: Doing 'make -j4' parallel build
make[3]: *** No rule to make target '/usr/include/x86_64-linux-gnu/sys/types.h', needed by 'fixdep.o'. Stop. Makefile:42: recipe for target 'fixdep-in.o' failed
make[2]: *** [fixdep-in.o] Error 2/home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed
make[1]: *** [fixdep] Error 2
Makefile:68: recipe for target 'all' failed
make: *** [all] Error 2Now this got a bit better after I did a 'make mrproper' in the kernel tree:
deimos:~/tip/tools/perf> make
BUILD: Doing 'make -j4' parallel build
HOSTCC fixdep.o/home/mingo/tip/tools/build/fixdep: 1:/home/mingo/tip/tools/build/fixdep: Syntax error: "(" unexpected/home/mingo/tip/tools/build/Makefile.build:101: recipe for target 'fixdep.o' failed make[3]: *** [fixdep.o] Error 2
Makefile:42: recipe for target 'fixdep-in.o' failed
make[2]: *** [fixdep-in.o] Error 2/home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed make[1]: *** [fixdep] Error 2
Makefile:68: recipe for target 'all' failed
make: *** [all] Error 2After some digging it turns out that my 'fixdep' binary was 64-bit:
Quoted 8 lines
deimos:~/tip/tools/perf> file
/home/mingo/tip/tools/build/fixdep/home/mingo/tip/tools/build/fixdep: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter/lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d527f736b57b5ba47210fbcb562a3b52867d21c1, not strippedBut it did not get cleaned out by 'make clean'.
Only after I did a 'make clean' in
tools/itself, did it get built properly.
It shows we don't clean up properly the fixdep objects, so adding special rule for that.
--- tools/build/Makefile | 4 ++-- tools/build/Makefile.include | 3 +++ tools/perf/Makefile.perf | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-)
tools/build/Makefile +2 -2
@@ -35,8 +35,8 @@ all: $(OUTPUT)fixdep clean: $(call QUIET_CLEAN, fixdep) - $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete - $(Q)rm -f fixdep + $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete + $(Q)rm -f $(OUTPUT)fixdep $(OUTPUT)fixdep-in.o: FORCE $(Q)$(MAKE) $(build)=fixdep
tools/build/Makefile.include +3 -0
@@ -3,4 +3,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj fixdep: $(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep +fixdep-clean: + $(Q)$(MAKE) -C $(srctree)/tools/build clean + .PHONY: fixdep
tools/perf/Makefile.perf +2 -2
@@ -726,13 +726,13 @@ config-clean: $(call QUIET_CLEAN, config) $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null -clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean fixdep-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so $(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* \ - $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \ + $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ $(OUTPUT)pmu-events/pmu-events.c $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf build: Add special fixdep cleaning rule
perf build: Add special fixdep cleaning rule
Commit-ID: 85e0d509654c2e2e58b29e50a883acd4c4e8807d Gitweb: http://git.kernel.org/tip/85e0d509654c2e2e58b29e50a883acd4c4e8807d Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 17 Feb 2017 15:00:54 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 17 Feb 2017 16:04:38 -0300
perf build: Add special fixdep cleaning rule
Ingo reported following build failure:
Quoted 31 lines · Ingo Molnar
So I had this oldish 32-bit 15.10 Ubuntu installation around (fully updated), and trying to build perf gave me:
deimos:~/tip/tools/perf> make
BUILD: Doing 'make -j4' parallel build
make[3]: *** No rule to make target '/usr/include/x86_64-linux-gnu/sys/types.h', needed by 'fixdep.o'. Stop. Makefile:42: recipe for target 'fixdep-in.o' failed
make[2]: *** [fixdep-in.o] Error 2/home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed
make[1]: *** [fixdep] Error 2
Makefile:68: recipe for target 'all' failed
make: *** [all] Error 2Now this got a bit better after I did a 'make mrproper' in the kernel tree:
deimos:~/tip/tools/perf> make
BUILD: Doing 'make -j4' parallel build
HOSTCC fixdep.o/home/mingo/tip/tools/build/fixdep: 1:/home/mingo/tip/tools/build/fixdep: Syntax error: "(" unexpected/home/mingo/tip/tools/build/Makefile.build:101: recipe for target 'fixdep.o' failed make[3]: *** [fixdep.o] Error 2
Makefile:42: recipe for target 'fixdep-in.o' failed
make[2]: *** [fixdep-in.o] Error 2/home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed make[1]: *** [fixdep] Error 2
Makefile:68: recipe for target 'all' failed
make: *** [all] Error 2After some digging it turns out that my 'fixdep' binary was 64-bit:
Quoted 8 lines
deimos:~/tip/tools/perf> file
/home/mingo/tip/tools/build/fixdep/home/mingo/tip/tools/build/fixdep: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter/lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d527f736b57b5ba47210fbcb562a3b52867d21c1, not strippedBut it did not get cleaned out by 'make clean'.
Only after I did a 'make clean' in
tools/itself, did it get built properly.
It shows we don't clean up properly the fixdep objects, so adding special rule for that.
--- tools/build/Makefile | 4 ++-- tools/build/Makefile.include | 3 +++ tools/perf/Makefile.perf | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-)
tools/build/Makefile +2 -2
@@ -35,8 +35,8 @@ all: $(OUTPUT)fixdep clean: $(call QUIET_CLEAN, fixdep) - $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete - $(Q)rm -f fixdep + $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete + $(Q)rm -f $(OUTPUT)fixdep $(OUTPUT)fixdep-in.o: FORCE $(Q)$(MAKE) $(build)=fixdep
tools/build/Makefile.include +3 -0
@@ -3,4 +3,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj fixdep: $(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep +fixdep-clean: + $(Q)$(MAKE) -C $(srctree)/tools/build clean + .PHONY: fixdep
tools/perf/Makefile.perf +2 -2
@@ -726,13 +726,13 @@ config-clean: $(call QUIET_CLEAN, config) $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null -clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean fixdep-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so $(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* \ - $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \ + $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ $(OUTPUT)pmu-events/pmu-events.c $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
Jiri Olsa
reviewerPATCH 2/5 perf tools: Move new_term arguments into struct parse_events_term template
In reply to Jiri OlsaWe need to add yet another parameter to new_term function in following patch, so it's better to move first all the current params into template struct parse_events_term and use it as a single argument.
--- tools/perf/util/parse-events.c | 69 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-)
tools/perf/util/parse-events.c +39 -30
@@ -2318,24 +2318,20 @@ int parse_events__is_hardcoded_term(struct parse_events_term *term)return term->type_term !=PARSE_EVENTS__TERM_TYPE_USER ; } -static int new_term (struct parse_events_term **_term,int type_val, -int type_term,char *config, -char *str,u64 num,int err_term,int err_val) +static int new_term (struct parse_events_term **_term, +struct parse_events_term *temp, +char *str,u64 num) {struct parse_events_term *term; - term =zalloc (sizeof (*term)); + term =malloc (sizeof (*term));if (!term)return -ENOMEM ; + *term = *temp;INIT_LIST_HEAD (&term->list); - term->type_val = type_val; - term->type_term = type_term; - term->config = config; - term->err_term = err_term; - term->err_val = err_val; -switch (type_val) { +switch (term->type_val) {case PARSE_EVENTS__TERM_TYPE_NUM : term->val.num = num;break ;
@@ -2358,10 +2354,15 @@ int parse_events_term__num(struct parse_events_term **term,YYLTYPE *loc_term = loc_term_;YYLTYPE *loc_val = loc_val_; -return new_term (term,PARSE_EVENTS__TERM_TYPE_NUM , type_term, - config,NULL , num, - loc_term ? loc_term->first_column :0 , - loc_val ? loc_val->first_column :0 ); +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_NUM , + .type_term = type_term, + .config = config, + .err_term = loc_term ? loc_term->first_column :0 , + .err_val = loc_val ? loc_val->first_column :0 , + }; + +return new_term (term, &temp,NULL , num); } int parse_events_term__str(struct parse_events_term **term,
@@ -2371,37 +2372,45 @@ int parse_events_term__str(struct parse_events_term **term,YYLTYPE *loc_term = loc_term_;YYLTYPE *loc_val = loc_val_; -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , type_term, - config, str,0 , - loc_term ? loc_term->first_column :0 , - loc_val ? loc_val->first_column :0 ); +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_STR , + .type_term = type_term, + .config = config, + .err_term = loc_term ? loc_term->first_column :0 , + .err_val = loc_val ? loc_val->first_column :0 , + }; + +return new_term (term, &temp, str,0 ); }int parse_events_term__sym_hw (struct parse_events_term **term,char *config,unsigned idx) {struct event_symbol *sym; +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_STR , + .type_term =PARSE_EVENTS__TERM_TYPE_USER , + .config = config ?: (char *)"event" , + };BUG_ON (idx >=PERF_COUNT_HW_MAX ); sym = &event_symbols_hw[idx]; -if (config) -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , -PARSE_EVENTS__TERM_TYPE_USER , config, - (char *) sym->symbol,0 ,0 ,0 ); -else -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , -PARSE_EVENTS__TERM_TYPE_USER , - (char *)"event" , (char *) sym->symbol, -0 ,0 ,0 ); +return new_term (term, &temp, (char *) sym->symbol,0 ); }int parse_events_term__clone (struct parse_events_term **new,struct parse_events_term *term) { -return new_term (new, term->type_val, term->type_term, term->config, - term->val.str, term->val.num, - term->err_term, term->err_val); +struct parse_events_term temp = { + .type_val = term->type_val, + .type_term = term->type_term, + .config = term->config, + .err_term = term->err_term, + .err_val = term->err_val, + }; + +return new_term (new, &temp, term->val.str, term->val.num); }void parse_events_terms__purge (struct list_head *terms)
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf tools: Move new_term arguments into struct parse_events_term template
perf tools: Move new_term arguments into struct parse_events_term template
Commit-ID: 67b49b38f7bd6f34319b540ce824d5697241b3a8 Gitweb: http://git.kernel.org/tip/67b49b38f7bd6f34319b540ce824d5697241b3a8 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 17 Feb 2017 15:00:55 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 17 Feb 2017 17:27:54 -0300
perf tools: Move new_term arguments into struct parse_events_term template
We need to add yet another parameter to new_term function in following patch, so it's better to move first all the current params into template struct parse_events_term and use it as a single argument.
--- tools/perf/util/parse-events.c | 69 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-)
tools/perf/util/parse-events.c +39 -30
@@ -2318,24 +2318,20 @@ int parse_events__is_hardcoded_term(struct parse_events_term *term)return term->type_term !=PARSE_EVENTS__TERM_TYPE_USER ; } -static int new_term (struct parse_events_term **_term,int type_val, -int type_term,char *config, -char *str,u64 num,int err_term,int err_val) +static int new_term (struct parse_events_term **_term, +struct parse_events_term *temp, +char *str,u64 num) {struct parse_events_term *term; - term =zalloc (sizeof (*term)); + term =malloc (sizeof (*term));if (!term)return -ENOMEM ; + *term = *temp;INIT_LIST_HEAD (&term->list); - term->type_val = type_val; - term->type_term = type_term; - term->config = config; - term->err_term = err_term; - term->err_val = err_val; -switch (type_val) { +switch (term->type_val) {case PARSE_EVENTS__TERM_TYPE_NUM : term->val.num = num;break ;
@@ -2358,10 +2354,15 @@ int parse_events_term__num(struct parse_events_term **term,YYLTYPE *loc_term = loc_term_;YYLTYPE *loc_val = loc_val_; -return new_term (term,PARSE_EVENTS__TERM_TYPE_NUM , type_term, - config,NULL , num, - loc_term ? loc_term->first_column :0 , - loc_val ? loc_val->first_column :0 ); +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_NUM , + .type_term = type_term, + .config = config, + .err_term = loc_term ? loc_term->first_column :0 , + .err_val = loc_val ? loc_val->first_column :0 , + }; + +return new_term (term, &temp,NULL , num); } int parse_events_term__str(struct parse_events_term **term,
@@ -2371,37 +2372,45 @@ int parse_events_term__str(struct parse_events_term **term,YYLTYPE *loc_term = loc_term_;YYLTYPE *loc_val = loc_val_; -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , type_term, - config, str,0 , - loc_term ? loc_term->first_column :0 , - loc_val ? loc_val->first_column :0 ); +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_STR , + .type_term = type_term, + .config = config, + .err_term = loc_term ? loc_term->first_column :0 , + .err_val = loc_val ? loc_val->first_column :0 , + }; + +return new_term (term, &temp, str,0 ); }int parse_events_term__sym_hw (struct parse_events_term **term,char *config,unsigned idx) {struct event_symbol *sym; +struct parse_events_term temp = { + .type_val =PARSE_EVENTS__TERM_TYPE_STR , + .type_term =PARSE_EVENTS__TERM_TYPE_USER , + .config = config ?: (char *)"event" , + };BUG_ON (idx >=PERF_COUNT_HW_MAX ); sym = &event_symbols_hw[idx]; -if (config) -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , -PARSE_EVENTS__TERM_TYPE_USER , config, - (char *) sym->symbol,0 ,0 ,0 ); -else -return new_term (term,PARSE_EVENTS__TERM_TYPE_STR , -PARSE_EVENTS__TERM_TYPE_USER , - (char *)"event" , (char *) sym->symbol, -0 ,0 ,0 ); +return new_term (term, &temp, (char *) sym->symbol,0 ); }int parse_events_term__clone (struct parse_events_term **new,struct parse_events_term *term) { -return new_term (new, term->type_val, term->type_term, term->config, - term->val.str, term->val.num, - term->err_term, term->err_val); +struct parse_events_term temp = { + .type_val = term->type_val, + .type_term = term->type_term, + .config = term->config, + .err_term = term->err_term, + .err_val = term->err_val, + }; + +return new_term (new, &temp, term->val.str, term->val.num); }void parse_events_terms__purge (struct list_head *terms)
Jiri Olsa
reviewerPATCH 3/5 perf tools: Fail on using multiple bits long terms without value
In reply to Jiri OlsaCurrently we allow not to specify value for numeric terms and we set them to value 1. This was originaly meant just for single bit terms to allow user to type:
$ perf record -e 'cpu/cpu-cycles,any'
instead of:
$ perf record -e 'cpu/cpu-cycles,any=1'
However it works also for multi bits terms like:
$ perf record -e 'cpu/event/' ls ... $ perf evlist -v ..., config: 0x1, ...
After discussion with Peter making such term usage to fail, like:
$ perf record -e 'cpu/event/' ls
event syntax error: 'cpu/event/'
\___ no value assigned for term
...--- tools/perf/util/parse-events.c | 2 ++ tools/perf/util/parse-events.h | 2 ++ tools/perf/util/parse-events.y | 14 +++++++------- tools/perf/util/pmu.c | 13 +++++++++++-- 4 files changed, 22 insertions(+), 9 deletions(-)
tools/perf/util/parse-events.c +2 -0
@@ -2349,6 +2349,7 @@ static int new_term(struct parse_events_term **_term,int parse_events_term__num (struct parse_events_term **term,int type_term,char *config,u64 num, +bool no_value,void *loc_term_,void *loc_val_) {YYLTYPE *loc_term = loc_term_;
@@ -2358,6 +2359,7 @@ int parse_events_term__num(struct parse_events_term **term, .type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_term = type_term, .config = config, + .no_value = no_value, .err_term = loc_term ? loc_term->first_column : 0, .err_val = loc_val ? loc_val->first_column : 0, };
tools/perf/util/parse-events.h +2 -0
@@ -94,6 +94,7 @@ struct parse_events_term {int type_term;struct list_head list;bool used; +bool no_value;/* error string indexes for within parsed string */ int err_term;
@@ -122,6 +123,7 @@ void parse_events__shrink_config_terms(void);int parse_events__is_hardcoded_term (struct parse_events_term *term);int parse_events_term__num (struct parse_events_term **term,int type_term,char *config,u64 num, +bool novalue,void *loc_term,void *loc_val); int parse_events_term__str(struct parse_events_term **term, int type_term, char *config, char *str,
tools/perf/util/parse-events.y +7 -7
@@ -252,7 +252,7 @@ PE_KERNEL_PMU_EVENT sep_dc if (!strcasecmp(alias->name, $1)) { ALLOC_LIST(head); ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, 1, &@1, NULL)); + $1, 1, false, &@1, NULL)); list_add_tail(&term->list, head); if (!parse_events_add_pmu(data, list,
@@ -282,7 +282,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc ALLOC_LIST(head); ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - &pmu_name, 1, &@1, NULL)); + &pmu_name, 1, false, &@1, NULL)); list_add_tail(&term->list, head); ALLOC_LIST(list);
@@ -548,7 +548,7 @@ PE_NAME '=' PE_VALUE struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, $3, &@1, &@3)); + $1, $3, false, &@1, &@3)); $$ = term; } |
@@ -566,7 +566,7 @@ PE_NAME struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, 1, &@1, NULL)); + $1, 1, true, &@1, NULL)); $$ = term; } |
@@ -591,7 +591,7 @@ PE_TERM '=' PE_VALUE { struct parse_events_term *term; - ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3)); + ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); $$ = term; } |
@@ -599,7 +599,7 @@ PE_TERM { struct parse_events_term *term; - ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL)); + ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); $$ = term; } |
@@ -620,7 +620,7 @@ PE_NAME array '=' PE_VALUE struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, $4, &@1, &@4)); + $1, $4, false, &@1, &@4)); term->array = $2; $$ = term; }
tools/perf/util/pmu.c +11 -2
@@ -834,9 +834,18 @@ static int pmu_config_term(struct list_head *formats,* Either directly use a numeric term, or try to translate string terms * using event parameters. */ -if (term->type_val ==PARSE_EVENTS__TERM_TYPE_NUM ) +if (term->type_val ==PARSE_EVENTS__TERM_TYPE_NUM ) { +if (term->no_value && +bitmap_weight (format->bits,PERF_PMU_FORMAT_BITS ) >1 ) { +if (err) { + err->idx = term->err_val; + err->str =strdup ("no value assigned for term" ); + } +return -EINVAL ; + } + val = term->val.num; -else if (term->type_val ==PARSE_EVENTS__TERM_TYPE_STR ) { + }else if (term->type_val ==PARSE_EVENTS__TERM_TYPE_STR ) {if (strcmp (term->val.str,"?" )) {if (verbose) { pr_info("Invalid sysfs entry %s=%s\n",
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf tools: Fail on using multiple bits long terms without value
perf tools: Fail on using multiple bits long terms without value
Commit-ID: 99e7138eb7897aa0ccc6661173ae2d7e79721e05 Gitweb: http://git.kernel.org/tip/99e7138eb7897aa0ccc6661173ae2d7e79721e05 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 17 Feb 2017 15:00:56 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 17 Feb 2017 17:28:22 -0300
perf tools: Fail on using multiple bits long terms without value
Currently we allow not to specify value for numeric terms and we set them to value 1. This was originaly meant just for single bit terms to allow user to type:
$ perf record -e 'cpu/cpu-cycles,any'
instead of:
$ perf record -e 'cpu/cpu-cycles,any=1'
However it works also for multi bits terms like:
$ perf record -e 'cpu/event/' ls ... $ perf evlist -v ..., config: 0x1, ...
After discussion with Peter we decided making such term usage to fail, like:
$ perf record -e 'cpu/event/' ls
event syntax error: 'cpu/event/'
\___ no value assigned for term
...--- tools/perf/util/parse-events.c | 2 ++ tools/perf/util/parse-events.h | 2 ++ tools/perf/util/parse-events.y | 14 +++++++------- tools/perf/util/pmu.c | 13 +++++++++++-- 4 files changed, 22 insertions(+), 9 deletions(-)
tools/perf/util/parse-events.c +2 -0
@@ -2349,6 +2349,7 @@ static int new_term(struct parse_events_term **_term,int parse_events_term__num (struct parse_events_term **term,int type_term,char *config,u64 num, +bool no_value,void *loc_term_,void *loc_val_) {YYLTYPE *loc_term = loc_term_;
@@ -2358,6 +2359,7 @@ int parse_events_term__num(struct parse_events_term **term, .type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_term = type_term, .config = config, + .no_value = no_value, .err_term = loc_term ? loc_term->first_column : 0, .err_val = loc_val ? loc_val->first_column : 0, };
tools/perf/util/parse-events.h +2 -0
@@ -94,6 +94,7 @@ struct parse_events_term {int type_term;struct list_head list;bool used; +bool no_value;/* error string indexes for within parsed string */ int err_term;
@@ -122,6 +123,7 @@ void parse_events__shrink_config_terms(void);int parse_events__is_hardcoded_term (struct parse_events_term *term);int parse_events_term__num (struct parse_events_term **term,int type_term,char *config,u64 num, +bool novalue,void *loc_term,void *loc_val); int parse_events_term__str(struct parse_events_term **term, int type_term, char *config, char *str,
tools/perf/util/parse-events.y +7 -7
@@ -252,7 +252,7 @@ PE_KERNEL_PMU_EVENT sep_dc if (!strcasecmp(alias->name, $1)) { ALLOC_LIST(head); ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, 1, &@1, NULL)); + $1, 1, false, &@1, NULL)); list_add_tail(&term->list, head); if (!parse_events_add_pmu(data, list,
@@ -282,7 +282,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc ALLOC_LIST(head); ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - &pmu_name, 1, &@1, NULL)); + &pmu_name, 1, false, &@1, NULL)); list_add_tail(&term->list, head); ALLOC_LIST(list);
@@ -548,7 +548,7 @@ PE_NAME '=' PE_VALUE struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, $3, &@1, &@3)); + $1, $3, false, &@1, &@3)); $$ = term; } |
@@ -566,7 +566,7 @@ PE_NAME struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, 1, &@1, NULL)); + $1, 1, true, &@1, NULL)); $$ = term; } |
@@ -591,7 +591,7 @@ PE_TERM '=' PE_VALUE { struct parse_events_term *term; - ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3)); + ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); $$ = term; } |
@@ -599,7 +599,7 @@ PE_TERM { struct parse_events_term *term; - ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL)); + ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); $$ = term; } |
@@ -620,7 +620,7 @@ PE_NAME array '=' PE_VALUE struct parse_events_term *term; ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, - $1, $4, &@1, &@4)); + $1, $4, false, &@1, &@4)); term->array = $2; $$ = term; }
tools/perf/util/pmu.c +11 -2
@@ -834,9 +834,18 @@ static int pmu_config_term(struct list_head *formats,* Either directly use a numeric term, or try to translate string terms * using event parameters. */ -if (term->type_val ==PARSE_EVENTS__TERM_TYPE_NUM ) +if (term->type_val ==PARSE_EVENTS__TERM_TYPE_NUM ) { +if (term->no_value && +bitmap_weight (format->bits,PERF_PMU_FORMAT_BITS ) >1 ) { +if (err) { + err->idx = term->err_val; + err->str =strdup ("no value assigned for term" ); + } +return -EINVAL ; + } + val = term->val.num; -else if (term->type_val ==PARSE_EVENTS__TERM_TYPE_STR ) { + }else if (term->type_val ==PARSE_EVENTS__TERM_TYPE_STR ) {if (strcmp (term->val.str,"?" )) {if (verbose) { pr_info("Invalid sysfs entry %s=%s\n",
Jiri Olsa
reviewerPATCH 4/5 perf stat: Add -a as a default target
In reply to Jiri OlsaBoris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a). ...
--- tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/builtin-stat.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-stat.txt +1 -1
@@ -63,7 +63,7 @@ report:: -a:: --all-cpus:: - system-wide collection from all CPUs + system-wide collection from all CPUs (default if no target is specified) -c:: --scale::
tools/perf/builtin-stat.c +4 -2
@@ -2445,8 +2445,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; -if (!argc &&target__none (&target)) -usage_with_options (stat_usage, stat_options); +if (!argc &&target__none (&target)) { +pr_warning ("Warning: No target specified, setting system-wide collection (-a).\n" ); + target.system_wide = true; + }if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/5] perf stat: Add -a as a default target
Em Fri, Feb 17, 2017 at 03:00:57PM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a).
Humm, would be interesting to disable this after a few warnings? Just one?
BTW, this is how 'perf trace' works since day one, i.e. no target means system wide syscall tracing.
- Arnaldo
Quoted 46 lines
...
Requested-by Borislav Petkov <[email protected]>Signed-off-by Jiri Olsa <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Borislav Petkov <[email protected]>--- tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/builtin-stat.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)tools/perf/Documentation/perf-stat.txt +1
-1@@ -63,7 +63,7 @@ report:: -a:: --all-cpus:: - system-wide collection from all CPUs + system-wide collection from all CPUs (default if no target is specified) -c:: --scale::tools/perf/builtin-stat.c +4
-2@@ -2445,8 +2445,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; -if (!argc &&target__none (&target)) -usage_with_options (stat_usage, stat_options); +if (!argc &&target__none (&target)) { +pr_warning ("Warning: No target specified, setting system-wide collection (-a).\n" ); + target.system_wide = true; + }if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );Signature · 1 line
2.7.4
Re: [PATCH 4/5] perf stat: Add -a as a default target
Quoted 10 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 17, 2017 at 03:00:57PM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a).Humm, would be interesting to disable this after a few warnings? Just one?
not sure it's good idea to keep the count of that somewhere.. how about i make the warning smaller ;-)
# perf stat Forced system wide target. ...
Quoted 3 lines
BTW, this is how 'perf trace' works since day one, i.e. no target means system wide syscall tracing.
or we could omit the warning completely as probably perf trace does
thanks,
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/5] perf stat: Add -a as a default target
Em Fri, Feb 17, 2017 at 03:33:27PM +0100, Jiri Olsa escreveu:
Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
Em Fri, Feb 17, 2017 at 03:00:57PM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a).Humm, would be interesting to disable this after a few warnings? Just one?
not sure it's good idea to keep the count of that somewhere.. how about i make the warning smaller ;-)
Quoted 8 lines
# perf stat Forced system wide target. ...Quoted 2 lines
BTW, this is how 'perf trace' works since day one, i.e. no target means system wide syscall tracing.
or we could omit the warning completely as probably perf trace does
I think that we should have some note on the Documentation (have you added it?) and be done with it.
Another thing possiblity my mind, print that at the end? like:
perf record
^C[ perf record: Woken up 1 times to write data - system wide samples ] [ perf record: Captured and wrote 1.738 MB perf.data (7565 samples) ]
----------
Then people will thing, hey, so now it does systemwide samples when I pass no target, I don't have anymore to type _three_ keys! cool! :-)
- Arnaldo
Re: [PATCH 4/5] perf stat: Add -a as a default target
Quoted 30 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 17, 2017 at 03:33:27PM +0100, Jiri Olsa escreveu:
Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
Em Fri, Feb 17, 2017 at 03:00:57PM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a).Humm, would be interesting to disable this after a few warnings? Just one?
not sure it's good idea to keep the count of that somewhere.. how about i make the warning smaller ;-)
Quoted 8 lines
# perf stat Forced system wide target. ...Quoted 2 lines
BTW, this is how 'perf trace' works since day one, i.e. no target means system wide syscall tracing.
or we could omit the warning completely as probably perf trace does
I think that we should have some note on the Documentation (have you added it?) and be done with it.
Another thing possiblity my mind, print that at the end? like:
Quoted 8 lines
perf record
^C[ perf record: Woken up 1 times to write data - system wide samples ] [ perf record: Captured and wrote 1.738 MB perf.data (7565 samples) ]----------
Then people will thing, hey, so now it does systemwide samples when I pass no target, I don't have anymore to type _three_ keys! cool! :-)
ok, I'll check on that and send new version for the last 2 patches
thanks,
jirka
PATCH v2 4/5 perf stat: Add -a as a default target
In reply to Arnaldo Carvalho de MeloQuoted 30 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 17, 2017 at 03:33:27PM +0100, Jiri Olsa escreveu:
Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
Em Fri, Feb 17, 2017 at 03:00:57PM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
# perf stat Warning: No target specified, setting system-wide collection (-a).Humm, would be interesting to disable this after a few warnings? Just one?
not sure it's good idea to keep the count of that somewhere.. how about i make the warning smaller ;-)
Quoted 8 lines
# perf stat Forced system wide target. ...Quoted 2 lines
BTW, this is how 'perf trace' works since day one, i.e. no target means system wide syscall tracing.
or we could omit the warning completely as probably perf trace does
I think that we should have some note on the Documentation (have you added it?) and be done with it.
Another thing possiblity my mind, print that at the end? like:
Quoted 8 lines
perf record
^C[ perf record: Woken up 1 times to write data - system wide samples ] [ perf record: Captured and wrote 1.738 MB perf.data (7565 samples) ]----------
Then people will thing, hey, so now it does systemwide samples when I pass no target, I don't have anymore to type _three_ keys! cool! :-)
ok, posting the change with no warning
jirka
---
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.
Running 'perf stat' will now collect system wide data.
--- tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/builtin-stat.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-stat.txt +1 -1
@@ -63,7 +63,7 @@ report:: -a:: --all-cpus:: - system-wide collection from all CPUs + system-wide collection from all CPUs (default if no target is specified) -c:: --scale::
tools/perf/builtin-stat.c +2 -1
@@ -2445,8 +2445,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; +/* Make system wide (-a) the default target. */ if (!argc &&target__none (&target)) -usage_with_options (stat_usage, stat_options); + target.system_wide = true;if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );
Signature · 1 line
2.7.4
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 7 lines · Jiri Olsa
---
Boris asked for default -a option in case we monitor only uncore events. While implementing that I thought it might be actually useful to make it overall default.Running 'perf stat' will now collect system wide data.
Quoted 7 lines
Requested-by Borislav Petkov <[email protected]>Signed-off-by Jiri Olsa <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Peter Zijlstra <[email protected]>
LGTM.
Thanks.
Signature · 1 line
Sent from a small device: formatting sux and brevity is inevitable.
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 3 lines · Boris Petkov
LGTM.
Acked-by me
Well, it looks good but actually trying it is a different story. For example:
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/ sleep 1
still says <not supported> because argc is not 0.
So how about the below diff instead?
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/
without args dumps the usage message and
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/ sleep 1
actually does the system-wide thing:
Performance counter stats for 'system wide':
196,469 amd_nb/event=0xe0,umask=0x1f/
1.001815180 seconds time elapsedHmmm?
tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/builtin-stat.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-stat.txt +1 -1
@@ -63,7 +63,7 @@ report:: -a:: --all-cpus:: - system-wide collection from all CPUs + system-wide collection from all CPUs (default if no target is specified) -c:: --scale::
tools/perf/builtin-stat.c +6 -2
@@ -2445,8 +2445,12 @@ int cmd_stat(int argc, const char **argv }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; -if (!argc &&target__none (&target)) -usage_with_options (stat_usage, stat_options); +/* Make system wide (-a) the default target. */ +if (target__none (&target)) { +if (!argc) +usage_with_options (stat_usage, stat_options); + target.system_wide = true; + }if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 22 lines · Borislav Petkov
Quoted 3 lines · Boris Petkov
LGTM.
Acked-by meWell, it looks good but actually trying it is a different story. For example:
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/ sleep 1still says <not supported> because argc is not 0.
So how about the below diff instead?
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/without args dumps the usage message and
$ ./perf stat -e amd_nb/event=0xe0,umask=0x1f/ sleep 1actually does the system-wide thing:
Quoted 7 lines
Performance counter stats for 'system wide':
196,469 amd_nb/event=0xe0,umask=0x1f/ 1.001815180 seconds time elapsedHmmm?
ugh, I thought it was too easy ;-)
it looks good to me
thanks,
jirka
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Btw, I received your mail just now - probably greylisting...
Quoted 3 lines · Arnaldo Carvalho de Melo
Isn't this confusing, i.e. people runnin 'tool workload' can be lead to think that the events reported took place just when the workload was running, i.e. on the same cpu and while it was being scheduled?
That's a good point.
Quoted 3 lines
I understand the desire to avoid asking people to use -a, i.e. if it only makes sense as system wide, hey, do it as system wide, but can't this be confusing?
Well, I did
tool workload
and it said <not supported>. Now, if I'm the only one to stare puzzled at this and wonder why it says "not supported", then sure, I know now that I should use -a.
But if other users are as confused as me, you probably want to tell them to try -a too, no?
IOW, we probably could extend my other patch which says that people should try to disable the HW NMI watchdog to say "try using -a for uncore-only events" when it detects <not supported>.
Thoughts?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Arnaldo Carvalho de Melo
maintainerRe: [PATCHv2 4/5] perf stat: Add -a as a default target
Em Mon, Feb 20, 2017 at 09:31:49PM +0100, Borislav Petkov escreveu:
Quoted 13 lines
Btw, I received your mail just now - probably greylisting...
Quoted 3 lines · Arnaldo Carvalho de Melo
Isn't this confusing, i.e. people runnin 'tool workload' can be lead to think that the events reported took place just when the workload was running, i.e. on the same cpu and while it was being scheduled?
That's a good point.
Quoted 3 lines
I understand the desire to avoid asking people to use -a, i.e. if it only makes sense as system wide, hey, do it as system wide, but can't this be confusing?
Quoted 5 lines
Well, I did
tool workload
and it said <not supported>. Now, if I'm the only one to stare puzzled
Well, this one should be read (and written in the tool output as):
<not supported in workload only mode, try system wide, using -a>
Quoted 9 lines
at this and wonder why it says "not supported", then sure, I know now that I should use -a.
But if other users are as confused as me, you probably want to tell them to try -a too, no?
IOW, we probably could extend my other patch which says that people should try to disable the HW NMI watchdog to say "try using -a for uncore-only events" when it detects <not supported>.
Right, the ENOTSUPP in this case needs to be properly expanded into something meaningful, as suggested above.
Quoted 8 lines
Thoughts?
Signature · 4 lines
Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 3 lines · Arnaldo Carvalho de Melo
Well, this one should be read (and written in the tool output as):
<not supported in workload only mode, try system wide, using -a>
Do you want to change that CNTR_NOT_SUPPORTED string unconditionally to something like above?
Because perf_evsel.supported seems like it means that counter is not supported but not necessarily only because of the missing -a for an uncore event, AFAICT. I could be wrong.
Quoted 2 lines
Right, the ENOTSUPP in this case needs to be properly expanded into something meaningful, as suggested above.
I dumped errno in __run_perf_stat():
./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/ sleep 1 Using CPUID AuthenticAMD-21-2
Warning:
amd_nb/event=0xe0,umask=0x1f/ event is not supported by the kernel: 22.
It is -EINVAL and the syscall returns -EINVAL in bunch of places so I'm guessing this might not be a good way to match the retval to the proper error message.
Peterz said something about scanning all events supplied by -e and if all are uncore, to set -a automatically. Can we do that?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 22 lines · Borislav Petkov
Quoted 3 lines · Arnaldo Carvalho de Melo
Well, this one should be read (and written in the tool output as):
<not supported in workload only mode, try system wide, using -a>
Do you want to change that
CNTR_NOT_SUPPORTEDstring unconditionally to something like above?Because perf_evsel.supported seems like it means that counter is not supported but not necessarily only because of the missing -a for an uncore event, AFAICT. I could be wrong.
Quoted 2 lines
Right, the ENOTSUPP in this case needs to be properly expanded into something meaningful, as suggested above.
I dumped errno in
__run_perf_stat():./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/ sleep 1 Using CPUID AuthenticAMD-21-2
Warning:
amd_nb/event=0xe0,umask=0x1f/ event is not supported by the kernel: 22.
Quoted 6 lines
It is
-EINVALand the syscall returns-EINVALin bunch of places so I'm guessing this might not be a good way to match the retval to the proper error message.Peterz said something about scanning all events supplied by -e and if all are uncore, to set -a automatically. Can we do that?
right, so that's different from what we actually did.. ;-)
I'll check on this one.. might not be as straight forward, because some uncore events might have already cpumask limit
jirka
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 27 lines · Jiri Olsa
Quoted 26 lines · Borislav Petkov
Quoted 3 lines · Arnaldo Carvalho de Melo
Well, this one should be read (and written in the tool output as):
<not supported in workload only mode, try system wide, using -a>
Do you want to change that
CNTR_NOT_SUPPORTEDstring unconditionally to something like above?Because perf_evsel.supported seems like it means that counter is not supported but not necessarily only because of the missing -a for an uncore event, AFAICT. I could be wrong.
Quoted 2 lines
Right, the ENOTSUPP in this case needs to be properly expanded into something meaningful, as suggested above.
I dumped errno in
__run_perf_stat():./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/ sleep 1 Using CPUID AuthenticAMD-21-2
Warning:
amd_nb/event=0xe0,umask=0x1f/ event is not supported by the kernel: 22.It is
-EINVALand the syscall returns-EINVALin bunch of places so I'm guessing this might not be a good way to match the retval to the proper error message.
Quoted 7 lines
Quoted 2 lines
Peterz said something about scanning all events supplied by -e and if all are uncore, to set -a automatically. Can we do that?
right, so that's different from what we actually did.. ;-)
I'll check on this one.. might not be as straight forward, because some uncore events might have already cpumask limit
could you please test this change?
thanks,
jirka
---
tools/perf/arch/x86/util/pmu.c +1 -0
@@ -14,5 +14,6 @@ struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybif (!strcmp (pmu->name,INTEL_BTS_PMU_NAME )) pmu->selectable = true;#endif + pmu->system_wide =strcmp (pmu->name,"cpu" );return NULL ; }
tools/perf/builtin-stat.c +22 -3
@@ -2339,6 +2339,27 @@ static int __cmd_report(int argc, const char **argv)return 0 ; } +static void setup_system_wide (int argc) +{ +/* +* Make system wide (-a) the default target +* or change the target to system_wide if +* all the counters are system_ wide. +*/ +if (!argc &&target__none (&target)) + target.system_wide = true; +else { +struct perf_evsel *counter; + +evlist__for_each_entry (evsel_list, counter) { +if (!counter->system_wide) +return ; + } + + target.system_wide = true; + } +} +int cmd_stat (int argc,const char **argv,const char *prefix__maybe_unused ) {const char *const stat_usage[] = {
@@ -2445,9 +2466,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; -/* Make system wide (-a) the default target. */ -if (!argc &&target__none (&target)) - target.system_wide = true; +setup_system_wide (argc);if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );
tools/perf/util/parse-events.c +1 -0
@@ -1254,6 +1254,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data, evsel->scale = info.scale; evsel->per_pkg = info.per_pkg; evsel->snapshot = info.snapshot; + evsel->system_wide = pmu->system_wide; }return evsel ?0 : -ENOMEM ;
tools/perf/util/pmu.h +1 -0
@@ -21,6 +21,7 @@ struct perf_pmu {char *name;__u32 type;bool selectable; +bool system_wide;struct perf_event_attr *default_config;struct cpu_map *cpus;struct list_head format;/* HEAD struct perf_pmu_format -> list */
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 1 line · Jiri Olsa
could you please test this change?
LGTM, thanks!
$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 249356 1002053637 1002053637
Performance counter stats for 'system wide':
249,356 amd_nb/event=0xe0,umask=0x1f/
1.002080419 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,cycles sleep 1 Using CPUID AuthenticAMD-21-2 Warning: amd_nb/event=0xe0,umask=0x1f/ event is not supported by the kernel. failed to read counter amd_nb/event=0xe0,umask=0x1f/ amd_nb/event=0xe0,umask=0x1f/: 0 0 0 cycles: 1223719 815034 815034
Performance counter stats for 'sleep 1':
<not supported> amd_nb/event=0xe0,umask=0x1f/
1,223,719 cycles
1.001679931 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 262994 1001697720 1001697720 amd_nb/event=0xe1,umask=0x3/: 0 1001701216 1001701216
Performance counter stats for 'system wide':
262,994 amd_nb/event=0xe0,umask=0x1f
0 amd_nb/event=0xe1,umask=0x3/
1.001718951 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/,amd_nb/event=0xe2,umask=0x3/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 203936 1001654831 1001654831 amd_nb/event=0xe1,umask=0x3/: 0 1001657636 1001657636 amd_nb/event=0xe2,umask=0x3/: 988016 1001657991 1001657991
Performance counter stats for 'system wide':
203,936 amd_nb/event=0xe0,umask=0x1f/
0 amd_nb/event=0xe1,umask=0x3/
988,016 amd_nb/event=0xe2,umask=0x3/1.001681434 seconds time elapsed
$ ./perf stat -v -a -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/,amd_nb/event=0xe2,umask=0x3/,cycles sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 365803 1001738673 1001738673 amd_nb/event=0xe1,umask=0x3/: 0 1001736790 1001736790 amd_nb/event=0xe2,umask=0x3/: 1884159 1001731876 1001731876 cycles: 156820391 8014227609 8014227609
Performance counter stats for 'system wide':
365,803 amd_nb/event=0xe0,umask=0x1f/
0 amd_nb/event=0xe1,umask=0x3/
1,884,159 amd_nb/event=0xe2,umask=0x3/
156,820,391 cycles1.001963906 seconds time elapsed
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Arnaldo Carvalho de Melo
maintainerRe: [PATCHv2 4/5] perf stat: Add -a as a default target
Em Tue, Feb 21, 2017 at 12:20:28PM +0100, Borislav Petkov escreveu:
Quoted 4 lines · Jiri Olsa
Quoted 1 line
could you please test this change?
LGTM, thanks!
Only one remark about a misleading warning, that is not a warning, is an error, as its mere presence prevents what was asked for from being performed.
Quoted 6 lines
$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 249356 1002053637 1002053637Performance counter stats for 'system wide':
Quoted 7 lines
249,356 amd_nb/event=0xe0,umask=0x1f/ 1.002080419 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,cycles sleep 1 Using CPUID AuthenticAMD-21-2 Warning:
^^^^^^^
^^^^^^^
Error:
^^^^^^^
^^^^^^^
Quoted 1 line
amd_nb/event=0xe0,umask=0x1f/ event is not supported by the kernel.
in system wide mode.
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^It _is_ supported by the kernel, and by the hardware, its just that it is not supported in system wide mode, that BTW, in the case above, the user doesn't even asked for (-a wasn't in the command line).
Quoted 58 lines
failed to read counter amd_nb/event=0xe0,umask=0x1f/ amd_nb/event=0xe0,umask=0x1f/: 0 0 0
cycles: 1223719 815034 815034Performance counter stats for 'sleep 1':
<not supported> amd_nb/event=0xe0,umask=0x1f/ 1,223,719 cycles 1.001679931 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 262994 1001697720 1001697720 amd_nb/event=0xe1,umask=0x3/: 0 1001701216 1001701216Performance counter stats for 'system wide':
262,994 amd_nb/event=0xe0,umask=0x1f 0 amd_nb/event=0xe1,umask=0x3/ 1.001718951 seconds time elapsed$ ./perf stat -v -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/,amd_nb/event=0xe2,umask=0x3/ sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 203936 1001654831 1001654831 amd_nb/event=0xe1,umask=0x3/: 0 1001657636 1001657636 amd_nb/event=0xe2,umask=0x3/: 988016 1001657991 1001657991Performance counter stats for 'system wide':
203,936 amd_nb/event=0xe0,umask=0x1f/ 0 amd_nb/event=0xe1,umask=0x3/ 988,016 amd_nb/event=0xe2,umask=0x3/1.001681434 seconds time elapsed$ ./perf stat -v -a -e amd_nb/event=0xe0,umask=0x1f/,amd_nb/event=0xe1,umask=0x3/,amd_nb/event=0xe2,umask=0x3/,cycles sleep 1 Using CPUID AuthenticAMD-21-2 amd_nb/event=0xe0,umask=0x1f/: 365803 1001738673 1001738673 amd_nb/event=0xe1,umask=0x3/: 0 1001736790 1001736790 amd_nb/event=0xe2,umask=0x3/: 1884159 1001731876 1001731876 cycles: 156820391 8014227609 8014227609Performance counter stats for 'system wide':
365,803 amd_nb/event=0xe0,umask=0x1f/ 0 amd_nb/event=0xe1,umask=0x3/ 1,884,159 amd_nb/event=0xe2,umask=0x3/ 156,820,391 cycles1.001963906 seconds time elapsedSignature · 4 lines
Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Re: [PATCHv2 4/5] perf stat: Add -a as a default target
Quoted 3 lines · Arnaldo Carvalho de Melo
It _is_ supported by the kernel, and by the hardware, its just that it is not supported in system wide mode, that BTW, in the case above, the user doesn't even asked for (-a wasn't in the command line).
Well, that warning is issued for a bunch of errno's. Lumping them all together is probably not what you want.
Also, EINVAL for example, as I noted earlier, can be issued for a variety of conditions...
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Arnaldo Carvalho de Melo
maintainerRe: [PATCHv2 4/5] perf stat: Add -a as a default target
Em Tue, Feb 21, 2017 at 03:05:44PM +0100, Borislav Petkov escreveu:
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 3 lines
It _is_ supported by the kernel, and by the hardware, its just that it is not supported in system wide mode, that BTW, in the case above, the user doesn't even asked for (-a wasn't in the command line).
Well, that warning is issued for a bunch of errno's. Lumping them all together is probably not what you want.
Also, EINVAL for example, as I noted earlier, can be issued for a variety of conditions...
That is well understood, but it doesn't prevents us from trying to, with the context in mind, disambiguate that value into meaningful messages, that ends up being possible to a great degree, see, for instance:
perf_evsel__open_strerror()
It will take the errno and internal evsel state to try to provide a better error message. So, if it is a uncore event and it the error when trying to open it is EINVAL and it evsel->system_wide is not set...
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf stat: Add -a as default target
In reply to Jiri Olsaperf stat: Add -a as default target
Commit-ID: 0d79f8b93187c771b6971acfaba67f4e2f1e0710 Gitweb: http://git.kernel.org/tip/0d79f8b93187c771b6971acfaba67f4e2f1e0710 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 17 Feb 2017 18:00:34 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 17 Feb 2017 17:31:10 -0300
perf stat: Add -a as default target
Boris asked for default -a option in case we monitor only uncore events.
While implementing that I thought it might be actually useful to make it overall default.
Running 'perf stat' will now collect system wide data.
Committer note:
Testing it:
# perf stat ^C Performance counter stats for 'system wide':
3571.559178 cpu-clock (msec) # 4.000 CPUs utilized
3,346 context-switches # 0.937 K/sec
277 cpu-migrations # 0.078 K/sec
57,271 page-faults # 0.016 M/sec
4,535,633,835 cycles # 1.270 GHz
6,389,736,516 instructions # 1.41 insn per cycle
1,541,293,875 branches # 431.547 M/sec
14,526,396 branch-misses # 0.94% of all branches0.892950118 seconds time elapsed
#
--- tools/perf/Documentation/perf-stat.txt | 2 +- tools/perf/builtin-stat.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-stat.txt +1 -1
@@ -63,7 +63,7 @@ report:: -a:: --all-cpus:: - system-wide collection from all CPUs + system-wide collection from all CPUs (default if no target is specified) -c:: --scale::
tools/perf/builtin-stat.c +2 -1
@@ -2445,8 +2445,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) }else if (big_num_opt ==0 )/* User passed --no-big-num */ big_num = false; +/* Make system wide (-a) the default target. */ if (!argc &&target__none (&target)) -usage_with_options (stat_usage, stat_options); + target.system_wide = true;if (run_count <0 ) {pr_err ("Run count must be a positive number\n" );
Jiri Olsa
reviewerPATCH 5/5 perf record: Add -a as a default target
In reply to Jiri OlsaAdding system wide (-a) option as a default target if non is specified.
# perf record Warning: No target specified, setting system-wide collection (-a). ...
--- tools/perf/Documentation/perf-record.txt | 2 +- tools/perf/builtin-record.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-record.txt +1 -1
@@ -157,7 +157,7 @@ OPTIONS -a:: --all-cpus:: - System-wide collection from all CPUs. + System-wide collection from all CPUs (default if no target is specified). -p:: --pid=::
tools/perf/builtin-record.c +4 -2
@@ -1677,8 +1677,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options (argc, argv, record_options, record_usage,PARSE_OPT_STOP_AT_NON_OPTION ); -if (!argc &&target__none (&rec->opts.target)) -usage_with_options (record_usage, record_options); +if (!argc &&target__none (&rec->opts.target)) { +pr_warning ("Warning: No target specified, setting system-wide collection (-a).\n" ); + rec->opts.target.system_wide = true; + }if (nr_cgroups && !rec->opts.target.system_wide) { usage_with_options_msg(record_usage, record_options,
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 5/5] perf record: Add -a as a default target
Em Fri, Feb 17, 2017 at 03:00:58PM +0100, Jiri Olsa escreveu:
Quoted 5 lines
Adding system wide (-a) option as a default target if non is specified.
# perf record Warning: No target specified, setting system-wide collection (-a).
Ditto, this warning will get annoying after a while...
Quoted 44 lines
...
Signed-off-by Jiri Olsa <[email protected]>Cc David Ahern <[email protected]>Cc Namhyung Kim <[email protected]>Cc Peter Zijlstra <[email protected]>--- tools/perf/Documentation/perf-record.txt | 2 +- tools/perf/builtin-record.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)tools/perf/Documentation/perf-record.txt +1
-1@@ -157,7 +157,7 @@ OPTIONS -a:: --all-cpus:: - System-wide collection from all CPUs. + System-wide collection from all CPUs (default if no target is specified). -p:: --pid=::tools/perf/builtin-record.c +4
-2@@ -1677,8 +1677,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options (argc, argv, record_options, record_usage,PARSE_OPT_STOP_AT_NON_OPTION ); -if (!argc &&target__none (&rec->opts.target)) -usage_with_options (record_usage, record_options); +if (!argc &&target__none (&rec->opts.target)) { +pr_warning ("Warning: No target specified, setting system-wide collection (-a).\n" ); + rec->opts.target.system_wide = true; + }if (nr_cgroups && !rec->opts.target.system_wide) { usage_with_options_msg(record_usage, record_options,Signature · 1 line
2.7.4
Re: [PATCH 5/5] perf record: Add -a as a default target
Quoted 8 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 17, 2017 at 03:00:58PM +0100, Jiri Olsa escreveu:
Quoted 5 lines
Adding system wide (-a) option as a default target if non is specified.
# perf record Warning: No target specified, setting system-wide collection (-a).Ditto, this warning will get annoying after a while...
ok, posting the change with no warning
jirka
---
Adding system wide (-a) option as a default target if non is specified.
Running 'perf record' will now collect system wide data.
--- tools/perf/Documentation/perf-record.txt | 2 +- tools/perf/builtin-record.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-record.txt +1 -1
@@ -157,7 +157,7 @@ OPTIONS -a:: --all-cpus:: - System-wide collection from all CPUs. + System-wide collection from all CPUs (default if no target is specified). -p:: --pid=::
tools/perf/builtin-record.c +3 -1
@@ -1677,8 +1677,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options (argc, argv, record_options, record_usage,PARSE_OPT_STOP_AT_NON_OPTION ); + +/* Make system wide (-a) the default target. */ if (!argc &&target__none (&rec->opts.target)) -usage_with_options (record_usage, record_options); + rec->opts.target.system_wide = true;if (nr_cgroups && !rec->opts.target.system_wide) { usage_with_options_msg(record_usage, record_options,
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf record: Add -a as default target
perf record: Add -a as default target
Commit-ID: 483635a9d0802d5ffbe402ceac5b93ddb2acb138 Gitweb: http://git.kernel.org/tip/483635a9d0802d5ffbe402ceac5b93ddb2acb138 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 17 Feb 2017 18:00:18 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 17 Feb 2017 17:32:38 -0300
perf record: Add -a as default target
Running 'perf record' with no target (-a, -p, -t, etc) will now collect system wide data.
Commiter notes:
Testing it:
[root@jouet ~]# perf record
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.351 MB perf.data (366 samples) ] #
is equivalent to:
# perf record -a ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 1.411 MB perf.data (978 samples) ] #
--- tools/perf/Documentation/perf-record.txt | 2 +- tools/perf/builtin-record.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-record.txt +1 -1
@@ -157,7 +157,7 @@ OPTIONS -a:: --all-cpus:: - System-wide collection from all CPUs. + System-wide collection from all CPUs (default if no target is specified). -p:: --pid=::
tools/perf/builtin-record.c +3 -1
@@ -1677,8 +1677,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options (argc, argv, record_options, record_usage,PARSE_OPT_STOP_AT_NON_OPTION ); + +/* Make system wide (-a) the default target. */ if (!argc &&target__none (&rec->opts.target)) -usage_with_options (record_usage, record_options); + rec->opts.target.system_wide = true;if (nr_cgroups && !rec->opts.target.system_wide) { usage_with_options_msg(record_usage, record_options,