Skip to contentSkip to conversation

perf tools: Fixes

PATCH In review Jiri Olsa 4 participants 16 messages Mar 24, 2016 – Apr 7, 2016 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover perf tools: Fixes

hi,
sending assorted fixes and leftover from previous mem patchset.

Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes

thanks,
jirka
---
Jiri Olsa (6):
perf mem: Add --ldlat option
perf mem: Add -U/-K (--all-user/--all-kernel) options perf tools: Make hists__collapse_insert_entry static perf tools: Introduce trim function
perf tools: Unify -f/--force option documentation perf tests: Add test to check for event times

 tools/perf/Documentation/perf-annotate.txt |   2 +-
 tools/perf/Documentation/perf-diff.txt     |   2 +-
 tools/perf/Documentation/perf-mem.txt      |  11 +++++
 tools/perf/Documentation/perf-report.txt   |   2 +-
 tools/perf/Documentation/perf-script.txt   |   4 ++
 tools/perf/builtin-mem.c                   |  12 ++++-
 tools/perf/tests/Build                     |   1 +
 tools/perf/tests/builtin-test.c            |   4 ++
 tools/perf/tests/event-times.c             | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h                   |   1 +
 tools/perf/ui/browsers/hists.c             |   3 +-
 tools/perf/ui/stdio/hist.c                 |   3 +-
 tools/perf/util/hist.c                     |   5 +-
 tools/perf/util/hist.h                     |   2 -
 tools/perf/util/mem-events.c               |  17 ++++++-
 tools/perf/util/mem-events.h               |   1 +
 tools/perf/util/util.h                     |   5 ++
 17 files changed, 298 insertions(+), 13 deletions(-)
 create mode 100644 tools/perf/tests/event-times.c
author reviewer
#1 lore raw

PATCH 1/6 perf mem: Add --ldlat option

Adding --ldlat option to specify desired latency
for loads event.

Specify 50 as loads event latency:

  $ perf mem record -e ldlat-loads -v --ldlat 50 true
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P true
---
 tools/perf/Documentation/perf-mem.txt |  3 +++
 tools/perf/builtin-mem.c              |  1 +
 tools/perf/util/mem-events.c          | 17 ++++++++++++++++-
 tools/perf/util/mem-events.h          |  1 +
 4 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-mem.txt +3 -0
index 43310d8661fe..6676d2784733 100644
@@ -48,6 +48,9 @@ OPTIONS
 	option can be passed in record mode. It will be interpreted the same way as perf
 	record.
 
+--ldload::
+	Specify desired latency for loads event.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +1 -0
index 914f6fe192e3..bf0bfca5be20 100644
@@ -66,6 +66,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
 		     parse_record_events),
+	OPT_UINTEGER(0, "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
 	OPT_INCR('v', "verbose", &verbose,
 		 "be more verbose (show counter open errors, etc)"),
 	OPT_END()
tools/perf/util/mem-events.c +16 -1
index e6b01e6f70a0..3ff60f08a778 100644
@@ -10,10 +10,12 @@
 #include "debug.h"
 #include "symbol.h"
 
+unsigned int perf_mem_events__loads_ldlat = 30;
+
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
 struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
-	E("ldlat-loads",	"cpu/mem-loads,ldlat=30/P",	"mem-loads"),
+	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"mem-stores"),
 	E("stlb-miss-loads",	"cpu/mem-stlb-miss-loads/P",	"mem-stlb-miss-loads"),
 	E("stlb-miss-stores",	"cpu/mem-stlb-miss-stores/P",	"mem-stlb-miss-stores"),
@@ -39,8 +41,21 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 
 #undef E
 
+static char mem_loads_name[100];
+static bool mem_loads_name__init;
+
 char *perf_mem_events__name(int i)
 {
+	if (i == PERF_MEM_EVENTS__LOAD) {
+		if (!mem_loads_name__init) {
+			mem_loads_name__init = true;
+			scnprintf(mem_loads_name, sizeof(mem_loads_name),
+				  perf_mem_events[i].name,
+				  perf_mem_events__loads_ldlat);
+		}
+		return mem_loads_name;
+	}
+
 	return (char *)perf_mem_events[i].name;
 }
 
tools/perf/util/mem-events.h +1 -0
index de88f4267cd1..939786ffab2a 100644
@@ -37,6 +37,7 @@ enum {
 };
 
 extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
+extern unsigned int perf_mem_events__loads_ldlat;
 
 int perf_mem_events__parse(const char *str);
 int perf_mem_events__init(void);
Signature · 1 line
2.4.3
#2 lore raw

Re: [PATCH 1/6] perf mem: Add --ldlat option

Em Thu, Mar 24, 2016 at 01:52:15PM +0100, Jiri Olsa escreveu:

Quoted 7 lines

Adding --ldlat option to specify desired latency
for loads event.

Specify 50 as loads event latency:

  $ perf mem record -e ldlat-loads -v --ldlat 50 true
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P true

We have all this infrastructure to set per-event settings, on the command line, and here we end up adding a separate command line option to do that? Why not something like:

perf mem record -e ldlat-loads/lat=50/ true

?

- Arnaldo

Quoted 89 lines
---
 tools/perf/Documentation/perf-mem.txt |  3 +++
 tools/perf/builtin-mem.c              |  1 +
 tools/perf/util/mem-events.c          | 17 ++++++++++++++++-
 tools/perf/util/mem-events.h          |  1 +
 4 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-mem.txt +3 -0
index 43310d8661fe..6676d2784733 100644
@@ -48,6 +48,9 @@ OPTIONS
 	option can be passed in record mode. It will be interpreted the same way as perf
 	record.
 
+--ldload::
+	Specify desired latency for loads event.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +1 -0
index 914f6fe192e3..bf0bfca5be20 100644
@@ -66,6 +66,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
 		     parse_record_events),
+	OPT_UINTEGER(0, "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
 	OPT_INCR('v', "verbose", &verbose,
 		 "be more verbose (show counter open errors, etc)"),
 	OPT_END()
tools/perf/util/mem-events.c +16 -1
index e6b01e6f70a0..3ff60f08a778 100644
@@ -10,10 +10,12 @@
 #include "debug.h"
 #include "symbol.h"
 
+unsigned int perf_mem_events__loads_ldlat = 30;
+
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
 struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
-	E("ldlat-loads",	"cpu/mem-loads,ldlat=30/P",	"mem-loads"),
+	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"mem-stores"),
 	E("stlb-miss-loads",	"cpu/mem-stlb-miss-loads/P",	"mem-stlb-miss-loads"),
 	E("stlb-miss-stores",	"cpu/mem-stlb-miss-stores/P",	"mem-stlb-miss-stores"),
@@ -39,8 +41,21 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 
 #undef E
 
+static char mem_loads_name[100];
+static bool mem_loads_name__init;
+
 char *perf_mem_events__name(int i)
 {
+	if (i == PERF_MEM_EVENTS__LOAD) {
+		if (!mem_loads_name__init) {
+			mem_loads_name__init = true;
+			scnprintf(mem_loads_name, sizeof(mem_loads_name),
+				  perf_mem_events[i].name,
+				  perf_mem_events__loads_ldlat);
+		}
+		return mem_loads_name;
+	}
+
 	return (char *)perf_mem_events[i].name;
 }
 
tools/perf/util/mem-events.h +1 -0
index de88f4267cd1..939786ffab2a 100644
@@ -37,6 +37,7 @@ enum {
 };
 
 extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
+extern unsigned int perf_mem_events__loads_ldlat;
 
 int perf_mem_events__parse(const char *str);
 int perf_mem_events__init(void);
Signature · 1 line
2.4.3
#3 lore raw

Re: [PATCH 1/6] perf mem: Add --ldlat option

Quoted 6 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 24, 2016 at 01:52:15PM +0100, Jiri Olsa escreveu:

Quoted 5 lines

Adding --ldlat option to specify desired latency
for loads event.

Specify 50 as loads event latency:

Quoted 8 lines
Quoted 2 lines
  $ perf mem record -e ldlat-loads -v --ldlat 50 true
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P true

We have all this infrastructure to set per-event settings, on the command line, and here we end up adding a separate command line option to do that? Why not something like:

perf mem record -e ldlat-loads/lat=50/ true

will check ;-)

thanks,
jirka

#4 lore raw

Re: [PATCH 1/6] perf mem: Add --ldlat option

Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 24, 2016 at 01:52:15PM +0100, Jiri Olsa escreveu:

Quoted 7 lines

Adding --ldlat option to specify desired latency
for loads event.

Specify 50 as loads event latency:

  $ perf mem record -e ldlat-loads -v --ldlat 50 true
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P true
Quoted 7 lines
Quoted 5 lines

We have all this infrastructure to set per-event settings, on the command line, and here we end up adding a separate command line option to do that? Why not something like:

perf mem record -e ldlat-loads/lat=50/ true

will check ;-)

sry for delay..

the thing is, that we can already do that via record command:
perf record -e "cpu/mem-loads,ldlat=30/" ls

but this option is in perf mem command, which provides the way to use short config:

   $ perf mem record --ldlat 50 ls

and adds also '-W -d' options for record command:

  $ ./perf mem record -v --ldlat 50 ls 
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P ls 

jirka

author reviewer
#5 lore raw

PATCH 2/6 perf mem: Add -U/-K (--all-user/--all-kernel) options

In reply to Jiri Olsa

Add -U/-K (--all-user/--all-kernel) options to use the perf record --all-user/--all-kernel options.

---
 tools/perf/Documentation/perf-mem.txt |  8 ++++++++
 tools/perf/builtin-mem.c              | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-mem.txt +8 -0
index 6676d2784733..f8e23f50ce59 100644
@@ -51,6 +51,14 @@ OPTIONS
 --ldload::
 	Specify desired latency for loads event.
 
+-K::
+--all-kernel::
+	Configure all used events to run in kernel space.
+
+-U::
+--all-user::
+	Configure all used events to run in user space.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +10 -1
index bf0bfca5be20..5dad76e1c8df 100644
@@ -62,6 +62,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
 	int ret;
+	bool all_user = false, all_kernel = false;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
@@ -69,13 +70,15 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_UINTEGER(0, "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
 	OPT_INCR('v', "verbose", &verbose,
 		 "be more verbose (show counter open errors, etc)"),
+	OPT_BOOLEAN('U', "--all-user", &all_user, "collect only user level data"),
+	OPT_BOOLEAN('K', "--all-kernel", &all_kernel, "collect only kernel level data"),
 	OPT_END()
 	};
 
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
-	rec_argc = argc + 7; /* max number of arguments */
+	rec_argc = argc + 9; /* max number of arguments */
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	if (!rec_argv)
 		return -1;
@@ -104,6 +107,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		rec_argv[i++] = perf_mem_events__name(j);
 	};
 
+	if (all_user)
+		rec_argv[i++] = "--all-user";
+
+	if (all_kernel)
+		rec_argv[i++] = "--all-kernel";
+
 	for (j = 0; j < argc; j++, i++)
 		rec_argv[i] = argv[j];
 
Signature · 1 line
2.4.3
#6 lore raw

Re: [PATCH 2/6] perf mem: Add -U/-K (--all-user/--all-kernel) options

Em Thu, Mar 24, 2016 at 01:52:16PM +0100, Jiri Olsa escreveu:

Quoted 2 lines

Add -U/-K (--all-user/--all-kernel) options to use the perf record --all-user/--all-kernel options.

Applying this after fixing up the clash due to the first patch not being merged so far.

Quoted 70 lines
---
 tools/perf/Documentation/perf-mem.txt |  8 ++++++++
 tools/perf/builtin-mem.c              | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-mem.txt +8 -0
index 6676d2784733..f8e23f50ce59 100644
@@ -51,6 +51,14 @@ OPTIONS
 --ldload::
 	Specify desired latency for loads event.
 
+-K::
+--all-kernel::
+	Configure all used events to run in kernel space.
+
+-U::
+--all-user::
+	Configure all used events to run in user space.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +10 -1
index bf0bfca5be20..5dad76e1c8df 100644
@@ -62,6 +62,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
 	int ret;
+	bool all_user = false, all_kernel = false;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
@@ -69,13 +70,15 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_UINTEGER(0, "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
 	OPT_INCR('v', "verbose", &verbose,
 		 "be more verbose (show counter open errors, etc)"),
+	OPT_BOOLEAN('U', "--all-user", &all_user, "collect only user level data"),
+	OPT_BOOLEAN('K', "--all-kernel", &all_kernel, "collect only kernel level data"),
 	OPT_END()
 	};
 
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
-	rec_argc = argc + 7; /* max number of arguments */
+	rec_argc = argc + 9; /* max number of arguments */
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	if (!rec_argv)
 		return -1;
@@ -104,6 +107,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		rec_argv[i++] = perf_mem_events__name(j);
 	};
 
+	if (all_user)
+		rec_argv[i++] = "--all-user";
+
+	if (all_kernel)
+		rec_argv[i++] = "--all-kernel";
+
 	for (j = 0; j < argc; j++, i++)
 		rec_argv[i] = argv[j];
 
Signature · 1 line
2.4.3
#7 lore raw

[tip:perf/core] perf mem: Add -U/-K (--all-user/--all-kernel) options

In reply to Jiri Olsa
perf mem: Add -U/-K (--all-user/--all-kernel) options
Commit-ID:  ad16511b0e404652331a5350c522d0824f8209de
Gitweb:     http://git.kernel.org/tip/ad16511b0e404652331a5350c522d0824f8209de
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 24 Mar 2016 13:52:16 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 30 Mar 2016 11:14:07 -0300

perf mem: Add -U/-K (--all-user/--all-kernel) options

Add -U/-K (--all-user/--all-kernel) options to use the perf record --all-user/--all-kernel options.

---
 tools/perf/Documentation/perf-mem.txt |  8 ++++++++
 tools/perf/builtin-mem.c              | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-mem.txt +8 -0
index 43310d8..1d6092c 100644
@@ -48,6 +48,14 @@ OPTIONS
 	option can be passed in record mode. It will be interpreted the same way as perf
 	record.
 
+-K::
+--all-kernel::
+	Configure all used events to run in kernel space.
+
+-U::
+--all-user::
+	Configure all used events to run in user space.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/builtin-mem.c +10 -1
index 85db3be..1dc140c 100644
@@ -62,19 +62,22 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
 	int ret;
+	bool all_user = false, all_kernel = false;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
 		     parse_record_events),
 	OPT_INCR('v', "verbose", &verbose,
 		 "be more verbose (show counter open errors, etc)"),
+	OPT_BOOLEAN('U', "--all-user", &all_user, "collect only user level data"),
+	OPT_BOOLEAN('K', "--all-kernel", &all_kernel, "collect only kernel level data"),
 	OPT_END()
 	};
 
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
-	rec_argc = argc + 7; /* max number of arguments */
+	rec_argc = argc + 9; /* max number of arguments */
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	if (!rec_argv)
 		return -1;
@@ -103,6 +106,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		rec_argv[i++] = perf_mem_events__name(j);
 	};
 
+	if (all_user)
+		rec_argv[i++] = "--all-user";
+
+	if (all_kernel)
+		rec_argv[i++] = "--all-kernel";
+
 	for (j = 0; j < argc; j++, i++)
 		rec_argv[i] = argv[j];
 
author reviewer
#8 lore raw

PATCH 3/6 perf tools: Make hists__collapse_insert_entry static

In reply to Jiri Olsa

No need to export hists__collapse_insert_entry function.

---
 tools/perf/util/hist.c | 5 +++--
 tools/perf/util/hist.h | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)
tools/perf/util/hist.c +3 -2
index 31c4641fe5ff..3d34c57dfbe2 100644
@@ -1295,8 +1295,9 @@ static int hists__hierarchy_insert_entry(struct hists *hists,
 	return ret;
 }
 
-int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
-				 struct hist_entry *he)
+static int hists__collapse_insert_entry(struct hists *hists,
+					struct rb_root *root,
+					struct hist_entry *he)
 {
 	struct rb_node **p = &root->rb_node;
 	struct rb_node *parent = NULL;
tools/perf/util/hist.h +0 -2
index bec0cd660fbd..588596561cb3 100644
@@ -199,8 +199,6 @@ int hists__init(void);
 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
 
 struct rb_root *hists__get_rotate_entries_in(struct hists *hists);
-int hists__collapse_insert_entry(struct hists *hists,
-				  struct rb_root *root, struct hist_entry *he);
 
 struct perf_hpp {
 	char *buf;
Signature · 1 line
2.4.3
#9 lore raw

[tip:perf/core] perf tools: Make hists__collapse_insert_entry static

perf tools: Make hists__collapse_insert_entry static
Commit-ID:  592dac6f35cf222a7687d4ff1ea7df0e6ef722e0
Gitweb:     http://git.kernel.org/tip/592dac6f35cf222a7687d4ff1ea7df0e6ef722e0
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 24 Mar 2016 13:52:17 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 30 Mar 2016 11:14:07 -0300

perf tools: Make hists__collapse_insert_entry static

No need to export hists__collapse_insert_entry function.

---
 tools/perf/util/hist.c | 5 +++--
 tools/perf/util/hist.h | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)
tools/perf/util/hist.c +3 -2
index 31c4641..3d34c57 100644
@@ -1295,8 +1295,9 @@ static int hists__hierarchy_insert_entry(struct hists *hists,
 	return ret;
 }
 
-int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
-				 struct hist_entry *he)
+static int hists__collapse_insert_entry(struct hists *hists,
+					struct rb_root *root,
+					struct hist_entry *he)
 {
 	struct rb_node **p = &root->rb_node;
 	struct rb_node *parent = NULL;
tools/perf/util/hist.h +0 -2
index bec0cd6..5885965 100644
@@ -199,8 +199,6 @@ int hists__init(void);
 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
 
 struct rb_root *hists__get_rotate_entries_in(struct hists *hists);
-int hists__collapse_insert_entry(struct hists *hists,
-				  struct rb_root *root, struct hist_entry *he);
 
 struct perf_hpp {
 	char *buf;
author reviewer
#10 lore raw

PATCH 4/6 perf tools: Introduce trim function

In reply to Jiri Olsa

To be used in cases for both sides trim.

---
 tools/perf/ui/browsers/hists.c | 3 +--
 tools/perf/ui/stdio/hist.c     | 3 +--
 tools/perf/util/util.h         | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)
tools/perf/ui/browsers/hists.c +1 -2
index 4b9816555946..ba10c86cb56c 100644
@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
 
 			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
 			dummy_hpp.buf[ret] = '\0';
-			rtrim(dummy_hpp.buf);
 
-			start = ltrim(dummy_hpp.buf);
+			start = trim(dummy_hpp.buf);
 			ret = strlen(start);
 
 			if (start != dummy_hpp.buf)
tools/perf/ui/stdio/hist.c +1 -2
index 7aff5acf3265..560eb47d56f9 100644
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
 			first_col = false;
 
 			fmt->header(fmt, hpp, hists_to_evsel(hists));
-			rtrim(hpp->buf);
 
-			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
+			header_width += fprintf(fp, "%s", trim(hpp->buf));
 		}
 	}
 
tools/perf/util/util.h +5 -0
index 8298d607c738..3bf3de86d429 100644
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+	return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 
Signature · 1 line
2.4.3
author reviewer
#11 lore raw

PATCH 5/6 perf tools: Unify -f/--force option documentation

In reply to Jiri Olsa
---
 tools/perf/Documentation/perf-annotate.txt | 2 +-
 tools/perf/Documentation/perf-diff.txt     | 2 +-
 tools/perf/Documentation/perf-report.txt   | 2 +-
 tools/perf/Documentation/perf-script.txt   | 4 ++++
 4 files changed, 7 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-annotate.txt +1 -1
index e9cd39a92dc2..778f54d4d0bd 100644
@@ -33,7 +33,7 @@ OPTIONS
 
 -f::
 --force::
-        Don't complain, do it.
+        Don't do ownership validation.
 
 -v::
 --verbose::
tools/perf/Documentation/perf-diff.txt +1 -1
index d1deb573877f..3e9490b9c533 100644
@@ -75,7 +75,7 @@ OPTIONS
 
 -f::
 --force::
-       Don't complain, do it.
+        Don't do ownership validation.
 
 --symfs=<directory>::
         Look for files with symbols relative to this directory.
tools/perf/Documentation/perf-report.txt +1 -1
index 12113992ac9d..496d42cdf02b 100644
@@ -285,7 +285,7 @@ OPTIONS
 
 -f::
 --force::
-        Don't complain, do it.
+        Don't do ownership validation.
 
 --symfs=<directory>::
         Look for files with symbols relative to this directory.
tools/perf/Documentation/perf-script.txt +4 -0
index 382ddfb45d1d..22ef3933342a 100644
@@ -262,6 +262,10 @@ include::itrace.txt[]
 --ns::
 	Use 9 decimal places when displaying time (i.e. show the nanoseconds)
 
+-f::
+--force::
+	Don't do ownership validation.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-script-perl[1],
Signature · 1 line
2.4.3
#12 lore raw

[tip:perf/core] perf tools: Make -f/--force option documentation consistent across tools

perf tools: Make -f/--force option documentation consistent across tools
Commit-ID:  e0be62cc0325d65e1b7ae55d23e3d224638c20a6
Gitweb:     http://git.kernel.org/tip/e0be62cc0325d65e1b7ae55d23e3d224638c20a6
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 24 Mar 2016 13:52:19 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 30 Mar 2016 11:14:08 -0300

perf tools: Make -f/--force option documentation consistent across tools

---
 tools/perf/Documentation/perf-annotate.txt | 2 +-
 tools/perf/Documentation/perf-diff.txt     | 2 +-
 tools/perf/Documentation/perf-report.txt   | 2 +-
 tools/perf/Documentation/perf-script.txt   | 4 ++++
 4 files changed, 7 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-annotate.txt +1 -1
index e9cd39a..778f54d 100644
@@ -33,7 +33,7 @@ OPTIONS
 
 -f::
 --force::
-        Don't complain, do it.
+        Don't do ownership validation.
 
 -v::
 --verbose::
tools/perf/Documentation/perf-diff.txt +1 -1
index d1deb57..3e9490b 100644
@@ -75,7 +75,7 @@ OPTIONS
 
 -f::
 --force::
-       Don't complain, do it.
+        Don't do ownership validation.
 
 --symfs=<directory>::
         Look for files with symbols relative to this directory.
tools/perf/Documentation/perf-report.txt +1 -1
index 1211399..496d42c 100644
@@ -285,7 +285,7 @@ OPTIONS
 
 -f::
 --force::
-        Don't complain, do it.
+        Don't do ownership validation.
 
 --symfs=<directory>::
         Look for files with symbols relative to this directory.
tools/perf/Documentation/perf-script.txt +4 -0
index 382ddfb..22ef393 100644
@@ -262,6 +262,10 @@ include::itrace.txt[]
 --ns::
 	Use 9 decimal places when displaying time (i.e. show the nanoseconds)
 
+-f::
+--force::
+	Don't do ownership validation.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-script-perl[1],
author reviewer
#13 lore raw

PATCH 6/6 perf tests: Add test to check for event times

In reply to Jiri Olsa

This test creates software event 'cpu-clock'
attaches it in several ways and checks that
enabled and running times match.

---
 tools/perf/tests/Build          |   1 +
 tools/perf/tests/builtin-test.c |   4 +
 tools/perf/tests/event-times.c  | 236 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |   1 +
 4 files changed, 242 insertions(+)
 create mode 100644 tools/perf/tests/event-times.c
tools/perf/tests/Build +1 -0
index 1ba628ed049a..449fe97a555f 100644
@@ -37,6 +37,7 @@ perf-y += topology.o
 perf-y += cpumap.o
 perf-y += stat.o
 perf-y += event_update.o
+perf-y += event-times.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
 	$(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
index f2b1dcac45d3..93c467015e71 100644
@@ -204,6 +204,10 @@ static struct test generic_tests[] = {
 		.func = test__event_update,
 	},
 	{
+		.desc = "Test events times",
+		.func = test__event_times,
+	},
+	{
 		.func = NULL,
 	},
 };
tools/perf/tests/event-times.c new file +236 -0

236 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 82b2b5e6ba7c..0fc946989cf0 100644
@@ -85,6 +85,7 @@ int test__synthesize_stat_config(int subtest);
 int test__synthesize_stat(int subtest);
 int test__synthesize_stat_round(int subtest);
 int test__event_update(int subtest);
+int test__event_times(int subtest);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
Signature · 1 line
2.4.3
#14 lore raw

[tip:perf/core] perf tests: Add test to check for event times

perf tests: Add test to check for event times
Commit-ID:  b31d660df37c1701fd18d526faeb9a86f0fc7dd2
Gitweb:     http://git.kernel.org/tip/b31d660df37c1701fd18d526faeb9a86f0fc7dd2
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 24 Mar 2016 13:52:20 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 30 Mar 2016 11:14:08 -0300

perf tests: Add test to check for event times

This test creates software event 'cpu-clock' attaches it in several ways and checks that enabled and running times match.

Committer notes:

Testing it:

[acme@jouet linux]$ perf test -v times
44: Test events times :
--- start ---
test child forked, pid 27170
attaching to spawned child, enable on exec

    OK    : ena 307328, run 307328
  attaching to current thread as enabled
    OK    : ena 7826, run 7826
  attaching to current thread as disabled
    OK    : ena 738, run 738

attaching to CPU 0 as enabled
SKIP : not enough rights
attaching to CPU 0 as enabled
SKIP : not enough rights
test child finished with -2
---- end ----
Test events times: Skip
[acme@jouet linux]$

[root@jouet ~]# perf test times
44: Test events times : Ok
[root@jouet ~]# perf test -v times
44: Test events times :
--- start ---
test child forked, pid 27306
attaching to spawned child, enable on exec

    OK    : ena 479290, run 479290
  attaching to current thread as enabled
    OK    : ena 11356, run 11356
  attaching to current thread as disabled
    OK    : ena 987, run 987
  attaching to CPU 0 as enabled
    OK    : ena 3717, run 3717
  attaching to CPU 0 as enabled
    OK    : ena 2323, run 2323

test child finished with 0
---- end ----
Test events times: Ok
[root@jouet ~]#

---
 tools/perf/tests/Build          |   1 +
 tools/perf/tests/builtin-test.c |   4 +
 tools/perf/tests/event-times.c  | 236 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |   1 +
 4 files changed, 242 insertions(+)
tools/perf/tests/Build +1 -0
index 1ba628e..449fe97 100644
@@ -37,6 +37,7 @@ perf-y += topology.o
 perf-y += cpumap.o
 perf-y += stat.o
 perf-y += event_update.o
+perf-y += event-times.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
 	$(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
index f2b1dca..93c4670 100644
@@ -204,6 +204,10 @@ static struct test generic_tests[] = {
 		.func = test__event_update,
 	},
 	{
+		.desc = "Test events times",
+		.func = test__event_times,
+	},
+	{
 		.func = NULL,
 	},
 };
tools/perf/tests/event-times.c new file +236 -0

236 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 82b2b5e..0fc9469 100644
@@ -85,6 +85,7 @@ int test__synthesize_stat_config(int subtest);
 int test__synthesize_stat(int subtest);
 int test__synthesize_stat_round(int subtest);
 int test__event_update(int subtest);
+int test__event_times(int subtest);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
#15 lore raw
In reply to Jiri Olsa

Em Thu, Mar 24, 2016 at 01:52:14PM +0100, Jiri Olsa escreveu:

Quoted 6 lines

hi,
sending assorted fixes and leftover from previous mem patchset.

Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes

Applied all, after adjustments, except for patch 1.

- Arnaldo

Quoted 30 lines

thanks,
jirka
---
Jiri Olsa (6):
perf mem: Add --ldlat option
perf mem: Add -U/-K (--all-user/--all-kernel) options perf tools: Make hists__collapse_insert_entry static perf tools: Introduce trim function
perf tools: Unify -f/--force option documentation perf tests: Add test to check for event times

 tools/perf/Documentation/perf-annotate.txt |   2 +-
 tools/perf/Documentation/perf-diff.txt     |   2 +-
 tools/perf/Documentation/perf-mem.txt      |  11 +++++
 tools/perf/Documentation/perf-report.txt   |   2 +-
 tools/perf/Documentation/perf-script.txt   |   4 ++
 tools/perf/builtin-mem.c                   |  12 ++++-
 tools/perf/tests/Build                     |   1 +
 tools/perf/tests/builtin-test.c            |   4 ++
 tools/perf/tests/event-times.c             | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h                   |   1 +
 tools/perf/ui/browsers/hists.c             |   3 +-
 tools/perf/ui/stdio/hist.c                 |   3 +-
 tools/perf/util/hist.c                     |   5 +-
 tools/perf/util/hist.h                     |   2 -
 tools/perf/util/mem-events.c               |  17 ++++++-
 tools/perf/util/mem-events.h               |   1 +
 tools/perf/util/util.h                     |   5 ++
 17 files changed, 298 insertions(+), 13 deletions(-)
 create mode 100644 tools/perf/tests/event-times.c