Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL In review Arnaldo Carvalho de Melo 5 participants 31 messages Nov 25, 2013 – Nov 26, 2013 perf events

lore
Share & tools
lore
#0 lore raw

From: Arnaldo Carvalho de Melo <[email protected]>

Hi Ingo,

Please consider pulling,

This is based on top of a recent tip/perf/urgent.

- Arnaldo

The following changes since commit e98a6e59dff885eb387163b1a7abe019a44ba90b:

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2013-11-20 14:29:46 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo

for you to fetch changes up to 33d7da61e10ad7d43c60d4a5f4adb712361e5131:

perf script: Print callchains and symbols if they exist (2013-11-22 15:47:41 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

. Make per-cpu mmaps the default in 'perf record', from Adrian Hunter.

. Default -t/--thread 'perf record' option to no inheritance,
from Adrian Hunter.

. Make 'perf top -g' refer to callchains, for consistency with other tools,
from David Ahern.

. Skip ignored symbols while printing callchain, from David Ahern.

. Print callchains and symbols if they exist in 'perf script',
from David Ahern.

. Remove thread summary coloring in 'perf trace', from Pekka Enberg.

. zsh completion support, from Ramkumar Ramachandra.

. 'perf timechart' improvements, including backtrace support,
from Stanislav Fomichev.

----------------------------------------------------------------
Adrian Hunter (4):
perf record: Make per-cpu mmaps the default.
perf tools: Allow '--inherit' as the negation of '--no-inherit' perf tools: Add option macro OPT_BOOLEAN_SET
perf record: Default -t option to no inheritance

David Ahern (6):
perf top: Make -g refer to callchains
perf evsel: Skip ignored symbols while printing callchain perf symbols: Move idle syms check from top to generic function perf thread: Move comm_list check into function
perf tools: Export setup_list
perf script: Print callchains and symbols if they exist

Namhyung Kim (1):
perf script: Move evname print code to process_event()

Pekka Enberg (1):
perf trace: Remove thread summary coloring

Ramkumar Ramachandra (5):
perf completion: Introduce a layer of indirection perf completion: Factor out compgen stuff
perf completion: Factor out call to __ltrim_colon_completions perf completion: Introduce zsh support
perf completion: Rename file to reflect zsh support

Stanislav Fomichev (7):
perf timechart: Always try to print at least 15 tasks perf timechart: Add option to limit number of tasks perf timechart: Use proc_num to implement --power-only perf timechart: Add support for displaying only tasks related data perf timechart: Group figures and add title with details perf timechart: Add support for -P and -T in timechart recording perf timechart: Add backtrace support

Steven Rostedt (1):
tools lib traceevent: Use helper trace-seq in print functions like kernel does

 tools/lib/traceevent/event-parse.c                 |   7 +-
 tools/perf/Documentation/perf-record.txt           |  12 +-
 tools/perf/Documentation/perf-timechart.txt        |  26 +-
 tools/perf/Documentation/perf-top.txt              |   5 +-
 tools/perf/Makefile.perf                           |   4 +-
 tools/perf/builtin-record.c                        |  13 +-
 tools/perf/builtin-script.c                        |  35 ++-
 tools/perf/builtin-timechart.c                     | 306 +++++++++++++++++----
 tools/perf/builtin-top.c                           |  29 +-
 tools/perf/builtin-trace.c                         |  13 +-
 tools/perf/{bash_completion => perf-completion.sh} | 100 ++++++-
 tools/perf/perf.h                                  |   1 +
 tools/perf/tests/attr/test-record-no-inherit       |   2 +-
 tools/perf/util/event.c                            |   3 +-
 tools/perf/util/evlist.c                           |   6 +-
 tools/perf/util/evsel.c                            |   5 +-
 tools/perf/util/parse-options.c                    |  21 ++
 tools/perf/util/parse-options.h                    |   8 +
 tools/perf/util/session.c                          |  10 +-
 tools/perf/util/svghelper.c                        |  77 +++++-
 tools/perf/util/svghelper.h                        |  11 +-
 tools/perf/util/symbol.c                           |  32 ++-
 tools/perf/util/symbol.h                           |   4 +
 tools/perf/util/target.c                           |  11 +-
 tools/perf/util/target.h                           |   4 +-
 tools/perf/util/thread.h                           |  12 +
 26 files changed, 603 insertions(+), 154 deletions(-)
 rename tools/perf/{bash_completion => perf-completion.sh} (65%)
#1 lore raw

PATCH 1/25 tools lib traceevent: Use helper trace-seq in print functions like kernel does

From: Steven Rostedt <[email protected]>

Jiri Olsa reported that his plugin for scsi was chopping off part of the output. Investigating this, I found that Jiri used the same functions as what is in the kernel, which adds the following:

	trace_seq_putc(p, 0);

This adds a '\0' to the output string. The reason this works in the kernel is that the "p" that is passed to the function helper is a temporary trace_seq. But in the libtraceevent library, it's the pointer to the trace_seq used to output. By adding the '\0', it truncates the line and nothing added after that will be printed.

We can solve this in two ways. One is to have the helper functions for the library not add the unnecessary '\0'. The other is to change the library to also use a helper trace_seq structure that gets copied to the main trace_seq just like the kernel does.

The latter allows the helper functions in the plugins to be the same as the kernel, which is the better solution.

---
 tools/lib/traceevent/event-parse.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +6 -1
index 217c82ee3665..900fca01bdd3 100644
@@ -4099,6 +4099,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
 	unsigned long long val;
 	struct func_map *func;
 	const char *saveptr;
+	struct trace_seq p;
 	char *bprint_fmt = NULL;
 	char format[32];
 	int show_func;
@@ -4306,8 +4307,12 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
 				format[len] = 0;
 				if (!len_as_arg)
 					len_arg = -1;
-				print_str_arg(s, data, size, event,
+				/* Use helper trace_seq */
+				trace_seq_init(&p);
+				print_str_arg(&p, data, size, event,
 					      format, len_arg, arg);
+				trace_seq_terminate(&p);
+				trace_seq_puts(s, p.buffer);
 				arg = arg->next;
 				break;
 			default:
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/25 perf trace: Remove thread summary coloring

In reply to Arnaldo Carvalho de Melo

From: Pekka Enberg <[email protected]>

Thread summary line coloring looks ugly. It doesn't add much value so remove coloring completely.

---
 tools/perf/builtin-trace.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
tools/perf/builtin-trace.c +2 -11
index 8be17fc462ba..e9f345e2551a 100644
@@ -2158,7 +2158,6 @@ static int trace__fprintf_one_thread(struct thread *thread, void *priv)
 	size_t printed = data->printed;
 	struct trace *trace = data->trace;
 	struct thread_trace *ttrace = thread->priv;
-	const char *color;
 	double ratio;
 
 	if (ttrace == NULL)
@@ -2166,17 +2165,9 @@ static int trace__fprintf_one_thread(struct thread *thread, void *priv)
 
 	ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;
 
-	color = PERF_COLOR_NORMAL;
-	if (ratio > 50.0)
-		color = PERF_COLOR_RED;
-	else if (ratio > 25.0)
-		color = PERF_COLOR_GREEN;
-	else if (ratio > 5.0)
-		color = PERF_COLOR_YELLOW;
-
-	printed += color_fprintf(fp, color, " %s (%d), ", thread__comm_str(thread), thread->tid);
+	printed += fprintf(fp, " %s (%d), ", thread__comm_str(thread), thread->tid);
 	printed += fprintf(fp, "%lu events, ", ttrace->nr_events);
-	printed += color_fprintf(fp, color, "%.1f%%", ratio);
+	printed += fprintf(fp, "%.1f%%", ratio);
 	printed += fprintf(fp, ", %.3f msec\n", ttrace->runtime_ms);
 	printed += thread__dump_stats(ttrace, trace, fp);
 
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 3/25 perf top: Make -g refer to callchains

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

In most commands -g is used for callchains. Make perf-top follow suit. Move group to just --group with no short cut making it similar to perf-record.

---
 tools/perf/Documentation/perf-top.txt | 5 ++---
 tools/perf/builtin-top.c              | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-top.txt +2 -3
index 7de01dd79688..cdd8d4946dba 100644
@@ -50,7 +50,6 @@ Default is to monitor all CPUS.
 --count-filter=<count>::
 	Only display functions with more events than this.
 
--g::
 --group::
         Put the counters into a counter group.
 
@@ -143,12 +142,12 @@ Default is to monitor all CPUS.
 --asm-raw::
 	Show raw instruction encoding of assembly instructions.
 
--G::
+-g::
 	Enables call-graph (stack chain/backtrace) recording.
 
 --call-graph::
 	Setup and enable call-graph (stack chain/backtrace) recording,
-	implies -G.
+	implies -g.
 
 --max-stack::
 	Set the stack depth limit when parsing the callchain, anything
tools/perf/builtin-top.c +2 -2
index 71e6402729a8..531522d3d97b 100644
@@ -1084,7 +1084,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 			    "dump the symbol table used for profiling"),
 	OPT_INTEGER('f', "count-filter", &top.count_filter,
 		    "only display functions with more events than this"),
-	OPT_BOOLEAN('g', "group", &opts->group,
+	OPT_BOOLEAN(0, "group", &opts->group,
 			    "put the counters into a counter group"),
 	OPT_BOOLEAN('i', "no-inherit", &opts->no_inherit,
 		    "child tasks do not inherit counters"),
@@ -1105,7 +1105,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 		   " abort, in_tx, transaction"),
 	OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
 		    "Show a column with the number of samples"),
-	OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts,
+	OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
 			   NULL, "enables call-graph recording",
 			   &callchain_opt),
 	OPT_CALLBACK(0, "call-graph", &top.record_opts,
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 4/25 perf completion: Introduce a layer of indirection

In reply to Arnaldo Carvalho de Melo

From: Ramkumar Ramachandra <[email protected]>

Define the variables cur, words, cword, and prev outside the main completion function so that we have a chance to override it when we introduce zsh support.

---
 tools/perf/bash_completion | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
tools/perf/bash_completion +11 -6
index 62e157db2e2b..3efdc84f112c 100644
@@ -89,15 +89,12 @@ __ltrim_colon_completions()
 	fi
 }
 
-type perf &>/dev/null &&
-_perf()
+__perf_main ()
 {
-	local cur words cword prev cmd
-
-	COMPREPLY=()
-	_get_comp_words_by_ref -n =: cur words cword prev
+	local cmd
 
 	cmd=${words[0]}
+	COMPREPLY=()
 
 	# List perf subcommands or long options
 	if [ $cword -eq 1 ]; then
@@ -120,6 +117,14 @@ _perf()
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
 	fi
+}
+
+type perf &>/dev/null &&
+_perf()
+{
+	local cur words cword prev
+	_get_comp_words_by_ref -n =: cur words cword prev
+	__perf_main
 } &&
 
 complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH 5/25 perf completion: Factor out compgen stuff

In reply to Arnaldo Carvalho de Melo

From: Ramkumar Ramachandra <[email protected]>

compgen is a bash-builtin; factor out the invocations into a separate function to give us a chance to override it with a zsh equivalent in future patches.

---
 tools/perf/bash_completion | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
tools/perf/bash_completion +10 -5
index 3efdc84f112c..824312681601 100644
@@ -89,6 +89,11 @@ __ltrim_colon_completions()
 	fi
 }
 
+__perfcomp ()
+{
+	COMPREPLY=( $( compgen -W "$1" -- "$2" ) )
+}
+
 __perf_main ()
 {
 	local cmd
@@ -99,23 +104,23 @@ __perf_main ()
 	# List perf subcommands or long options
 	if [ $cword -eq 1 ]; then
 		if [[ $cur == --* ]]; then
-			COMPREPLY=( $( compgen -W '--help --version \
+			__perfcomp '--help --version \
 			--exec-path --html-path --paginate --no-pager \
-			--perf-dir --work-tree --debugfs-dir' -- "$cur" ) )
+			--perf-dir --work-tree --debugfs-dir' -- "$cur"
 		else
 			cmds=$($cmd --list-cmds)
-			COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
+			__perfcomp "$cmds" "$cur"
 		fi
 	# List possible events for -e option
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
-		COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )
+		__perfcomp "$evts" "$cur"
 		__ltrim_colon_completions $cur
 	# List long option names
 	elif [[ $cur == --* ]];  then
 		subcmd=${words[1]}
 		opts=$($cmd $subcmd --list-opts)
-		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
+		__perfcomp "$opts" "$cur"
 	fi
 }
 
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH 6/25 perf completion: Factor out call to __ltrim_colon_completions

In reply to Arnaldo Carvalho de Melo

From: Ramkumar Ramachandra <[email protected]>

In our sole callsite, __ltrim_colon_completions is called after __perfcomp, to modify the COMPREPLY set by the invocation.

This is problematic, because in the zsh equivalent (using compset/ compadd), we'll have to generate completions in one-shot.

So factor out this entire callsite into a special override'able __perfcomp_colon function; we will override it when introducing zsh support.

---
 tools/perf/bash_completion | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/bash_completion +7 -2
index 824312681601..573599b42be2 100644
@@ -94,6 +94,12 @@ __perfcomp ()
 	COMPREPLY=( $( compgen -W "$1" -- "$2" ) )
 }
 
+__perfcomp_colon ()
+{
+	__perfcomp "$1" "$2"
+	__ltrim_colon_completions $cur
+}
+
 __perf_main ()
 {
 	local cmd
@@ -114,8 +120,7 @@ __perf_main ()
 	# List possible events for -e option
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
-		__perfcomp "$evts" "$cur"
-		__ltrim_colon_completions $cur
+		__perfcomp_colon "$evts" "$cur"
 	# List long option names
 	elif [[ $cur == --* ]];  then
 		subcmd=${words[1]}
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH 7/25 perf completion: Introduce zsh support

In reply to Arnaldo Carvalho de Melo

From: Ramkumar Ramachandra <[email protected]>

__perfcomp(), __perfcomp_colon(), and _perf() have to be overridden. Inspired by the way the git.git completion system is structured.

---
 tools/perf/bash_completion | 63 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)
tools/perf/bash_completion +62 -1
index 573599b42be2..49494882d9bb 100644
@@ -1,4 +1,4 @@
-# perf completion
+# perf bash and zsh completion
 
 # Taken from git.git's completion script.
 __my_reassemble_comp_words_by_ref()
@@ -129,6 +129,67 @@ __perf_main ()
 	fi
 }
 
+if [[ -n ${ZSH_VERSION-} ]]; then
+	autoload -U +X compinit && compinit
+
+	__perfcomp ()
+	{
+		emulate -L zsh
+
+		local c IFS=$' \t\n'
+		local -a array
+
+		for c in ${=1}; do
+			case $c in
+			--*=*|*.) ;;
+			*) c="$c " ;;
+			esac
+			array[${#array[@]}+1]="$c"
+		done
+
+		compset -P '*[=:]'
+		compadd -Q -S '' -a -- array && _ret=0
+	}
+
+	__perfcomp_colon ()
+	{
+		emulate -L zsh
+
+		local cur_="${2-$cur}"
+		local c IFS=$' \t\n'
+		local -a array
+
+		if [[ "$cur_" == *:* ]]; then
+			local colon_word=${cur_%"${cur_##*:}"}
+		fi
+
+		for c in ${=1}; do
+			case $c in
+			--*=*|*.) ;;
+			*) c="$c " ;;
+			esac
+			array[$#array+1]=${c#"$colon_word"}
+		done
+
+		compset -P '*[=:]'
+		compadd -Q -S '' -a -- array && _ret=0
+	}
+
+	_perf ()
+	{
+		local _ret=1 cur cword prev
+		cur=${words[CURRENT]}
+		prev=${words[CURRENT-1]}
+		let cword=CURRENT-1
+		emulate ksh -c __perf_main
+		let _ret && _default && _ret=0
+		return _ret
+	}
+
+	compdef _perf perf
+	return
+fi
+
 type perf &>/dev/null &&
 _perf()
 {
Signature · 1 line
1.8.1.4
#8 lore raw

PATCH 8/25 perf completion: Rename file to reflect zsh support

In reply to Arnaldo Carvalho de Melo

From: Ramkumar Ramachandra <[email protected]>

---
 tools/perf/Makefile.perf      |   4 +-
 tools/perf/bash_completion    | 202 ------------------------------------------
 tools/perf/perf-completion.sh | 202 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 204 insertions(+), 204 deletions(-)
 delete mode 100644 tools/perf/bash_completion
 create mode 100644 tools/perf/perf-completion.sh
tools/perf/Makefile.perf +2 -2
index 7fc8f179cae7..e416ccc7d831 100644
@@ -840,9 +840,9 @@ ifndef NO_LIBPYTHON
 		$(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
 		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
 endif
-	$(call QUIET_INSTALL, bash_completion-script) \
+	$(call QUIET_INSTALL, perf_completion-script) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
-		$(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
+		$(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
 	$(call QUIET_INSTALL, tests) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
 		$(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
tools/perf/bash_completion deleted +0 -202

202 lines not on this page · raw message

tools/perf/perf-completion.sh new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#9 lore raw

PATCH 9/25 perf script: Move evname print code to process_event()

In reply to Arnaldo Carvalho de Melo

From: Namhyung Kim <[email protected]>

The print_sample_start() will be reused by other printing routine for internal events like COMM, FORK and EXIT from next patch. And because they're not tied to a specific event, move the evname print code to its caller.

---
 tools/perf/builtin-script.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/builtin-script.c +5 -6
index baf17989a216..b392770766dd 100644
@@ -288,7 +288,6 @@ static void print_sample_start(struct perf_sample *sample,
 			       struct perf_evsel *evsel)
 {
 	struct perf_event_attr *attr = &evsel->attr;
-	const char *evname = NULL;
 	unsigned long secs;
 	unsigned long usecs;
 	unsigned long long nsecs;
@@ -323,11 +322,6 @@ static void print_sample_start(struct perf_sample *sample,
 		usecs = nsecs / NSECS_PER_USEC;
 		printf("%5lu.%06lu: ", secs, usecs);
 	}
-
-	if (PRINT_FIELD(EVNAME)) {
-		evname = perf_evsel__name(evsel);
-		printf("%s: ", evname ? evname : "[unknown]");
-	}
 }
 
 static bool is_bts_event(struct perf_event_attr *attr)
@@ -434,6 +428,11 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
 
 	print_sample_start(sample, thread, evsel);
 
+	if (PRINT_FIELD(EVNAME)) {
+		const char *evname = perf_evsel__name(evsel);
+		printf("%s: ", evname ? evname : "[unknown]");
+	}
+
 	if (is_bts_event(attr)) {
 		print_sample_bts(event, sample, evsel, machine, thread);
 		return;
Signature · 1 line
1.8.1.4
#10 lore raw

PATCH 10/25 perf record: Make per-cpu mmaps the default.

In reply to Arnaldo Carvalho de Melo

From: Adrian Hunter <[email protected]>

This affects the -p, -t and -u options that previously defaulted to per-thread mmaps.

Consequently add an option to select per-thread mmaps to support the old behaviour.

Note that per-thread can be used with a workload-only (i.e. none of -p, -t, -u, -a or -C is selected) to get a per-thread mmap with no inheritance.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/Documentation/perf-record.txt     | 10 +++++-----
 tools/perf/builtin-record.c                  |  5 +++--
 tools/perf/tests/attr/test-record-no-inherit |  2 +-
 tools/perf/util/evlist.c                     |  6 ++++--
 tools/perf/util/evsel.c                      |  5 +++--
 tools/perf/util/target.c                     | 11 ++++++++++-
 tools/perf/util/target.h                     |  4 +++-
 7 files changed, 29 insertions(+), 14 deletions(-)
tools/perf/Documentation/perf-record.txt +5 -5
index 43b42c4f4a91..6ac867e7667f 100644
@@ -201,11 +201,11 @@ abort events and some memory events in precise mode on modern Intel CPUs.
 --transaction::
 Record transaction flags for transaction related events.
 
---force-per-cpu::
-Force the use of per-cpu mmaps.  By default, when tasks are specified (i.e. -p,
--t or -u options) per-thread mmaps are created.  This option overrides that and
-forces per-cpu mmaps.  A side-effect of that is that inheritance is
-automatically enabled.  Add the -i option also to disable inheritance.
+--per-thread::
+Use per-thread mmaps.  By default per-cpu mmaps are created.  This option
+overrides that and uses per-thread mmaps.  A side-effect of that is that
+inheritance is automatically disabled.  --per-thread is ignored with a warning
+if combined with -a or -C options.
 
 SEE ALSO
 --------
tools/perf/builtin-record.c +3 -2
index 7c8020a32784..f5b18b8fe8c9 100644
@@ -800,6 +800,7 @@ static struct perf_record record = {
 		.freq		     = 4000,
 		.target		     = {
 			.uses_mmap   = true,
+			.default_per_cpu = true,
 		},
 	},
 };
@@ -888,8 +889,8 @@ const struct option record_options[] = {
 		    "sample by weight (on special events only)"),
 	OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
 		    "sample transaction flags (special events only)"),
-	OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu,
-		    "force the use of per-cpu mmaps"),
+	OPT_BOOLEAN(0, "per-thread", &record.opts.target.per_thread,
+		    "use per-thread mmaps"),
 	OPT_END()
 };
 
tools/perf/tests/attr/test-record-no-inherit +1 -1
index 9079a25cd643..44edcb2edcd5 100644
@@ -3,5 +3,5 @@ command = record
 args    = -i kill >/dev/null 2>&1
 
 [event:base-record]
-sample_type=259
+sample_type=263
 inherit=0
tools/perf/util/evlist.c +4 -2
index bbc746aa5716..76fa76431329 100644
@@ -819,8 +819,10 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 	if (evlist->threads == NULL)
 		return -1;
 
-	if (target->force_per_cpu)
-		evlist->cpus = cpu_map__new(target->cpu_list);
+	if (target->default_per_cpu)
+		evlist->cpus = target->per_thread ?
+					cpu_map__dummy_new() :
+					cpu_map__new(target->cpu_list);
 	else if (target__has_task(target))
 		evlist->cpus = cpu_map__dummy_new();
 	else if (!target__has_cpu(target) && !target->uses_mmap)
tools/perf/util/evsel.c +3 -2
index 46dd4c2a41ce..77e38ffdfb19 100644
@@ -572,6 +572,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 	struct perf_evsel *leader = evsel->leader;
 	struct perf_event_attr *attr = &evsel->attr;
 	int track = !evsel->idx; /* only the first counter needs these */
+	bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread;
 
 	attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
 	attr->inherit	    = !opts->no_inherit;
@@ -645,7 +646,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 		}
 	}
 
-	if (target__has_cpu(&opts->target) || opts->target.force_per_cpu)
+	if (target__has_cpu(&opts->target))
 		perf_evsel__set_sample_bit(evsel, CPU);
 
 	if (opts->period)
@@ -653,7 +654,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 
 	if (!perf_missing_features.sample_id_all &&
 	    (opts->sample_time || !opts->no_inherit ||
-	     target__has_cpu(&opts->target) || opts->target.force_per_cpu))
+	     target__has_cpu(&opts->target) || per_cpu))
 		perf_evsel__set_sample_bit(evsel, TIME);
 
 	if (opts->raw_samples) {
tools/perf/util/target.c +10 -1
index 3c778a07b7cc..e74c5963dc7a 100644
@@ -55,6 +55,13 @@ enum target_errno target__validate(struct target *target)
 			ret = TARGET_ERRNO__UID_OVERRIDE_SYSTEM;
 	}
 
+	/* THREAD and SYSTEM/CPU are mutually exclusive */
+	if (target->per_thread && (target->system_wide || target->cpu_list)) {
+		target->per_thread = false;
+		if (ret == TARGET_ERRNO__SUCCESS)
+			ret = TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD;
+	}
+
 	return ret;
 }
 
@@ -100,6 +107,7 @@ static const char *target__error_str[] = {
 	"UID switch overriding CPU",
 	"PID/TID switch overriding SYSTEM",
 	"UID switch overriding SYSTEM",
+	"SYSTEM/CPU switch overriding PER-THREAD",
 	"Invalid User: %s",
 	"Problems obtaining information for user %s",
 };
@@ -131,7 +139,8 @@ int target__strerror(struct target *target, int errnum,
 	msg = target__error_str[idx];
 
 	switch (errnum) {
-	case TARGET_ERRNO__PID_OVERRIDE_CPU ... TARGET_ERRNO__UID_OVERRIDE_SYSTEM:
+	case TARGET_ERRNO__PID_OVERRIDE_CPU ...
+	     TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD:
 		snprintf(buf, buflen, "%s", msg);
 		break;
 
tools/perf/util/target.h +3 -1
index 2d0c50690892..31dd2e9a27d0 100644
@@ -12,7 +12,8 @@ struct target {
 	uid_t	     uid;
 	bool	     system_wide;
 	bool	     uses_mmap;
-	bool	     force_per_cpu;
+	bool	     default_per_cpu;
+	bool	     per_thread;
 };
 
 enum target_errno {
@@ -33,6 +34,7 @@ enum target_errno {
 	TARGET_ERRNO__UID_OVERRIDE_CPU,
 	TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
 	TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
+	TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD,
 
 	/* for target__parse_uid() */
 	TARGET_ERRNO__INVALID_UID,
Signature · 1 line
1.8.1.4
#11 lore raw

PATCH 11/25 perf tools: Allow '--inherit' as the negation of '--no-inherit'

In reply to Arnaldo Carvalho de Melo

From: Adrian Hunter <[email protected]>

Long options can be negated by prefixing them with 'no-'. However options that already start with 'no-', such as '--no-inherit' result in ugly double 'no's.

Avoid that by accepting that the removal of 'no-' also negates the long option.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/parse-options.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tools/perf/util/parse-options.c +19 -0
index 31f404a032a9..b6b39ff14fbb 100644
@@ -224,6 +224,24 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 			return 0;
 		}
 		if (!rest) {
+			if (!prefixcmp(options->long_name, "no-")) {
+				/*
+				 * The long name itself starts with "no-", so
+				 * accept the option without "no-" so that users
+				 * do not have to enter "no-no-" to get the
+				 * negation.
+				 */
+				rest = skip_prefix(arg, options->long_name + 3);
+				if (rest) {
+					flags |= OPT_UNSET;
+					goto match;
+				}
+				/* Abbreviated case */
+				if (!prefixcmp(options->long_name + 3, arg)) {
+					flags |= OPT_UNSET;
+					goto is_abbreviated;
+				}
+			}
 			/* abbreviated? */
 			if (!strncmp(options->long_name, arg, arg_end - arg)) {
 is_abbreviated:
@@ -259,6 +277,7 @@ is_abbreviated:
 			if (!rest)
 				continue;
 		}
+match:
 		if (*rest) {
 			if (*rest != '=')
 				continue;
Signature · 1 line
1.8.1.4
#12 lore raw

PATCH 12/25 perf tools: Add option macro OPT_BOOLEAN_SET

In reply to Arnaldo Carvalho de Melo

From: Adrian Hunter <[email protected]>

OPT_BOOLEAN_SET records whether a boolean option was set by the user.

That information can be used to change the default value for the option after the options have been parsed.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/parse-options.c | 2 ++
 tools/perf/util/parse-options.h | 8 ++++++++
 2 files changed, 10 insertions(+)
tools/perf/util/parse-options.c +2 -0
index b6b39ff14fbb..d22e3f8017dc 100644
@@ -78,6 +78,8 @@ static int get_value(struct parse_opt_ctx_t *p,
 
 	case OPTION_BOOLEAN:
 		*(bool *)opt->value = unset ? false : true;
+		if (opt->set)
+			*(bool *)opt->set = true;
 		return 0;
 
 	case OPTION_INCR:
tools/perf/util/parse-options.h +8 -0
index b0241e28eaf7..cbf0149cf221 100644
@@ -82,6 +82,9 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
  *   OPTION_{BIT,SET_UINT,SET_PTR} store the {mask,integer,pointer} to put in
  *   the value when met.
  *   CALLBACKS can use it like they want.
+ *
+ * `set`::
+ *   whether an option was set by the user
  */
 struct option {
 	enum parse_opt_type type;
@@ -94,6 +97,7 @@ struct option {
 	int flags;
 	parse_opt_cb *callback;
 	intptr_t defval;
+	bool *set;
 };
 
 #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v )
@@ -103,6 +107,10 @@ struct option {
 #define OPT_GROUP(h)                { .type = OPTION_GROUP, .help = (h) }
 #define OPT_BIT(s, l, v, h, b)      { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h), .defval = (b) }
 #define OPT_BOOLEAN(s, l, v, h)     { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h) }
+#define OPT_BOOLEAN_SET(s, l, v, os, h) \
+	{ .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), \
+	.value = check_vtype(v, bool *), .help = (h), \
+	.set = check_vtype(os, bool *)}
 #define OPT_INCR(s, l, v, h)        { .type = OPTION_INCR, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) }
 #define OPT_SET_UINT(s, l, v, h, i)  { .type = OPTION_SET_UINT, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h), .defval = (i) }
 #define OPT_SET_PTR(s, l, v, h, p)  { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) }
Signature · 1 line
1.8.1.4
#13 lore raw

PATCH 13/25 perf record: Default -t option to no inheritance

In reply to Arnaldo Carvalho de Melo

From: Adrian Hunter <[email protected]>

The change to per-cpu mmaps causes the -p, -t and -u options now to have inheritance enabled by default. Change that back to no inheritance but for the -t option only.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/Documentation/perf-record.txt | 2 ++
 tools/perf/builtin-record.c              | 8 ++++++--
 tools/perf/perf.h                        | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-record.txt +2 -0
index 6ac867e7667f..c407897f0435 100644
@@ -57,6 +57,8 @@ OPTIONS
 -t::
 --tid=::
         Record events on existing thread ID (comma separated list).
+        This option also disables inheritance by default.  Enable it by adding
+        --inherit.
 
 -u::
 --uid=::
tools/perf/builtin-record.c +6 -2
index f5b18b8fe8c9..65615a8bc25e 100644
@@ -843,8 +843,9 @@ const struct option record_options[] = {
 	OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"),
 	OPT_STRING('o', "output", &record.file.path, "file",
 		    "output file name"),
-	OPT_BOOLEAN('i', "no-inherit", &record.opts.no_inherit,
-		    "child tasks do not inherit counters"),
+	OPT_BOOLEAN_SET('i', "no-inherit", &record.opts.no_inherit,
+			&record.opts.no_inherit_set,
+			"child tasks do not inherit counters"),
 	OPT_UINTEGER('F', "freq", &record.opts.user_freq, "profile at this frequency"),
 	OPT_CALLBACK('m', "mmap-pages", &record.opts.mmap_pages, "pages",
 		     "number of mmap data pages",
@@ -939,6 +940,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
 		goto out_symbol_exit;
 	}
 
+	if (rec->opts.target.tid && !rec->opts.no_inherit_set)
+		rec->opts.no_inherit = true;
+
 	err = target__validate(&rec->opts.target);
 	if (err) {
 		target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
tools/perf/perf.h +1 -0
index b079304bd53d..b23fed527514 100644
@@ -254,6 +254,7 @@ struct perf_record_opts {
 	bool	     inherit_stat;
 	bool	     no_delay;
 	bool	     no_inherit;
+	bool	     no_inherit_set;
 	bool	     no_samples;
 	bool	     raw_samples;
 	bool	     sample_address;
Signature · 1 line
1.8.1.4
#14 lore raw

PATCH 14/25 perf timechart: Always try to print at least 15 tasks

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

Always try to print at least 15 tasks no matter how long they run.

---
 tools/perf/builtin-timechart.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-timechart.c +7 -5
index 41c9bde2fb67..bb21e57ff9bb 100644
@@ -945,15 +945,17 @@ static void write_svg_file(const char *filename)
 {
 	u64 i;
 	int count;
+	int thresh = TIME_THRESH;
 
 	numcpus++;
 
 
-	count = determine_display_tasks(TIME_THRESH);
-
-	/* We'd like to show at least 15 tasks; be less picky if we have fewer */
-	if (count < 15)
-		count = determine_display_tasks(TIME_THRESH / 10);
+	/* We'd like to show at least proc_num tasks;
+	 * be less picky if we have fewer */
+	do {
+		count = determine_display_tasks(thresh);
+		thresh /= 10;
+	} while (!process_filter && thresh && count < 15);
 
 	open_svg(filename, numcpus, count, first_time, last_time);
 
Signature · 1 line
1.8.1.4
#15 lore raw

PATCH 15/25 perf timechart: Add option to limit number of tasks

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

Add -n option to specify min. number of tasks to print.

---
 tools/perf/Documentation/perf-timechart.txt | 4 ++++
 tools/perf/builtin-timechart.c              | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-timechart.txt +4 -0
index 3ff8bd4f0b4d..4373144a43b4 100644
@@ -54,6 +54,10 @@ $ perf timechart
 
   Written 10.2 seconds of trace to output.svg.
 
+-n::
+--proc-num::
+        Print task info for at least given number of tasks.
+
 SEE ALSO
 --------
 linkperf:perf-record[1]
tools/perf/builtin-timechart.c +4 -1
index bb21e57ff9bb..c352be418f98 100644
@@ -41,6 +41,7 @@
 #define SUPPORT_OLD_POWER_EVENTS 1
 #define PWR_EVENT_EXIT -1
 
+static int proc_num = 15;
 
 static unsigned int	numcpus;
 static u64		min_freq;	/* Lowest CPU frequency seen */
@@ -955,7 +956,7 @@ static void write_svg_file(const char *filename)
 	do {
 		count = determine_display_tasks(thresh);
 		thresh /= 10;
-	} while (!process_filter && thresh && count < 15);
+	} while (!process_filter && thresh && count < proc_num);
 
 	open_svg(filename, numcpus, count, first_time, last_time);
 
@@ -1102,6 +1103,8 @@ int cmd_timechart(int argc, const char **argv,
 		       parse_process),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		    "Look for files with symbols relative to this directory"),
+	OPT_INTEGER('n', "proc-num", &proc_num,
+		    "min. number of tasks to print"),
 	OPT_END()
 	};
 	const char * const timechart_usage[] = {
Signature · 1 line
1.8.1.4
#16 lore raw

PATCH 16/25 perf timechart: Use proc_num to implement --power-only

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

Don't use special flag to indicate power-only mode, just set proc_num to 0.

---
 tools/perf/builtin-timechart.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/perf/builtin-timechart.c +8 -4
index c352be418f98..6410c9ead9e2 100644
@@ -912,7 +912,7 @@ static int determine_display_tasks(u64 threshold)
 		/* no exit marker, task kept running to the end */
 		if (p->end_time == 0)
 			p->end_time = last_time;
-		if (p->total_time >= threshold && !power_only)
+		if (p->total_time >= threshold)
 			p->display = 1;
 
 		c = p->all;
@@ -923,7 +923,7 @@ static int determine_display_tasks(u64 threshold)
 			if (c->start_time == 1)
 				c->start_time = first_time;
 
-			if (c->total_time >= threshold && !power_only) {
+			if (c->total_time >= threshold) {
 				c->display = 1;
 				count++;
 			}
@@ -950,6 +950,8 @@ static void write_svg_file(const char *filename)
 
 	numcpus++;
 
+	if (power_only)
+		proc_num = 0;
 
 	/* We'd like to show at least proc_num tasks;
 	 * be less picky if we have fewer */
@@ -967,9 +969,11 @@ static void write_svg_file(const char *filename)
 		svg_cpu_box(i, max_freq, turbo_frequency);
 
 	draw_cpu_usage();
-	draw_process_bars();
+	if (proc_num)
+		draw_process_bars();
 	draw_c_p_states();
-	draw_wakeups();
+	if (proc_num)
+		draw_wakeups();
 
 	svg_close();
 }
Signature · 1 line
1.8.1.4
#17 lore raw

PATCH 17/25 perf timechart: Add support for displaying only tasks related data

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

In order to make SVG smaller and faster to browse add possibility to switch off power related information with -T switch.

---
 tools/perf/Documentation/perf-timechart.txt |  3 +++
 tools/perf/builtin-timechart.c              | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-timechart.txt +3 -0
index 4373144a43b4..d8441894d9ec 100644
@@ -35,6 +35,9 @@ OPTIONS
 -P::
 --power-only::
         Only output the CPU power section of the diagram
+-T::
+--tasks-only::
+        Don't output processor state transitions
 -p::
 --process::
         Select the processes to display, by name or PID
tools/perf/builtin-timechart.c +10 -1
index 6410c9ead9e2..b3f175a30d94 100644
@@ -51,6 +51,7 @@ static u64		turbo_frequency;
 static u64		first_time, last_time;
 
 static bool		power_only;
+static bool		tasks_only;
 
 
 struct per_pid;
@@ -971,7 +972,8 @@ static void write_svg_file(const char *filename)
 	draw_cpu_usage();
 	if (proc_num)
 		draw_process_bars();
-	draw_c_p_states();
+	if (!tasks_only)
+		draw_c_p_states();
 	if (proc_num)
 		draw_wakeups();
 
@@ -1102,6 +1104,8 @@ int cmd_timechart(int argc, const char **argv,
 	OPT_STRING('o', "output", &output_name, "file", "output file name"),
 	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
 	OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
+	OPT_BOOLEAN('T', "tasks-only", &tasks_only,
+		    "output processes data only"),
 	OPT_CALLBACK('p', "process", NULL, "process",
 		      "process selector. Pass a pid or process name.",
 		       parse_process),
@@ -1119,6 +1123,11 @@ int cmd_timechart(int argc, const char **argv,
 	argc = parse_options(argc, argv, options, timechart_usage,
 			PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (power_only && tasks_only) {
+		pr_err("-P and -T options cannot be used at the same time.\n");
+		return -1;
+	}
+
 	symbol__init();
 
 	if (argc && !strncmp(argv[0], "rec", 3))
Signature · 1 line
1.8.1.4
#18 lore raw

PATCH 18/25 perf timechart: Group figures and add title with details

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

Add titles to figures so we can run SVG interactively in Firefox and check event details in the tooltips.

This also aids exploring SVG with Inkscape because when user clicks on one part of logical figure, all parts are selected.

It's also possible to read titles with Inkscape in the object details.

---
 tools/perf/builtin-timechart.c |  6 ++---
 tools/perf/util/svghelper.c    | 56 ++++++++++++++++++++++++++++++++++++++++--
 tools/perf/util/svghelper.h    |  5 ++--
 3 files changed, 60 insertions(+), 7 deletions(-)
tools/perf/builtin-timechart.c +3 -3
index b3f175a30d94..6a848b8c4c16 100644
@@ -798,11 +798,11 @@ static void draw_process_bars(void)
 			sample = c->samples;
 			while (sample) {
 				if (sample->type == TYPE_RUNNING)
-					svg_sample(Y, sample->cpu, sample->start_time, sample->end_time);
+					svg_running(Y, sample->cpu, sample->start_time, sample->end_time);
 				if (sample->type == TYPE_BLOCKED)
-					svg_box(Y, sample->start_time, sample->end_time, "blocked");
+					svg_blocked(Y, sample->cpu, sample->start_time, sample->end_time);
 				if (sample->type == TYPE_WAITING)
-					svg_waiting(Y, sample->start_time, sample->end_time);
+					svg_waiting(Y, sample->cpu, sample->start_time, sample->end_time);
 				sample = sample->next;
 			}
 
tools/perf/util/svghelper.c +54 -2

179 lines not on this page · raw message

tools/perf/util/svghelper.h +3 -2
index e0781989cc31..aa533459ab76 100644
@@ -5,8 +5,9 @@
 
 extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
 extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
-extern void svg_sample(int Yslot, int cpu, u64 start, u64 end);
-extern void svg_waiting(int Yslot, u64 start, u64 end);
+extern void svg_blocked(int Yslot, int cpu, u64 start, u64 end);
+extern void svg_running(int Yslot, int cpu, u64 start, u64 end);
+extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end);
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
Signature · 1 line
1.8.1.4
#19 lore raw

PATCH 19/25 perf timechart: Add support for -P and -T in timechart recording

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

If we don't want either power or task events we may use -T or -P with the perf timechart record command to filter out events while recording to keep perf.data small.

---
 tools/perf/Documentation/perf-timechart.txt |  16 +++--
 tools/perf/builtin-timechart.c              | 101 +++++++++++++++++++++-------
 2 files changed, 87 insertions(+), 30 deletions(-)
tools/perf/Documentation/perf-timechart.txt +12 -4
index d8441894d9ec..8359cfadf0ac 100644
@@ -8,8 +8,7 @@ perf-timechart - Tool to visualize total system behavior during a workload
 SYNOPSIS
 --------
 [verse]
-'perf timechart' record <command>
-'perf timechart' [<options>]
+'perf timechart' [<timechart options>] {record} [<record options>]
 
 DESCRIPTION
 -----------
@@ -21,8 +20,8 @@ There are two variants of perf timechart:
   'perf timechart' to turn a trace into a Scalable Vector Graphics file,
   that can be viewed with popular SVG viewers such as 'Inkscape'.
 
-OPTIONS
--------
+TIMECHART OPTIONS
+-----------------
 -o::
 --output=::
         Select the output file (default: output.svg)
@@ -61,6 +60,15 @@ $ perf timechart
 --proc-num::
         Print task info for at least given number of tasks.
 
+RECORD OPTIONS
+--------------
+-P::
+--power-only::
+        Record only power-related events
+-T::
+--tasks-only::
+        Record only tasks-related events
+
 SEE ALSO
 --------
 linkperf:perf-record[1]
tools/perf/builtin-timechart.c +75 -26

149 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#20 lore raw

PATCH 20/25 perf timechart: Add backtrace support

In reply to Arnaldo Carvalho de Melo

From: Stanislav Fomichev <[email protected]>

Add -g flag to perf timechart record which saves callchain info in the perf.data.

When generating SVG, add backtrace information to the figure details, so now it's possible to see which code path woke up the task and why some task went to sleep.

---
 tools/perf/Documentation/perf-timechart.txt |   3 +
 tools/perf/builtin-timechart.c              | 169 ++++++++++++++++++++++++----
 tools/perf/util/svghelper.c                 |  27 ++++-
 tools/perf/util/svghelper.h                 |  12 +-
 4 files changed, 175 insertions(+), 36 deletions(-)
tools/perf/Documentation/perf-timechart.txt +3 -0
index 8359cfadf0ac..271dd4ed5b05 100644
@@ -68,6 +68,9 @@ RECORD OPTIONS
 -T::
 --tasks-only::
         Record only tasks-related events
+-g::
+--callchain::
+        Do call-graph (stack chain/backtrace) recording
 
 SEE ALSO
 --------
tools/perf/builtin-timechart.c +145 -24

331 lines not on this page · raw message

tools/perf/util/svghelper.c +21 -6
index 9a5b41392e01..8b79d3ad1246 100644
@@ -130,7 +130,7 @@ void svg_box(int Yslot, u64 start, u64 end, const char *type)
 }
 
 static char *time_to_string(u64 duration);
-void svg_blocked(int Yslot, int cpu, u64 start, u64 end)
+void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	if (!svgfile)
 		return;
@@ -138,11 +138,13 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end)
 	fprintf(svgfile, "<g>\n");
 	fprintf(svgfile, "<title>#%d blocked %s</title>\n", cpu,
 		time_to_string(end - start));
+	if (backtrace)
+		fprintf(svgfile, "<desc>Blocked on:\n%s</desc>\n", backtrace);
 	svg_box(Yslot, start, end, "blocked");
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_running(int Yslot, int cpu, u64 start, u64 end)
+void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	double text_size;
 	if (!svgfile)
@@ -152,6 +154,8 @@ void svg_running(int Yslot, int cpu, u64 start, u64 end)
 
 	fprintf(svgfile, "<title>#%d running %s</title>\n",
 		cpu, time_to_string(end - start));
+	if (backtrace)
+		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
 		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
 
@@ -187,7 +191,7 @@ static char *time_to_string(u64 duration)
 	return text;
 }
 
-void svg_waiting(int Yslot, int cpu, u64 start, u64 end)
+void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	char *text;
 	const char *style;
@@ -212,6 +216,8 @@ void svg_waiting(int Yslot, int cpu, u64 start, u64 end)
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), Yslot * SLOT_MULT);
 	fprintf(svgfile, "<title>#%d waiting %s</title>\n", cpu, time_to_string(end - start));
+	if (backtrace)
+		fprintf(svgfile, "<desc>Waiting on:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
 		time2pixels(end)-time2pixels(start), SLOT_HEIGHT, style);
 	if (font_size > MIN_TEXT_SIZE)
@@ -382,7 +388,7 @@ void svg_pstate(int cpu, u64 start, u64 end, u64 freq)
 }
 
 
-void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2)
+void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2, const char *backtrace)
 {
 	double height;
 
@@ -396,6 +402,9 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc
 		desc1 ? desc1 : "?",
 		desc2 ? desc2 : "?");
 
+	if (backtrace)
+		fprintf(svgfile, "<desc>%s</desc>\n", backtrace);
+
 	if (row1 < row2) {
 		if (row1) {
 			fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
@@ -437,7 +446,7 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_wakeline(u64 start, int row1, int row2)
+void svg_wakeline(u64 start, int row1, int row2, const char *backtrace)
 {
 	double height;
 
@@ -447,6 +456,9 @@ void svg_wakeline(u64 start, int row1, int row2)
 
 	fprintf(svgfile, "<g>\n");
 
+	if (backtrace)
+		fprintf(svgfile, "<desc>%s</desc>\n", backtrace);
+
 	if (row1 < row2)
 		fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
 			time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT,  time2pixels(start), row2 * SLOT_MULT);
@@ -463,7 +475,7 @@ void svg_wakeline(u64 start, int row1, int row2)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_interrupt(u64 start, int row)
+void svg_interrupt(u64 start, int row, const char *backtrace)
 {
 	if (!svgfile)
 		return;
@@ -472,6 +484,9 @@ void svg_interrupt(u64 start, int row)
 
 	fprintf(svgfile, "<title>Wakeup from interrupt</title>\n");
 
+	if (backtrace)
+		fprintf(svgfile, "<desc>%s</desc>\n", backtrace);
+
 	fprintf(svgfile, "<circle  cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\"  style=\"fill:rgb(255,128,128)\"/>\n",
 			time2pixels(start), row * SLOT_MULT);
 	fprintf(svgfile, "<circle  cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\"  style=\"fill:rgb(255,128,128)\"/>\n",
tools/perf/util/svghelper.h +6 -6
index aa533459ab76..fad79ceeac1a 100644
@@ -5,9 +5,9 @@
 
 extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
 extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
-extern void svg_blocked(int Yslot, int cpu, u64 start, u64 end);
-extern void svg_running(int Yslot, int cpu, u64 start, u64 end);
-extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end);
+extern void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace);
+extern void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace);
+extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *backtrace);
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
@@ -18,9 +18,9 @@ extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
 extern void svg_time_grid(void);
 extern void svg_legenda(void);
-extern void svg_wakeline(u64 start, int row1, int row2);
-extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2);
-extern void svg_interrupt(u64 start, int row);
+extern void svg_wakeline(u64 start, int row1, int row2, const char *backtrace);
+extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2, const char *backtrace);
+extern void svg_interrupt(u64 start, int row, const char *backtrace);
 extern void svg_text(int Yslot, u64 start, const char *text);
 extern void svg_close(void);
 
Signature · 1 line
1.8.1.4
#21 lore raw

PATCH 21/25 perf evsel: Skip ignored symbols while printing callchain

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Allows a command to have a symbol_filter controlled by the user to skip certain functions in a backtrace. One example is to allow the user to reduce repeating patterns like:

do_select core_sys_select sys_select

to just sys_select when dumping callchains, consuming less real estate on the screen while still conveying the essential message - the process is in a select call.

This option is leveraged by the upcoming timehist command.

---
 tools/perf/util/session.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/session.c +8 -2
index f36d24a02445..948f7644b4d9 100644
@@ -1522,6 +1522,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
 			if (!node)
 				break;
 
+			if (node->sym && node->sym->ignore)
+				goto next;
+
 			if (print_ip)
 				printf("%c%16" PRIx64, s, node->ip);
 
@@ -1544,12 +1547,15 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
 			if (!print_oneline)
 				printf("\n");
 
-			callchain_cursor_advance(&callchain_cursor);
-
 			stack_depth--;
+next:
+			callchain_cursor_advance(&callchain_cursor);
 		}
 
 	} else {
+		if (al.sym->ignore)
+			return;
+
 		if (print_ip)
 			printf("%16" PRIx64, sample->ip);
 
Signature · 1 line
1.8.1.4
reviewer
#22 lore raw

Re: [PATCH 21/25] perf evsel: Skip ignored symbols while printing callchain

Quoted 44 lines · Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Allows a command to have a symbol_filter controlled by the user to skip certain functions in a backtrace. One example is to allow the user to reduce repeating patterns like:

do_select core_sys_select sys_select

to just sys_select when dumping callchains, consuming less real estate on the screen while still conveying the essential message - the process is in a select call.

This option is leveraged by the upcoming timehist command.

---
 tools/perf/util/session.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/session.c +3 -0
index f36d24a02445..948f7644b4d9 100644
@@ -1522,6 +1522,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
 			if (!node)
 				break;
 
+			if (node->sym && node->sym->ignore)
+				goto next;
+
 			if (print_ip)
 				printf("%c%16" PRIx64, s, node->ip);
 
@@ -1544,12 +1547,15 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
 			if (!print_oneline)
 				printf("\n");

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1556

Quoted 10 lines
tools/perf/util/session.c +3 -2
 
-			callchain_cursor_advance(&callchain_cursor);
-
 			stack_depth--;
+next:
+			callchain_cursor_advance(&callchain_cursor);
 		}
 
 	} else {
+		if (al.sym->ignore)

Seems to segfault here because sym is null

Quoted 6 lines
tools/perf/util/session.c +2 -0
+			return;
+
 		if (print_ip)
 			printf("%16" PRIx64, sample->ip);
 
#23 lore raw

Re: [PATCH 21/25] perf evsel: Skip ignored symbols while printing callchain

Em Tue, Nov 26, 2013 at 12:52:21PM +0200, Adrian Hunter escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1556

Quoted 3 lines

From: David Ahern <[email protected]>

tools/perf/util/session.c +1 -0
 	} else {
+		if (al.sym->ignore)

Seems to segfault here because sym is null

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1558

Quoted 2 lines
tools/perf/util/session.c +2 -0
+			return;
+

Changed it to look at (al.sym && al.sym->ignore), the rest of the code already checkfs if al.sym is NULL (printing [unknown], etc), can you please take a look at:

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=c0dd57452349779e0e5d436db8f9448dfffcc512

In an updated acme/perf/core branch?

- Arnaldo

#24 lore raw

Re: [PATCH 21/25] perf evsel: Skip ignored symbols while printing callchain

Quoted 15 lines · Arnaldo Carvalho de Melo

Em Tue, Nov 26, 2013 at 12:52:21PM +0200, Adrian Hunter escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1556

Quoted 3 lines

From: David Ahern <[email protected]>
} else {

tools/perf/util/session.c +1 -0
+		if (al.sym->ignore)

Seems to segfault here because sym is null

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1558

Quoted 2 lines
tools/perf/util/session.c +2 -0
+			return;
+

Changed it to look at (al.sym && al.sym->ignore), the rest of the code already checkfs if al.sym is NULL (printing [unknown], etc), can you please take a look at:

Quoted 4 lines

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=c0dd57452349779e0e5d436db8f9448dfffcc512

In an updated acme/perf/core branch?

Looks good to me. That's what I was going to send you. Sorry for the noise.

David

#25 lore raw

Re: [PATCH 21/25] perf evsel: Skip ignored symbols while printing callchain

Em Tue, Nov 26, 2013 at 07:30:02AM -0700, David Ahern escreveu:

Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 13 lines

Em Tue, Nov 26, 2013 at 12:52:21PM +0200, Adrian Hunter escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1556

Quoted 3 lines

From: David Ahern <[email protected]>

tools/perf/util/session.c +1 -0
 	} else {
+		if (al.sym->ignore)

Seems to segfault here because sym is null

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1557

Quoted 1 line
tools/perf/util/session.c +1 -0
+			return;

Changed it to look at (al.sym && al.sym->ignore), the rest of the code already checkfs if al.sym is NULL (printing [unknown], etc), can you please take a look at:

Quoted 5 lines
Quoted 3 lines

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=c0dd57452349779e0e5d436db8f9448dfffcc512

In an updated acme/perf/core branch?

Looks good to me. That's what I was going to send you. Sorry for the noise.

No problem, I'll regenerate a +perf-core-for-mingo signed tag and send it with this new version with a [PATCH N/M v2] together with a new set of patches that I've put there today, not resending the unmodified patches from last pull req.

Is that ok with you Ingo?

- Arnaldo

#26 lore raw

Re: [PATCH 21/25] perf evsel: Skip ignored symbols while printing callchain

Quoted 20 lines · Arnaldo Carvalho de Melo

Em Tue, Nov 26, 2013 at 07:30:02AM -0700, David Ahern escreveu:

Quoted 18 lines · Arnaldo Carvalho de Melo
Quoted 17 lines

Em Tue, Nov 26, 2013 at 12:52:21PM +0200, Adrian Hunter escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1556

Quoted 3 lines

From: David Ahern <[email protected]>

tools/perf/util/session.c +1 -0
 	} else {
+		if (al.sym->ignore)

Seems to segfault here because sym is null

tools/perf/util/session.c void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, · line 1557

Quoted 1 line
tools/perf/util/session.c +1 -0
+			return;

Changed it to look at (al.sym && al.sym->ignore), the rest of the code already checkfs if al.sym is NULL (printing [unknown], etc), can you please take a look at:

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=c0dd57452349779e0e5d436db8f9448dfffcc512

In an updated acme/perf/core branch?

Quoted 8 lines
Quoted 1 line

Looks good to me. That's what I was going to send you. Sorry for the noise.

No problem, I'll regenerate a +perf-core-for-mingo signed tag and send it with this new version with a [PATCH N/M v2] together with a new set of patches that I've put there today, not resending the unmodified patches from last pull req.

Is that ok with you Ingo?

Sounds good to me!

Thanks,

Ingo

#27 lore raw

PATCH 22/25 perf symbols: Move idle syms check from top to generic function

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Allows list of idle symbols to be leveraged by other commands, such as the upcoming timehist command.

---
 tools/perf/builtin-top.c | 25 ++-----------------------
 tools/perf/util/symbol.c | 30 ++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h |  1 +
 3 files changed, 33 insertions(+), 23 deletions(-)
tools/perf/builtin-top.c +2 -23
index 531522d3d97b..03d37a76c612 100644
@@ -634,26 +634,9 @@ repeat:
 	return NULL;
 }
 
-/* Tag samples to be skipped. */
-static const char *skip_symbols[] = {
-	"intel_idle",
-	"default_idle",
-	"native_safe_halt",
-	"cpu_idle",
-	"enter_idle",
-	"exit_idle",
-	"mwait_idle",
-	"mwait_idle_with_hints",
-	"poll_idle",
-	"ppc64_runlatch_off",
-	"pseries_dedicated_idle_sleep",
-	NULL
-};
-
 static int symbol_filter(struct map *map __maybe_unused, struct symbol *sym)
 {
 	const char *name = sym->name;
-	int i;
 
 	/*
 	 * ppc64 uses function descriptors and appends a '.' to the
@@ -671,12 +654,8 @@ static int symbol_filter(struct map *map __maybe_unused, struct symbol *sym)
 	    strstr(name, "_text_end"))
 		return 1;
 
-	for (i = 0; skip_symbols[i]; i++) {
-		if (!strcmp(skip_symbols[i], name)) {
-			sym->ignore = true;
-			break;
-		}
-	}
+	if (symbol__is_idle(sym))
+		sym->ignore = true;
 
 	return 0;
 }
tools/perf/util/symbol.c +30 -0
index c0c36965fff0..f55c18da1e40 100644
@@ -573,6 +573,36 @@ static u8 kallsyms2elf_type(char type)
 	return isupper(type) ? STB_GLOBAL : STB_LOCAL;
 }
 
+bool symbol__is_idle(struct symbol *sym)
+{
+	const char * const idle_symbols[] = {
+		"cpu_idle",
+		"intel_idle",
+		"default_idle",
+		"native_safe_halt",
+		"enter_idle",
+		"exit_idle",
+		"mwait_idle",
+		"mwait_idle_with_hints",
+		"poll_idle",
+		"ppc64_runlatch_off",
+		"pseries_dedicated_idle_sleep",
+		NULL
+	};
+
+	int i;
+
+	if (!sym)
+		return false;
+
+	for (i = 0; idle_symbols[i]; i++) {
+		if (!strcmp(idle_symbols[i], sym->name))
+			return true;
+	}
+
+	return false;
+}
+
 static int map__process_kallsym_symbol(void *arg, const char *name,
 				       char type, u64 start)
 {
tools/perf/util/symbol.h +1 -0
index 07de8fea2f48..ad13c5d50b91 100644
@@ -240,6 +240,7 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp);
 bool symbol_type__is_a(char symbol_type, enum map_type map_type);
 bool symbol__restricted_filename(const char *filename,
 				 const char *restricted_filename);
+bool symbol__is_idle(struct symbol *sym);
 
 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 		  struct symsrc *runtime_ss, symbol_filter_t filter,
Signature · 1 line
1.8.1.4
#28 lore raw

PATCH 23/25 perf thread: Move comm_list check into function

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

---
 tools/perf/util/event.c  |  3 +--
 tools/perf/util/thread.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/util/event.c +1 -2
index bb788c109fe6..c77814bf01e1 100644
@@ -732,8 +732,7 @@ int perf_event__preprocess_sample(const union perf_event *event,
 	if (thread == NULL)
 		return -1;
 
-	if (symbol_conf.comm_list &&
-	    !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread)))
+	if (thread__is_filtered(thread))
 		goto out_filtered;
 
 	dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
tools/perf/util/thread.h +12 -0
index 897c1b2a750a..5b856bf942e1 100644
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include "symbol.h"
+#include <strlist.h>
 
 struct thread {
 	union {
@@ -66,4 +67,15 @@ static inline void thread__set_priv(struct thread *thread, void *p)
 {
 	thread->priv = p;
 }
+
+static inline bool thread__is_filtered(struct thread *thread)
+{
+	if (symbol_conf.comm_list &&
+	    !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) {
+		return true;
+	}
+
+	return false;
+}
+
 #endif	/* __PERF_THREAD_H */
Signature · 1 line
1.8.1.4
#29 lore raw

PATCH 24/25 perf tools: Export setup_list

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Used in upcoming patches (perf sched timehist command).

---
 tools/perf/util/symbol.c | 2 +-
 tools/perf/util/symbol.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
index f55c18da1e40..ce9ce101adf4 100644
@@ -1749,7 +1749,7 @@ out_fail:
 	return -1;
 }
 
-static int setup_list(struct strlist **list, const char *list_str,
+int setup_list(struct strlist **list, const char *list_str,
 		      const char *list_name)
 {
 	if (list_str == NULL)
tools/perf/util/symbol.h +3 -0
index ad13c5d50b91..f1031a1358a1 100644
@@ -274,4 +274,7 @@ void kcore_extract__delete(struct kcore_extract *kce);
 int kcore_copy(const char *from_dir, const char *to_dir);
 int compare_proc_modules(const char *from, const char *to);
 
+int setup_list(struct strlist **list, const char *list_str,
+	       const char *list_name);
+
 #endif /* __PERF_SYMBOL */
Signature · 1 line
1.8.1.4
#30 lore raw

PATCH 25/25 perf script: Print callchains and symbols if they exist

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

The intent of perf-script is to dump the events and information in the file. H/W, S/W and raw events all dump callchains if they are present; might as well make that the default for tracepoints too.

v2: Only add options for sym, dso and ip if callchains are present

---
 tools/perf/builtin-script.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
tools/perf/builtin-script.c +24 -0
index b392770766dd..9f3ba4404a14 100644
@@ -280,6 +280,30 @@ static int perf_session__check_output_opt(struct perf_session *session)
 		set_print_ip_opts(&evsel->attr);
 	}
 
+	/*
+	 * set default for tracepoints to print symbols only
+	 * if callchains are present
+	 */
+	if (symbol_conf.use_callchain &&
+	    !output[PERF_TYPE_TRACEPOINT].user_set) {
+		struct perf_event_attr *attr;
+
+		j = PERF_TYPE_TRACEPOINT;
+		evsel = perf_session__find_first_evtype(session, j);
+		if (evsel == NULL)
+			goto out;
+
+		attr = &evsel->attr;
+
+		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
+			output[j].fields |= PERF_OUTPUT_IP;
+			output[j].fields |= PERF_OUTPUT_SYM;
+			output[j].fields |= PERF_OUTPUT_DSO;
+			set_print_ip_opts(attr);
+		}
+	}
+
+out:
 	return 0;
 }
 
Signature · 1 line
1.8.1.4