Skip to contentSkip to conversation

perf tools: Add 'perf-config' command

PATCH Superseded Taeung Song 6 participants 54 messages Nov 17, 2015 – Mar 5, 2016 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v11 1/24 perf tools: Add 'perf-config' command

The perf configuration file contains many variables to change various aspects of each of its tools, including output, disk usage, etc. But looking through state of configuration is difficult and there's no knowing what kind of other variables except variables in perfconfig.example exist. So This patch adds 'perf-config' command with '--list' option.

perf config [options]

display current perf config variables.
# perf config -l | --list

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Build            |  1 +
 tools/perf/builtin-config.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h        |  1 +
 tools/perf/command-list.txt |  1 +
 tools/perf/perf.c           |  1 +
 5 files changed, 70 insertions(+)
 create mode 100644 tools/perf/builtin-config.c
tools/perf/Build +1 -0
index 7223745..2c7aaf2 100644
@@ -1,5 +1,6 @@
 perf-y += builtin-bench.o
 perf-y += builtin-annotate.o
+perf-y += builtin-config.o
 perf-y += builtin-diff.o
 perf-y += builtin-evlist.o
 perf-y += builtin-help.o
tools/perf/builtin-config.c new file +66 -0

66 lines not on this page · raw message

tools/perf/builtin.h +1 -0
index 3688ad2..3f871b5 100644
@@ -17,6 +17,7 @@ extern int cmd_annotate(int argc, const char **argv, const char *prefix);
 extern int cmd_bench(int argc, const char **argv, const char *prefix);
 extern int cmd_buildid_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_buildid_list(int argc, const char **argv, const char *prefix);
+extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_diff(int argc, const char **argv, const char *prefix);
 extern int cmd_evlist(int argc, const char **argv, const char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
tools/perf/command-list.txt +1 -0
index 00fcaf8..acc3ea7 100644
@@ -9,6 +9,7 @@ perf-buildid-cache		mainporcelain common
 perf-buildid-list		mainporcelain common
 perf-data			mainporcelain common
 perf-diff			mainporcelain common
+perf-config			mainporcelain common
 perf-evlist			mainporcelain common
 perf-inject			mainporcelain common
 perf-kmem			mainporcelain common
tools/perf/perf.c +1 -0
index 3d4c7c0..4bee53c 100644
@@ -39,6 +39,7 @@ struct cmd_struct {
 static struct cmd_struct commands[] = {
 	{ "buildid-cache", cmd_buildid_cache, 0 },
 	{ "buildid-list", cmd_buildid_list, 0 },
+	{ "config",	cmd_config,	0 },
 	{ "diff",	cmd_diff,	0 },
 	{ "evlist",	cmd_evlist,	0 },
 	{ "help",	cmd_help,	0 },
Signature · 1 line
1.9.1
#1 lore raw

PATCH v11 2/24 perf tools: Add perf-config document

Add perf-config document to describe the perf configuration and a subcommand 'list'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 103 +++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 tools/perf/Documentation/perf-config.txt
tools/perf/Documentation/perf-config.txt new file +103 -0
new file mode 100644
index 0000000..dfdab9c
@@ -0,0 +1,103 @@
+perf-config(1)
+==============
+
+NAME
+----
+perf-config - Get and set variables in a configuration file.
+
+SYNOPSIS
+--------
+[verse]
+'perf config' -l | --list
+
+DESCRIPTION
+-----------
+You can manage variables in a configuration file with this command.
+
+OPTIONS
+-------
+
+-l::
+--list::
+	Show current config variables, name and value, for all sections.
+
+CONFIGURATION FILE
+------------------
+
+The perf configuration file contains many variables to change various
+aspects of each of its tools, including output, disk usage, etc.
+The '$HOME/.perfconfig' file is used to store a per-user configuration.
+The file '$(sysconfdir)/perfconfig' can be used to
+store a system-wide default configuration.
+
+Syntax
+~~~~~~
+
+The file consist of sections. A section starts with its name
+surrounded by square brackets and continues till the next section
+begins. Each variable must be in a section, and have the form
+'name = value', for example:
+
+	[section]
+		name1 = value1
+		name2 = value2
+
+Section names are case sensitive and can contain any characters except
+newline (double quote `"` and backslash have to be escaped as `\"` and `\\`,
+respectively). Section headers can't span multiple lines.
+
+Example
+~~~~~~~
+
+Given a $HOME/.perfconfig like this:
+
+#
+# This is the config file, and
+# a '#' and ';' character indicates a comment
+#
+
+[colors]
+	# Color variables
+	top = red, default
+	medium = green, default
+	normal = lightgray, default
+	selected = white, lightgray
+	code = blue, default
+	addr = magenta, default
+	root = white, blue
+
+[tui]
+	# Defaults if linked with libslang
+	report = on
+	annotate = on
+	top = on
+
+[buildid]
+	# Default, disable using /dev/null
+	dir = ~/.debug
+
+[annotate]
+	# Defaults
+	hide_src_code = false
+	use_offset = true
+	jump_arrows = true
+	show_nr_jumps = false
+
+[help]
+	# Format can be man, info, web or html
+	format = man
+	autocorrect = 0
+
+[ui]
+	show-headers = true
+
+[call-graph]
+	# fp (framepointer), dwarf
+	record-mode = fp
+	print-type = graph
+	order = caller
+	sort-key = function
+
+SEE ALSO
+--------
+linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer Acked-by on v11 2/24
#2 lore raw

Re: [PATCH v11 02/24] perf tools: Add perf-config document

Quoted 5 lines · Taeung Song

Add perf-config document to describe the perf configuration and a subcommand 'list'.

Thanks,
Namhyung

Quoted 117 lines
---
 tools/perf/Documentation/perf-config.txt | 103 +++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 tools/perf/Documentation/perf-config.txt
tools/perf/Documentation/perf-config.txt new file +103 -0
new file mode 100644
index 0000000..dfdab9c
@@ -0,0 +1,103 @@
+perf-config(1)
+==============
+
+NAME
+----
+perf-config - Get and set variables in a configuration file.
+
+SYNOPSIS
+--------
+[verse]
+'perf config' -l | --list
+
+DESCRIPTION
+-----------
+You can manage variables in a configuration file with this command.
+
+OPTIONS
+-------
+
+-l::
+--list::
+	Show current config variables, name and value, for all sections.
+
+CONFIGURATION FILE
+------------------
+
+The perf configuration file contains many variables to change various
+aspects of each of its tools, including output, disk usage, etc.
+The '$HOME/.perfconfig' file is used to store a per-user configuration.
+The file '$(sysconfdir)/perfconfig' can be used to
+store a system-wide default configuration.
+
+Syntax
+~~~~~~
+
+The file consist of sections. A section starts with its name
+surrounded by square brackets and continues till the next section
+begins. Each variable must be in a section, and have the form
+'name = value', for example:
+
+	[section]
+		name1 = value1
+		name2 = value2
+
+Section names are case sensitive and can contain any characters except
+newline (double quote `"` and backslash have to be escaped as `\"` and `\\`,
+respectively). Section headers can't span multiple lines.
+
+Example
+~~~~~~~
+
+Given a $HOME/.perfconfig like this:
+
+#
+# This is the config file, and
+# a '#' and ';' character indicates a comment
+#
+
+[colors]
+	# Color variables
+	top = red, default
+	medium = green, default
+	normal = lightgray, default
+	selected = white, lightgray
+	code = blue, default
+	addr = magenta, default
+	root = white, blue
+
+[tui]
+	# Defaults if linked with libslang
+	report = on
+	annotate = on
+	top = on
+
+[buildid]
+	# Default, disable using /dev/null
+	dir = ~/.debug
+
+[annotate]
+	# Defaults
+	hide_src_code = false
+	use_offset = true
+	jump_arrows = true
+	show_nr_jumps = false
+
+[help]
+	# Format can be man, info, web or html
+	format = man
+	autocorrect = 0
+
+[ui]
+	show-headers = true
+
+[call-graph]
+	# fp (framepointer), dwarf
+	record-mode = fp
+	print-type = graph
+	order = caller
+	sort-key = function
+
+SEE ALSO
+--------
+linkperf:perf[1]
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH v11 02/24] perf tools: Add perf-config document

Em Wed, Nov 18, 2015 at 08:13:13AM +0900, Namhyung Kim escreveu:

Quoted 8 lines · Taeung Song
Quoted 5 lines

Add perf-config document to describe the perf configuration and a subcommand 'list'.

Taeung, please check this:

[acme@zoo linux]$ rpm -q asciidoc
asciidoc-8.6.8-6.fc21.noarch

I applied the first patch, continue your work from my perf/core branch.

INSTALL perf_completion-script
INSTALL tests
ASCIIDOC /tmp/build/perf/perf-kmem.xml
ASCIIDOC /tmp/build/perf/perf-trace.xml
ASCIIDOC /tmp/build/perf/perf-data.xml
ASCIIDOC /tmp/build/perf/perf-buildid-cache.xml
ASCIIDOC /tmp/build/perf/perf-list.xml
ASCIIDOC /tmp/build/perf/perf-help.xml
ASCIIDOC /tmp/build/perf/perf-script.xml
ASCIIDOC /tmp/build/perf/perf-lock.xml
ASCIIDOC /tmp/build/perf/perf-archive.xml
ASCIIDOC /tmp/build/perf/perf-probe.xml
ASCIIDOC /tmp/build/perf/perf-config.xml
ASCIIDOC /tmp/build/perf/perf-bench.xml
ASCIIDOC /tmp/build/perf/perf-evlist.xml
asciidoc: WARNING: perf-config.txt: line 59: missing style: [paradef-literal]: colors
asciidoc: WARNING: perf-config.txt: line 69: missing style: [paradef-literal]: tui
asciidoc: WARNING: perf-config.txt: line 75: missing style: [paradef-literal]: buildid
asciidoc: WARNING: perf-config.txt: line 79: missing style: [paradef-literal]: annotate
asciidoc: WARNING: perf-config.txt: line 86: missing style: [paradef-literal]: help
asciidoc: WARNING: perf-config.txt: line 91: missing style: [paradef-literal]: ui
asciidoc: WARNING: perf-config.txt: line 94: missing style: [paradef-literal]: call-graph
ASCIIDOC /tmp/build/perf/perf-sched.xml

#4 lore raw

Re: [PATCH v11 02/24] perf tools: Add perf-config document

Hi, Arnaldo, Namhyung

I left out indentation for config example.
I fixed the bugs and I resent patch mail.

Thanks,
Taeung

Quoted 43 lines · Arnaldo Carvalho de Melo

Em Wed, Nov 18, 2015 at 08:13:13AM +0900, Namhyung Kim escreveu:

Quoted 8 lines · Taeung Song
Quoted 5 lines

Add perf-config document to describe the perf configuration and a subcommand 'list'.

Taeung, please check this:

[acme@zoo linux]$ rpm -q asciidoc
asciidoc-8.6.8-6.fc21.noarch

I applied the first patch, continue your work from my perf/core branch.

INSTALL perf_completion-script
INSTALL tests
ASCIIDOC /tmp/build/perf/perf-kmem.xml
ASCIIDOC /tmp/build/perf/perf-trace.xml
ASCIIDOC /tmp/build/perf/perf-data.xml
ASCIIDOC /tmp/build/perf/perf-buildid-cache.xml
ASCIIDOC /tmp/build/perf/perf-list.xml
ASCIIDOC /tmp/build/perf/perf-help.xml
ASCIIDOC /tmp/build/perf/perf-script.xml
ASCIIDOC /tmp/build/perf/perf-lock.xml
ASCIIDOC /tmp/build/perf/perf-archive.xml
ASCIIDOC /tmp/build/perf/perf-probe.xml
ASCIIDOC /tmp/build/perf/perf-config.xml
ASCIIDOC /tmp/build/perf/perf-bench.xml
ASCIIDOC /tmp/build/perf/perf-evlist.xml
asciidoc: WARNING: perf-config.txt: line 59: missing style: [paradef-literal]: colors
asciidoc: WARNING: perf-config.txt: line 69: missing style: [paradef-literal]: tui
asciidoc: WARNING: perf-config.txt: line 75: missing style: [paradef-literal]: buildid
asciidoc: WARNING: perf-config.txt: line 79: missing style: [paradef-literal]: annotate
asciidoc: WARNING: perf-config.txt: line 86: missing style: [paradef-literal]: help
asciidoc: WARNING: perf-config.txt: line 91: missing style: [paradef-literal]: ui
asciidoc: WARNING: perf-config.txt: line 94: missing style: [paradef-literal]: call-graph
ASCIIDOC /tmp/build/perf/perf-sched.xml

#5 lore raw

PATCH RESEND v11 2/24 perf tools: Add perf-config document

In reply to Arnaldo Carvalho de Melo

Add perf-config document to describe the perf configuration and a subcommand 'list’.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 103 +++++++++++++++++++++++++++++++

1 file changed, 103 insertions(+)

create mode 100644 tools/perf/Documentation/perf-config.txt

tools/perf/Documentation/perf-config.txt new file +103 -0
new file mode 100644
index 0000000..b9ca1e3
@@ -0,0 +1,103 @@
+perf-config(1)
+==============
+
+NAME
+----
+perf-config - Get and set variables in a configuration file.
+
+SYNOPSIS
+--------
+[verse]
+'perf config' -l | --list
+
+DESCRIPTION
+-----------
+You can manage variables in a configuration file with this command.
+
+OPTIONS
+-------
+
+-l::
+--list::
+	Show current config variables, name and value, for all sections.
+
+CONFIGURATION FILE
+------------------
+
+The perf configuration file contains many variables to change various
+aspects of each of its tools, including output, disk usage, etc.
+The '$HOME/.perfconfig' file is used to store a per-user configuration.
+The file '$(sysconfdir)/perfconfig' can be used to
+store a system-wide default configuration.
+
+Syntax
+~~~~~~
+
+The file consist of sections. A section starts with its name
+surrounded by square brackets and continues till the next section
+begins. Each variable must be in a section, and have the form
+'name = value', for example:
+
+	[section]
+		name1 = value1
+		name2 = value2
+
+Section names are case sensitive and can contain any characters except
+newline (double quote `"` and backslash have to be escaped as `\"` and `\\`,
+respectively). Section headers can't span multiple lines.
+
+Example
+~~~~~~~
+
+Given a $HOME/.perfconfig like this:
+
+#
+# This is the config file, and
+# a '#' and ';' character indicates a comment
+#
+
+	[colors]
+		# Color variables
+		top = red, default
+		medium = green, default
+		normal = lightgray, default
+		selected = white, lightgray
+		code = blue, default
+		addr = magenta, default
+		root = white, blue
+
+	[tui]
+		# Defaults if linked with libslang
+		report = on
+		annotate = on
+		top = on
+
+	[buildid]
+		# Default, disable using /dev/null
+		dir = ~/.debug
+
+	[annotate]
+		# Defaults
+		hide_src_code = false
+		use_offset = true
+		jump_arrows = true
+		show_nr_jumps = false
+
+	[help]
+		# Format can be man, info, web or html
+		format = man
+		autocorrect = 0
+
+	[ui]
+		show-headers = true
+
+	[call-graph]
+		# fp (framepointer), dwarf
+		record-mode = fp
+		print-type = graph
+		order = caller
+		sort-key = function
+
+SEE ALSO
+--------
+linkperf:perf[1]
Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH v11 RESEND 02/24] perf tools: Add perf-config document

Em Sun, Nov 22, 2015 at 07:11:56PM +0900, Taeung Song escreveu:

Quoted 2 lines

Add perf-config document to describe the perf configuration and a subcommand 'list’.

Worked this time, applied, will continue processing the other patches soon.

- Arnaldo

Quoted 119 lines
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 103 +++++++++++++++++++++++++++++++

1 file changed, 103 insertions(+)

create mode 100644 tools/perf/Documentation/perf-config.txt

tools/perf/Documentation/perf-config.txt new file +103 -0
new file mode 100644
index 0000000..b9ca1e3
@@ -0,0 +1,103 @@
+perf-config(1)
+==============
+
+NAME
+----
+perf-config - Get and set variables in a configuration file.
+
+SYNOPSIS
+--------
+[verse]
+'perf config' -l | --list
+
+DESCRIPTION
+-----------
+You can manage variables in a configuration file with this command.
+
+OPTIONS
+-------
+
+-l::
+--list::
+	Show current config variables, name and value, for all sections.
+
+CONFIGURATION FILE
+------------------
+
+The perf configuration file contains many variables to change various
+aspects of each of its tools, including output, disk usage, etc.
+The '$HOME/.perfconfig' file is used to store a per-user configuration.
+The file '$(sysconfdir)/perfconfig' can be used to
+store a system-wide default configuration.
+
+Syntax
+~~~~~~
+
+The file consist of sections. A section starts with its name
+surrounded by square brackets and continues till the next section
+begins. Each variable must be in a section, and have the form
+'name = value', for example:
+
+	[section]
+		name1 = value1
+		name2 = value2
+
+Section names are case sensitive and can contain any characters except
+newline (double quote `"` and backslash have to be escaped as `\"` and `\\`,
+respectively). Section headers can't span multiple lines.
+
+Example
+~~~~~~~
+
+Given a $HOME/.perfconfig like this:
+
+#
+# This is the config file, and
+# a '#' and ';' character indicates a comment
+#
+
+	[colors]
+		# Color variables
+		top = red, default
+		medium = green, default
+		normal = lightgray, default
+		selected = white, lightgray
+		code = blue, default
+		addr = magenta, default
+		root = white, blue
+
+	[tui]
+		# Defaults if linked with libslang
+		report = on
+		annotate = on
+		top = on
+
+	[buildid]
+		# Default, disable using /dev/null
+		dir = ~/.debug
+
+	[annotate]
+		# Defaults
+		hide_src_code = false
+		use_offset = true
+		jump_arrows = true
+		show_nr_jumps = false
+
+	[help]
+		# Format can be man, info, web or html
+		format = man
+		autocorrect = 0
+
+	[ui]
+		show-headers = true
+
+	[call-graph]
+		# fp (framepointer), dwarf
+		record-mode = fp
+		print-type = graph
+		order = caller
+		sort-key = function
+
+SEE ALSO
+--------
+linkperf:perf[1]
Signature · 1 line
1.9.1
#7 lore raw

[tip:perf/core] perf config: Add initial man page

In reply to Taeung Song
perf config: Add initial man page
Commit-ID:  7d6852432acb3b09fc3ec45dd65421d34eebe3b5
Gitweb:     http://git.kernel.org/tip/7d6852432acb3b09fc3ec45dd65421d34eebe3b5
Author:     Taeung Song <[email protected]>
AuthorDate: Sun, 22 Nov 2015 19:11:56 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 23 Nov 2015 18:31:25 -0300

perf config: Add initial man page

Add perf-config document to describe the perf configuration and a 'list’ subcommand.

---
 tools/perf/Documentation/perf-config.txt | 103 +++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
tools/perf/Documentation/perf-config.txt new file +103 -0
new file mode 100644
index 0000000..b9ca1e3
@@ -0,0 +1,103 @@
+perf-config(1)
+==============
+
+NAME
+----
+perf-config - Get and set variables in a configuration file.
+
+SYNOPSIS
+--------
+[verse]
+'perf config' -l | --list
+
+DESCRIPTION
+-----------
+You can manage variables in a configuration file with this command.
+
+OPTIONS
+-------
+
+-l::
+--list::
+	Show current config variables, name and value, for all sections.
+
+CONFIGURATION FILE
+------------------
+
+The perf configuration file contains many variables to change various
+aspects of each of its tools, including output, disk usage, etc.
+The '$HOME/.perfconfig' file is used to store a per-user configuration.
+The file '$(sysconfdir)/perfconfig' can be used to
+store a system-wide default configuration.
+
+Syntax
+~~~~~~
+
+The file consist of sections. A section starts with its name
+surrounded by square brackets and continues till the next section
+begins. Each variable must be in a section, and have the form
+'name = value', for example:
+
+	[section]
+		name1 = value1
+		name2 = value2
+
+Section names are case sensitive and can contain any characters except
+newline (double quote `"` and backslash have to be escaped as `\"` and `\\`,
+respectively). Section headers can't span multiple lines.
+
+Example
+~~~~~~~
+
+Given a $HOME/.perfconfig like this:
+
+#
+# This is the config file, and
+# a '#' and ';' character indicates a comment
+#
+
+	[colors]
+		# Color variables
+		top = red, default
+		medium = green, default
+		normal = lightgray, default
+		selected = white, lightgray
+		code = blue, default
+		addr = magenta, default
+		root = white, blue
+
+	[tui]
+		# Defaults if linked with libslang
+		report = on
+		annotate = on
+		top = on
+
+	[buildid]
+		# Default, disable using /dev/null
+		dir = ~/.debug
+
+	[annotate]
+		# Defaults
+		hide_src_code = false
+		use_offset = true
+		jump_arrows = true
+		show_nr_jumps = false
+
+	[help]
+		# Format can be man, info, web or html
+		format = man
+		autocorrect = 0
+
+	[ui]
+		show-headers = true
+
+	[call-graph]
+		# fp (framepointer), dwarf
+		record-mode = fp
+		print-type = graph
+		order = caller
+		sort-key = function
+
+SEE ALSO
+--------
+linkperf:perf[1]
#8 lore raw

PATCH v11 3/24 perf config: Document variables for 'color' section in man page

In reply to Taeung Song

Explain 'color' section and its variables.

'top', 'medium', 'normal', 'selected', 'code', 'addr' and 'root'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
tools/perf/Documentation/perf-config.txt +44 -0
index dfdab9c..84a982b 100644
@@ -98,6 +98,50 @@ Given a $HOME/.perfconfig like this:
 	order = caller
 	sort-key = function
 
+Variables
+~~~~~~~~~
+
+colors.*::
+	The variables for customizing the colors used in the output for the
+	'report', 'top' and annotate in the TUI. They should specify the
+	background and foreground colors, separated by a comma, for example:
+
+		medium = green, lightgray
+
+	If you want to use the color configured for you terminal, just leave it
+	as 'default', for example:
+
+		medium = default, lightgray
+
+	Available colors:
+	red, green, default, black, blue, white, magenta, lightgray
+
+	colors.top::
+		'top' means a overhead percentage which is more than 5%.
+		And values of this variable specify percentage colors.
+		Basic key values are foreground-color 'red' and
+		background-color 'default'.
+	colors.medium::
+		'medium' means a overhead percentage which has more than 0.5%.
+		Default values are 'green' and 'default'.
+	colors.normal::
+		'normal' means the rest of overhead percentages
+		except 'top', 'medium', 'selected'.
+		Default values are 'lightgray' and 'default'.
+	colors.selected::
+		This selects the colors for the current entry in a list of entries
+		from sub-commands (top,report,annotate).
+		Default values are 'white' and 'lightgray'.
+	colors.code::
+		Colors for arrows and lines in jumps on  assembly code listings
+		such as 'jns','jmp','jane',etc. Default values are 'blue', 'default'.
+	colors.addr::
+		This selects colors for addresses from 'annotate'.
+		Default values are 'magenta', 'default'.
+	colors.root::
+		Colors for headers in the output of a sub-command 'top'.
+		Default values are 'white', 'blue'.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#9 lore raw

Re: [PATCH v11 03/24] perf config: Document variables for 'color' section in man page

Quoted 17 lines · Taeung Song

Explain 'color' section and its variables.

'top', 'medium', 'normal', 'selected', 'code', 'addr' and 'root'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index dfdab9c..84a982b 100644

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 106

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +6 -0
@@ -98,6 +98,50 @@ Given a $HOME/.perfconfig like this:
 	order = caller
 	sort-key = function
 
+Variables
+~~~~~~~~~
+
+colors.*::
+	The variables for customizing the colors used in the output for the
+	'report', 'top' and annotate in the TUI. They should specify the

The 'annotate' also needs to be surrounded by single quotes.

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 107

Quoted 1 line
tools/perf/Documentation/perf-config.txt +1 -0
+	background and foreground colors, separated by a comma, for example:

I think 'foreground and background' is better due to the order.

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 117

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+
+		medium = green, lightgray
+
+	If you want to use the color configured for you terminal, just leave it
+	as 'default', for example:
+
+		medium = default, lightgray
+
+	Available colors:
+	red, green, default, black, blue, white, magenta, lightgray

I don't know about the libslang color scheme, but it seems that the standard color names like 'yellow', 'cyan' and 'gray' are also available.

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +7 -0
+
+	colors.top::
+		'top' means a overhead percentage which is more than 5%.
+		And values of this variable specify percentage colors.
+		Basic key values are foreground-color 'red' and
+		background-color 'default'.
+	colors.medium::

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 134

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+		'medium' means a overhead percentage which has more than 0.5%.
+		Default values are 'green' and 'default'.
+	colors.normal::
+		'normal' means the rest of overhead percentages
+		except 'top', 'medium', 'selected'.
+		Default values are 'lightgray' and 'default'.
+	colors.selected::
+		This selects the colors for the current entry in a list of entries
+		from sub-commands (top,report,annotate).
+		Default values are 'white' and 'lightgray'.

Isn't it 'black' and 'lightgray'?

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 137

Quoted 3 lines
tools/perf/Documentation/perf-config.txt +3 -0
+	colors.code::
+		Colors for arrows and lines in jumps on  assembly code listings
+		such as 'jns','jmp','jane',etc. Default values are 'blue', 'default'.

Hmm.. I thought this is for source code displayed with annotate output, but it's only for jump arrows? Maybe it's better to rename this then.. Anyway it's a different problem.

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 142

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +5 -0
+	colors.addr::
+		This selects colors for addresses from 'annotate'.
+		Default values are 'magenta', 'default'.
+	colors.root::
+		Colors for headers in the output of a sub-command 'top'.

It also works for 'report'.

Thanks,
Namhyung

Quoted 8 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		Default values are 'white', 'blue'.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH v11 03/24] perf config: Document variables for 'color' section in man page

Hi, Namhyung

Quoted 75 lines · Namhyung Kim
Quoted 17 lines · Taeung Song

Explain 'color' section and its variables.

'top', 'medium', 'normal', 'selected',
'code', 'addr' and 'root'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 44 ++++++++++++++++++++++++++++++++

1 file changed, 44 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index dfdab9c..84a982b 100644

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 106

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +6 -0
@@ -98,6 +98,50 @@ Given a $HOME/.perfconfig like this:
 	order = caller
 	sort-key = function
 
+Variables
+~~~~~~~~~
+
+colors.*::
+	The variables for customizing the colors used in the output for the
+	'report', 'top' and annotate in the TUI. They should specify the

The 'annotate' also needs to be surrounded by single quotes.

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 107

Quoted 1 line
tools/perf/Documentation/perf-config.txt +1 -0
+	background and foreground colors, separated by a comma, for example:

I think 'foreground and background' is better due to the order.

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 117

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+
+		medium = green, lightgray
+
+	If you want to use the color configured for you terminal, just leave it
+	as 'default', for example:
+
+		medium = default, lightgray
+
+	Available colors:
+	red, green, default, black, blue, white, magenta, lightgray

I don't know about the libslang color scheme, but it seems that the standard color names like 'yellow', 'cyan' and 'gray' are also available.

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +7 -0
+
+	colors.top::
+		'top' means a overhead percentage which is more than 5%.
+		And values of this variable specify percentage colors.
+		Basic key values are foreground-color 'red' and
+		background-color 'default'.
+	colors.medium::

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 134

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+		'medium' means a overhead percentage which has more than 0.5%.
+		Default values are 'green' and 'default'.
+	colors.normal::
+		'normal' means the rest of overhead percentages
+		except 'top', 'medium', 'selected'.
+		Default values are 'lightgray' and 'default'.
+	colors.selected::
+		This selects the colors for the current entry in a list of entries
+		from sub-commands (top,report,annotate).
+		Default values are 'white' and 'lightgray'.

Isn't it 'black' and 'lightgray'?

Quoted 8 lines

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 137

Quoted 3 lines
tools/perf/Documentation/perf-config.txt +3 -0
+	colors.code::
+		Colors for arrows and lines in jumps on  assembly code listings
+		such as 'jns','jmp','jane',etc. Default values are 'blue', 'default'.

Hmm.. I thought this is for source code displayed with annotate output, but it's only for jump arrows? Maybe it's better to rename this then.. Anyway it's a different problem.

I rechecked the config (colors.code) but the colors are only for jump arrows. So, I’ll send a patch to rename this config.

Thanks,
Taeung

Quoted 20 lines

tools/perf/Documentation/perf-config.txt Given a $HOME/.perfconfig like this: · line 142

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +5 -0
+	colors.addr::
+		This selects colors for addresses from 'annotate'.
+		Default values are 'magenta', 'default'.
+	colors.root::
+		Colors for headers in the output of a sub-command 'top'.

It also works for 'report'.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		Default values are 'white', 'blue'.
+

SEE ALSO
--------
linkperf:perf[1]

Signature · 1 line
1.9.1
#11 lore raw

PATCH v11 4/24 perf config: Document variables for 'tui' and 'gtk' sections in man page

In reply to Taeung Song

Explain 'tui' and 'gtk' sections and these variables.

'top', 'report' and 'annotate'

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/perf/Documentation/perf-config.txt +9 -0
index 84a982b..ec30229 100644
@@ -142,6 +142,15 @@ colors.*::
 		Colors for headers in the output of a sub-command 'top'.
 		Default values are 'white', 'blue'.
 
+tui.*, gtk.*::
+	Available subcommands are 'top', 'report' and 'annotate'.
+	These values are a boolean type, for example:
+
+		top = true
+
+	By setting value, TUI or GTK can be enabled or not. But it is needed
+	that perf detects the required library for them during build.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer Acked-by on v11 4/24
#12 lore raw

Re: [PATCH v11 04/24] perf config: Document variables for 'tui' and 'gtk' sections in man page

Quoted 6 lines · Taeung Song

Explain 'tui' and 'gtk' sections and these variables.

'top', 'report' and 'annotate'

Thanks,
Namhyung

Quoted 27 lines
---
 tools/perf/Documentation/perf-config.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/perf/Documentation/perf-config.txt +9 -0
index 84a982b..ec30229 100644
@@ -142,6 +142,15 @@ colors.*::
 		Colors for headers in the output of a sub-command 'top'.
 		Default values are 'white', 'blue'.
 
+tui.*, gtk.*::
+	Available subcommands are 'top', 'report' and 'annotate'.
+	These values are a boolean type, for example:
+
+		top = true
+
+	By setting value, TUI or GTK can be enabled or not. But it is needed
+	that perf detects the required library for them during build.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#13 lore raw

PATCH v11 5/24 perf config: Document 'buildid.dir' variable in man page

In reply to Taeung Song

Explain 'buildid.dir' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/perf/Documentation/perf-config.txt +15 -0
index ec30229..b4ee205 100644
@@ -151,6 +151,21 @@ tui.*, gtk.*::
 	By setting value, TUI or GTK can be enabled or not. But it is needed
 	that perf detects the required library for them during build.
 
+buildid.*::
+	buildid.dir::
+		Each executable and shared library in modern distributions comes with a
+		content based identifier that, if available, will be inserted in a
+		'perf.data' file header to, at analysis time find what is needed to do
+		symbol resolution, code annotation, etc.
+
+		The recording tools also stores a hard link or copy in a per-user
+		directory, $HOME/.debug/, of binaries, shared libraries, /proc/kallsyms
+		and /proc/kcore files to be used at analysis time.
+
+		The buildid.dir variable can be used to either change this directory
+		cache location, or to disable it altogether. If you want to disable it,
+		set buildid.dir to /dev/null. The default is $HOME/.debug
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer Acked-by on v11 5/24
#14 lore raw

Re: [PATCH v11 05/24] perf config: Document 'buildid.dir' variable in man page

Quoted 4 lines · Taeung Song

Explain 'buildid.dir' variable.

Thanks,
Namhyung

Quoted 33 lines
---
 tools/perf/Documentation/perf-config.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/perf/Documentation/perf-config.txt +15 -0
index ec30229..b4ee205 100644
@@ -151,6 +151,21 @@ tui.*, gtk.*::
 	By setting value, TUI or GTK can be enabled or not. But it is needed
 	that perf detects the required library for them during build.
 
+buildid.*::
+	buildid.dir::
+		Each executable and shared library in modern distributions comes with a
+		content based identifier that, if available, will be inserted in a
+		'perf.data' file header to, at analysis time find what is needed to do
+		symbol resolution, code annotation, etc.
+
+		The recording tools also stores a hard link or copy in a per-user
+		directory, $HOME/.debug/, of binaries, shared libraries, /proc/kallsyms
+		and /proc/kcore files to be used at analysis time.
+
+		The buildid.dir variable can be used to either change this directory
+		cache location, or to disable it altogether. If you want to disable it,
+		set buildid.dir to /dev/null. The default is $HOME/.debug
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#15 lore raw

PATCH v11 6/24 perf config: Document variables for 'annotate' section in man page

In reply to Taeung Song

Explain 'annotate' section and its variables.

'hide_src_code', 'use_offset', 'jump_arrows' and 'show_nr_jumps'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 76 ++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
tools/perf/Documentation/perf-config.txt +76 -0
index b4ee205..bfbeb34 100644
@@ -166,6 +166,82 @@ buildid.*::
 		cache location, or to disable it altogether. If you want to disable it,
 		set buildid.dir to /dev/null. The default is $HOME/.debug
 
+annotate.*::
+	There're options which work with a 'annotate' sub-command.
+	These are in control of addresses, jump function, source code
+	in lines of assembly code from a specific program.
+
+	annotate.hide_src_code::
+		If a program which is analyzed has source code,
+		this option lets 'annotate' print a list of assembly code with the source code.
+		For example, let's see a part of a program. There're four lines.
+		If this option is 'true', they can be printed
+		without source code from a program as below.
+
+		│        push   %rbp
+		│        mov    %rsp,%rbp
+		│        sub    $0x10,%rsp
+		│        mov    (%rdi),%rdx
+
+		But if this option is 'false', source code of the part
+		can be also printed as below.
+
+		│      struct rb_node *rb_next(const struct rb_node *node)
+		│      {
+		│        push   %rbp
+		│        mov    %rsp,%rbp
+		│        sub    $0x10,%rsp
+		│              struct rb_node *parent;
+		│
+		│              if (RB_EMPTY_NODE(node))
+		│        mov    (%rdi),%rdx
+		│              return n;
+
+        annotate.use_offset::
+		Basing on a first address of a loaded function, offset can be used.
+		Instead of using original addresses of assembly code,
+		addresses subtracted from a base address can be printed.
+		Let's illustrate a example.
+		If a base address is 0XFFFFFFFF81624d50 as below,
+
+		ffffffff81624d50 <load0>
+
+		a address on assembly code has a specific absolute address as below
+
+		ffffffff816250b8:│  mov    0x8(%r14),%rdi
+
+		but if use_offset is 'true', a address subtracted from a base address is printed.
+		The default is true. This option is only applied to TUI.
+
+		             368:│  mov    0x8(%r14),%rdi
+
+	annotate.jump_arrows::
+		There can be jump instruction among assembly code.
+		Depending on a boolean value of jump_arrows,
+		arrows can be printed or not which represent
+		where do the instruction jump into as below.
+
+		│     ┌──jmp    1333
+		│     │  xchg   %ax,%ax
+		│1330:│  mov    %r15,%r10
+		│1333:└─→cmp    %r15,%r14
+
+		If jump_arrow is 'false', the arrows isn't printed as below.
+
+		│      ↓ jmp    1333
+		│        xchg   %ax,%ax
+		│1330:   mov    %r15,%r10
+		│1333:   cmp    %r15,%r14
+
+        annotate.show_nr_jumps::
+		Let's see a part of assembly code.
+
+		│1382:   movb   $0x1,-0x270(%rbp)
+
+		If use this, the number of branches branching to that address can be printed as below.
+
+		│1 1382:   movb   $0x1,-0x270(%rbp)
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#16 lore raw

Re: [PATCH v11 06/24] perf config: Document variables for 'annotate' section in man page

Quoted 3 lines · Taeung Song

Explain 'annotate' section and its variables.

'hide_src_code', 'use_offset', 'jump_arrows' and 'show_nr_jumps'.

The 'show_linenr' and 'show_total_period' are missing. Also you'd better to mention the default values for each option.

And some nitpicks below..

Quoted 13 lines
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 76 ++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index b4ee205..bfbeb34 100644

tools/perf/Documentation/perf-config.txt buildid.*:: · line 170

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +2 -0
@@ -166,6 +166,82 @@ buildid.*::
 		cache location, or to disable it altogether. If you want to disable it,
 		set buildid.dir to /dev/null. The default is $HOME/.debug
 
+annotate.*::
+	There're options which work with a 'annotate' sub-command.

AFAIK these options work only for TUI.

Quoted 24 lines
tools/perf/Documentation/perf-config.txt +24 -0
+	These are in control of addresses, jump function, source code
+	in lines of assembly code from a specific program.
+
+	annotate.hide_src_code::
+		If a program which is analyzed has source code,
+		this option lets 'annotate' print a list of assembly code with the source code.
+		For example, let's see a part of a program. There're four lines.
+		If this option is 'true', they can be printed
+		without source code from a program as below.
+
+		│        push   %rbp
+		│        mov    %rsp,%rbp
+		│        sub    $0x10,%rsp
+		│        mov    (%rdi),%rdx
+
+		But if this option is 'false', source code of the part
+		can be also printed as below.
+
+		│      struct rb_node *rb_next(const struct rb_node *node)
+		│      {
+		│        push   %rbp
+		│        mov    %rsp,%rbp
+		│        sub    $0x10,%rsp
+		│              struct rb_node *parent;

tools/perf/Documentation/perf-config.txt buildid.*:: · line 204

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+		│
+		│              if (RB_EMPTY_NODE(node))
+		│        mov    (%rdi),%rdx
+		│              return n;
+
+        annotate.use_offset::
+		Basing on a first address of a loaded function, offset can be used.
+		Instead of using original addresses of assembly code,
+		addresses subtracted from a base address can be printed.
+		Let's illustrate a example.

s/a example/an example/

tools/perf/Documentation/perf-config.txt buildid.*:: · line 209

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +5 -0
+		If a base address is 0XFFFFFFFF81624d50 as below,
+
+		ffffffff81624d50 <load0>
+
+		a address on assembly code has a specific absolute address as below

s/a address/an address/

tools/perf/Documentation/perf-config.txt buildid.*:: · line 213

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+		ffffffff816250b8:│  mov    0x8(%r14),%rdi
+
+		but if use_offset is 'true', a address subtracted from a base address is printed.

Ditto.

Quoted 18 lines
tools/perf/Documentation/perf-config.txt +18 -0
+		The default is true. This option is only applied to TUI.
+
+		             368:│  mov    0x8(%r14),%rdi
+
+	annotate.jump_arrows::
+		There can be jump instruction among assembly code.
+		Depending on a boolean value of jump_arrows,
+		arrows can be printed or not which represent
+		where do the instruction jump into as below.
+
+		│     ┌──jmp    1333
+		│     │  xchg   %ax,%ax
+		│1330:│  mov    %r15,%r10
+		│1333:└─→cmp    %r15,%r14
+
+		If jump_arrow is 'false', the arrows isn't printed as below.
+
+		│      ↓ jmp    1333

tools/perf/Documentation/perf-config.txt buildid.*:: · line 241

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+		│        xchg   %ax,%ax
+		│1330:   mov    %r15,%r10
+		│1333:   cmp    %r15,%r14
+
+        annotate.show_nr_jumps::
+		Let's see a part of assembly code.
+
+		│1382:   movb   $0x1,-0x270(%rbp)
+
+		If use this, the number of branches branching to that address can be printed as below.

I think it'd be better to avoid using similar words in a row. How about "number of branches jumping to that address" instead?

Thanks,
Namhyung

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +3 -0
+
+		│1 1382:   movb   $0x1,-0x270(%rbp)
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#17 lore raw

PATCH v11 7/24 perf config: Document variables for 'help' section in man page

In reply to Taeung Song

Explain 'help.format' and 'help.autocorrect' variables.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tools/perf/Documentation/perf-config.txt +21 -0
index bfbeb34..88e9b88 100644
@@ -242,6 +242,27 @@ annotate.*::
 
 		│1 1382:   movb   $0x1,-0x270(%rbp)
 
+help.*::
+	help.format:: = man
+		A format of manual page can be 'man', 'info', 'web' or 'html'.
+		'man' is default.
+	help.autocorrect:: = 0
+		Automatically correct and execute mistyped commands after
+		waiting for the given number of deciseconds (0.1 sec).
+		Let's see a example. If a mistyped sub-command is executed like 'perf mistyped-command'
+		and this option is 0, the output is as below.
+
+		perf: 'mistyped-command' is not a perf-command. See 'perf --help'.
+
+		Or if this option is more than 1, the output can be such as.
+
+		WARNING: You called a perf program named 'mistyped-command', which does not exist.
+		Continuing under the assumption that you meant 'with-kcore'
+		in 0.1 seconds automatically...
+		Usage: perf-with-kcore <perf sub-command> <perf.data directory> [<sub-command options> [ -- <workload>]]
+		<perf sub-command> can be record, script, report or inject
+		    or: perf-with-kcore fix_buildid_cache_permissions
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#18 lore raw

Re: [PATCH v11 07/24] perf config: Document variables for 'help' section in man page

Quoted 14 lines · Taeung Song

Explain 'help.format' and 'help.autocorrect' variables.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index bfbeb34..88e9b88 100644

tools/perf/Documentation/perf-config.txt annotate.*:: · line 246

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +2 -0
@@ -242,6 +242,27 @@ annotate.*::
 
 		│1 1382:   movb   $0x1,-0x270(%rbp)
 
+help.*::
+	help.format:: = man

What is this '= man' part? Is it for default value? It looks inconsistent anyway.

tools/perf/Documentation/perf-config.txt annotate.*:: · line 248

Quoted 2 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		A format of manual page can be 'man', 'info', 'web' or 'html'.
+		'man' is default.

I don't know we support other format of manual pages. Maybe asciidoc does the job for us, but do we really care? At least 'info' seems broken..

tools/perf/Documentation/perf-config.txt annotate.*:: · line 252

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+	help.autocorrect:: = 0
+		Automatically correct and execute mistyped commands after
+		waiting for the given number of deciseconds (0.1 sec).
+		Let's see a example. If a mistyped sub-command is executed like 'perf mistyped-command'

s/a example/an example/

tools/perf/Documentation/perf-config.txt annotate.*:: · line 264

Quoted 12 lines
tools/perf/Documentation/perf-config.txt +12 -0
+		and this option is 0, the output is as below.
+
+		perf: 'mistyped-command' is not a perf-command. See 'perf --help'.
+
+		Or if this option is more than 1, the output can be such as.
+
+		WARNING: You called a perf program named 'mistyped-command', which does not exist.
+		Continuing under the assumption that you meant 'with-kcore'
+		in 0.1 seconds automatically...
+		Usage: perf-with-kcore <perf sub-command> <perf.data directory> [<sub-command options> [ -- <workload>]]
+		<perf sub-command> can be record, script, report or inject
+		    or: perf-with-kcore fix_buildid_cache_permissions

I wasn't aware of this feature and it seems completely broken. If it's a leftover from the git codebase, we'd better either to disable/remove it or fix it.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#19 lore raw

Re: [PATCH v11 07/24] perf config: Document variables for 'help' section in man page

Hi, Namhyung

Quoted 26 lines · Namhyung Kim
Quoted 14 lines · Taeung Song

Explain 'help.format' and 'help.autocorrect' variables.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 21 +++++++++++++++++++++

1 file changed, 21 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index bfbeb34..88e9b88 100644

tools/perf/Documentation/perf-config.txt annotate.*:: · line 246

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +2 -0
@@ -242,6 +242,27 @@ annotate.*::
 
 		│1 1382:   movb   $0x1,-0x270(%rbp)
 
+help.*::
+	help.format:: = man

What is this '= man' part? Is it for default value? It looks inconsistent anyway.

Quoted 6 lines

tools/perf/Documentation/perf-config.txt annotate.*:: · line 248

Quoted 2 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		A format of manual page can be 'man', 'info', 'web' or 'html'.
+		'man' is default.

I don't know we support other format of manual pages. Maybe asciidoc does the job for us, but do we really care? At least 'info' seems broken..

I rechecked source code for this values and tested them. Only a ‘man’ value work with perf without any problems. And code for ‘web', ‘html’ and ‘info’ has a few errors.

So, IMHO:), I thought that if the code for them was fixed, maybe they could be used as values for help.format.

Or is it better to remove/disable this values (web, html, info) ? (First of all I'll try to make patch for the errors.)

Thanks,
Taeung

Quoted 35 lines

tools/perf/Documentation/perf-config.txt annotate.*:: · line 252

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +4 -0
+	help.autocorrect:: = 0
+		Automatically correct and execute mistyped commands after
+		waiting for the given number of deciseconds (0.1 sec).
+		Let's see a example. If a mistyped sub-command is executed like 'perf mistyped-command'

s/a example/an example/

tools/perf/Documentation/perf-config.txt annotate.*:: · line 264

Quoted 12 lines
tools/perf/Documentation/perf-config.txt +12 -0
+		and this option is 0, the output is as below.
+
+		perf: 'mistyped-command' is not a perf-command. See 'perf --help'.
+
+		Or if this option is more than 1, the output can be such as.
+
+		WARNING: You called a perf program named 'mistyped-command', which does not exist.
+		Continuing under the assumption that you meant 'with-kcore'
+		in 0.1 seconds automatically...
+		Usage: perf-with-kcore <perf sub-command> <perf.data directory> [<sub-command options> [ -- <workload>]]
+		<perf sub-command> can be record, script, report or inject
+		    or: perf-with-kcore fix_buildid_cache_permissions

I wasn't aware of this feature and it seems completely broken. If it's a leftover from the git codebase, we'd better either to disable/remove it or fix it.

Thanks,
Namhyung

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +1 -0
+

SEE ALSO
--------
linkperf:perf[1]

Signature · 1 line
1.9.1
#20 lore raw

PATCH v11 8/24 perf config: Document 'hist.percentage' variable in man page

In reply to Taeung Song

Explain 'hist.percentage' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tools/perf/Documentation/perf-config.txt +17 -0
index 88e9b88..b166b81 100644
@@ -263,6 +263,23 @@ help.*::
 		<perf sub-command> can be record, script, report or inject
 		    or: perf-with-kcore fix_buildid_cache_permissions
 
+hist.*::
+	hist.percentage::
+		This option control a way to calcurate overhead of filtered entries -
+		that means the value of this option is effective only if there's a
+		filter (by comm, dso or symbol name). Suppose a following example:
+
+		       Overhead  Symbols
+		       ........  .......
+		        33.33%     foo
+		        33.33%     bar
+		        33.33%     baz
+
+	       This is an original overhead and we'll filter out the first 'foo'
+	       entry. The value of 'relative' would increase the overhead of 'bar'
+	       and 'baz' to 50.00% for each, while 'absolute' would show their
+	       current overhead (33.33%).
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer Acked-by on v11 8/24
#21 lore raw

Re: [PATCH v11 08/24] perf config: Document 'hist.percentage' variable in man page

Quoted 4 lines · Taeung Song

Explain 'hist.percentage' variable.

One nitpick below..

Quoted 9 lines
---
 tools/perf/Documentation/perf-config.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 88e9b88..b166b81 100644

tools/perf/Documentation/perf-config.txt help.*:: · line 268

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +3 -0
@@ -263,6 +263,23 @@ help.*::
 		<perf sub-command> can be record, script, report or inject
 		    or: perf-with-kcore fix_buildid_cache_permissions
 
+hist.*::
+	hist.percentage::
+		This option control a way to calcurate overhead of filtered entries -

s/control a way/controls the way/, s/calcurate/calculate/

Thanks,
Namhyung

Quoted 20 lines
tools/perf/Documentation/perf-config.txt +14 -0
+		that means the value of this option is effective only if there's a
+		filter (by comm, dso or symbol name). Suppose a following example:
+
+		       Overhead  Symbols
+		       ........  .......
+		        33.33%     foo
+		        33.33%     bar
+		        33.33%     baz
+
+	       This is an original overhead and we'll filter out the first 'foo'
+	       entry. The value of 'relative' would increase the overhead of 'bar'
+	       and 'baz' to 50.00% for each, while 'absolute' would show their
+	       current overhead (33.33%).
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#22 lore raw

PATCH v11 9/24 perf config: Document 'ui.show-headers' variable in man page

In reply to Taeung Song

Explain 'ui.show-headers' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +5 -0
index b166b81..7d386d4 100644
@@ -280,6 +280,11 @@ hist.*::
 	       and 'baz' to 50.00% for each, while 'absolute' would show their
 	       current overhead (33.33%).
 
+ui.*::
+	ui.show-headers::
+		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.
+		If this option is false, they are hiden. This option is only applied to TUI.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#23 lore raw

Re: [PATCH v11 09/24] perf config: Document 'ui.show-headers' variable in man page

Quoted 14 lines · Taeung Song

Explain 'ui.show-headers' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index b166b81..7d386d4 100644

tools/perf/Documentation/perf-config.txt hist.*:: · line 285

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +3 -0
@@ -280,6 +280,11 @@ hist.*::
 	       and 'baz' to 50.00% for each, while 'absolute' would show their
 	       current overhead (33.33%).
 
+ui.*::
+	ui.show-headers::
+		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.

How about this?

This option controls display of column headers (like 'Overhead' and 'Symbol') in 'report' and 'top'.

tools/perf/Documentation/perf-config.txt hist.*:: · line 286

Quoted 1 line
tools/perf/Documentation/perf-config.txt +1 -0
+		If this option is false, they are hiden. This option is only applied to TUI.

s/hiden/hidden/

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#24 lore raw

PATCH v11 10/24 perf config: Document variables for 'call-graph' section in man page

In reply to Taeung Song

Explain 'call-graph' section and its variables.

'record-mode', 'dump-size', 'print-type', 'order', 'sort-key', 'threshold' and 'print-limit'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 65 ++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
tools/perf/Documentation/perf-config.txt +65 -0
index 7d386d4..dc659d6 100644
@@ -285,6 +285,71 @@ ui.*::
 		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.
 		If this option is false, they are hiden. This option is only applied to TUI.
 
+call-graph.*::
+	When sub-commands 'top' and 'report' work with -g/—-children
+	there're options in control of call-graph.
+
+	call-graph.record-mode::
+		The record-mode can be 'fp' (frame pointer) and 'dwarf'.
+		The value of 'dwarf' is effective only if perf detect needed library
+		(libunwind or a recent version of libdw).  Also it doesn't *require*
+		the dump-size option since it can use the default value of 8192 if
+		missing.
+
+	call-graph.dump-size::
+		The size of stack to dump in order to do post-unwinding. Default is 8192 (byte).
+		When using dwarf into record-mode this option should have a value.
+
+	call-graph.print-type::
+		The print-types can be graph (graph absolute), fractal (graph relative), flat.
+		This option controls a way to show overhead for each callchain entry.
+		Suppose a following example.
+
+		Overhead  Symbols
+		........  .......
+		  40.00%  foo
+		      |
+		      --- foo
+		      |
+		      |--50.00%-- bar
+		      |           main
+		      |
+		      --50.00%-- baz
+		                 main
+
+		This output is a 'fractal' format. The 'foo' came from 'bar' and 'baz' exactly
+		half and half so 'fractal' shows 50.00% for each
+		(meaning that it assumes 100% total overhead of 'foo').
+
+		The 'graph' uses absolute overhead value of 'foo' as total so each of
+		'bar' and 'baz' callchain will have 20.00% of overhead.
+
+	call-graph.order::
+		This option controls print order of callchains. The default is
+		'callee' which means callee is printed at top and then followed by its
+		caller and so on. The 'caller' prints it in reverse order.
+
+		If this option is not set and report.children or top.children is
+		set to true (or the equivalent command line option is given),
+		the default value of this option is changed to 'caller' for the
+		execution of 'perf report' or 'perf top'. Other commands will
+		still default to 'callee'.
+
+	call-graph.sort-key::
+		The callchains are merged if they contain same information.
+		The sort-key option determines a way to compare the callchains.
+		A value of 'sort-key' can be 'function' or 'address'.
+		The default is 'function'.
+
+	call-graph.threshold::
+		When there're many callchains it'd print tons of lines.  So perf omits
+		small callchains under a certain overhead (threshold) and this option
+		control the threashold. Default is 0.5 (%).
+
+	call-graph.print-limit::
+		This is another way to control the number of callchains printed for a
+		single entry. Default is 0 which means no limitation.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#25 lore raw

Re: [PATCH v11 10/24] perf config: Document variables for 'call-graph' section in man page

Quoted 17 lines · Taeung Song

Explain 'call-graph' section and its variables.

'record-mode', 'dump-size', 'print-type', 'order', 'sort-key', 'threshold' and 'print-limit'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 65 ++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 7d386d4..dc659d6 100644

tools/perf/Documentation/perf-config.txt ui.*:: · line 293

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +6 -0
@@ -285,6 +285,71 @@ ui.*::
 		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.
 		If this option is false, they are hiden. This option is only applied to TUI.
 
+call-graph.*::
+	When sub-commands 'top' and 'report' work with -g/—-children
+	there're options in control of call-graph.
+
+	call-graph.record-mode::
+		The record-mode can be 'fp' (frame pointer) and 'dwarf'.

Also 'lbr' can be used, but it only work for recent intel cpus.

tools/perf/Documentation/perf-config.txt ui.*:: · line 297

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+		The value of 'dwarf' is effective only if perf detect needed library
+		(libunwind or a recent version of libdw).  Also it doesn't *require*
+		the dump-size option since it can use the default value of 8192 if
+		missing.

I think the last sentence can be omitted.

tools/perf/Documentation/perf-config.txt ui.*:: · line 301

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.dump-size::
+		The size of stack to dump in order to do post-unwinding. Default is 8192 (byte).
+		When using dwarf into record-mode this option should have a value.

This contradicts the above, it'll use the default size if omitted.

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +7 -0
+
+	call-graph.print-type::
+		The print-types can be graph (graph absolute), fractal (graph relative), flat.
+		This option controls a way to show overhead for each callchain entry.
+		Suppose a following example.
+
+		Overhead  Symbols

tools/perf/Documentation/perf-config.txt ui.*:: · line 318

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+		........  .......
+		  40.00%  foo
+		      |
+		      --- foo
+		      |
+		      |--50.00%-- bar
+		      |           main
+		      |
+		      --50.00%-- baz
+		                 main

^
it needs one more whitespace

Quoted 19 lines
tools/perf/Documentation/perf-config.txt +19 -0
+
+		This output is a 'fractal' format. The 'foo' came from 'bar' and 'baz' exactly
+		half and half so 'fractal' shows 50.00% for each
+		(meaning that it assumes 100% total overhead of 'foo').
+
+		The 'graph' uses absolute overhead value of 'foo' as total so each of
+		'bar' and 'baz' callchain will have 20.00% of overhead.
+
+	call-graph.order::
+		This option controls print order of callchains. The default is
+		'callee' which means callee is printed at top and then followed by its
+		caller and so on. The 'caller' prints it in reverse order.
+
+		If this option is not set and report.children or top.children is
+		set to true (or the equivalent command line option is given),
+		the default value of this option is changed to 'caller' for the
+		execution of 'perf report' or 'perf top'. Other commands will
+		still default to 'callee'.
+

tools/perf/Documentation/perf-config.txt ui.*:: · line 347

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+	call-graph.sort-key::
+		The callchains are merged if they contain same information.
+		The sort-key option determines a way to compare the callchains.
+		A value of 'sort-key' can be 'function' or 'address'.
+		The default is 'function'.
+
+	call-graph.threshold::
+		When there're many callchains it'd print tons of lines.  So perf omits
+		small callchains under a certain overhead (threshold) and this option
+		control the threashold. Default is 0.5 (%).

s/threashold/threshold/

Also it'd be better to mention that the overhead is calculated by value depends on call-graph.print-type.

tools/perf/Documentation/perf-config.txt ui.*:: · line 351

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.print-limit::
+		This is another way to control the number of callchains printed for a
+		single entry. Default is 0 which means no limitation.

This is a maximum number of lines of callchain printed for a single histogram entry.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#26 lore raw

Re: [PATCH v11 10/24] perf config: Document variables for 'call-graph' section in man page

Hi, Namhyung

Quoted 61 lines · Namhyung Kim
Quoted 17 lines · Taeung Song

Explain 'call-graph' section and its variables.

'record-mode', 'dump-size', 'print-type', 'order', 'sort-key', 'threshold' and 'print-limit'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 65 ++++++++++++++++++++++++++++++++

1 file changed, 65 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 7d386d4..dc659d6 100644

tools/perf/Documentation/perf-config.txt ui.*:: · line 293

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +6 -0
@@ -285,6 +285,71 @@ ui.*::
 		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.
 		If this option is false, they are hiden. This option is only applied to TUI.
 
+call-graph.*::
+	When sub-commands 'top' and 'report' work with -g/—-children
+	there're options in control of call-graph.
+
+	call-graph.record-mode::
+		The record-mode can be 'fp' (frame pointer) and 'dwarf'.

Also 'lbr' can be used, but it only work for recent intel cpus.

tools/perf/Documentation/perf-config.txt ui.*:: · line 297

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+		The value of 'dwarf' is effective only if perf detect needed library
+		(libunwind or a recent version of libdw).  Also it doesn't *require*
+		the dump-size option since it can use the default value of 8192 if
+		missing.

I think the last sentence can be omitted.

tools/perf/Documentation/perf-config.txt ui.*:: · line 301

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.dump-size::
+		The size of stack to dump in order to do post-unwinding. Default is 8192 (byte).
+		When using dwarf into record-mode this option should have a value.

This contradicts the above, it'll use the default size if omitted.

Quoted 12 lines
tools/perf/Documentation/perf-config.txt +12 -0
+
+	call-graph.print-type::
+		The print-types can be graph (graph absolute), fractal (graph relative), flat.
+		This option controls a way to show overhead for each callchain entry.
+		Suppose a following example.
+
+		Overhead  Symbols
+		........  .......
+		  40.00%  foo
+		      |
+		      --- foo
+		      |
Quoted 9 lines

tools/perf/Documentation/perf-config.txt ui.*:: · line 318

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +5 -0
+		      |--50.00%-- bar
+		      |           main
+		      |
+		      --50.00%-- baz
+		                 main

^
it needs one more whitespace

I checked this patch file and whitespace and tab characters on it. But I think the lacking whitespace because of mail client. After 'make install’ I checked it but there is no lack of whitespace. Are there different problems that I missed ?

Thanks,
Taeung

Quoted 55 lines
Quoted 20 lines
tools/perf/Documentation/perf-config.txt +19 -0
+
+		This output is a 'fractal' format. The 'foo' came from 'bar' and 'baz' exactly
+		half and half so 'fractal' shows 50.00% for each
+		(meaning that it assumes 100% total overhead of 'foo').
+
+		The 'graph' uses absolute overhead value of 'foo' as total so each of
+		'bar' and 'baz' callchain will have 20.00% of overhead.
+
+	call-graph.order::
+		This option controls print order of callchains. The default is
+		'callee' which means callee is printed at top and then followed by its
+		caller and so on. The 'caller' prints it in reverse order.
+
+		If this option is not set and report.children or top.children is
+		set to true (or the equivalent command line option is given),
+		the default value of this option is changed to 'caller' for the
+		execution of 'perf report' or 'perf top'. Other commands will
+		still default to 'callee'.
+

tools/perf/Documentation/perf-config.txt ui.*:: · line 347

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+	call-graph.sort-key::
+		The callchains are merged if they contain same information.
+		The sort-key option determines a way to compare the callchains.
+		A value of 'sort-key' can be 'function' or 'address'.
+		The default is 'function'.
+
+	call-graph.threshold::
+		When there're many callchains it'd print tons of lines.  So perf omits
+		small callchains under a certain overhead (threshold) and this option
+		control the threashold. Default is 0.5 (%).

s/threashold/threshold/

Also it'd be better to mention that the overhead is calculated by value depends on call-graph.print-type.

tools/perf/Documentation/perf-config.txt ui.*:: · line 351

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.print-limit::
+		This is another way to control the number of callchains printed for a
+		single entry. Default is 0 which means no limitation.

This is a maximum number of lines of callchain printed for a single histogram entry.

Thanks,
Namhyung

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +1 -0
+

SEE ALSO
--------
linkperf:perf[1]

Signature · 1 line
1.9.1
maintainer
#27 lore raw

Re: [PATCH v11 10/24] perf config: Document variables for 'call-graph' section in man page

Quoted 1 line · Taeung Song

Hi, Namhyung

Hi Taeung,

Quoted 49 lines
Quoted 49 lines · Namhyung Kim
Quoted 17 lines · Taeung Song

Explain 'call-graph' section and its variables.

'record-mode', 'dump-size', 'print-type', 'order', 'sort-key', 'threshold' and 'print-limit'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>

---
tools/perf/Documentation/perf-config.txt | 65 ++++++++++++++++++++++++++++++++

1 file changed, 65 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 7d386d4..dc659d6 100644

tools/perf/Documentation/perf-config.txt ui.*:: · line 293

Quoted 9 lines
tools/perf/Documentation/perf-config.txt +6 -0
@@ -285,6 +285,71 @@ ui.*::
 		There're columns as header 'Overhead', 'Children', 'Shared Object', 'Symbol', 'self'.
 		If this option is false, they are hiden. This option is only applied to TUI.
 
+call-graph.*::
+	When sub-commands 'top' and 'report' work with -g/—-children
+	there're options in control of call-graph.
+
+	call-graph.record-mode::
+		The record-mode can be 'fp' (frame pointer) and 'dwarf'.

Also 'lbr' can be used, but it only work for recent intel cpus.

tools/perf/Documentation/perf-config.txt ui.*:: · line 297

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+		The value of 'dwarf' is effective only if perf detect needed library
+		(libunwind or a recent version of libdw).  Also it doesn't *require*
+		the dump-size option since it can use the default value of 8192 if
+		missing.

I think the last sentence can be omitted.

tools/perf/Documentation/perf-config.txt ui.*:: · line 301

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.dump-size::
+		The size of stack to dump in order to do post-unwinding. Default is 8192 (byte).
+		When using dwarf into record-mode this option should have a value.

This contradicts the above, it'll use the default size if omitted.

Quoted 3 lines
Quoted 3 lines

tools/perf/Documentation/perf-config.txt ui.*:: · line 304

Quoted 3 lines
tools/perf/Documentation/perf-config.txt +3 -0
+
+	call-graph.print-type::
+		The print-types can be graph (graph absolute), fractal (graph relative), flat.

The 'folded' print type was added recently. Please update it too.

Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
tools/perf/Documentation/perf-config.txt +9 -0
+		This option controls a way to show overhead for each callchain entry.
+		Suppose a following example.
+
+		Overhead  Symbols
+		........  .......
+		  40.00%  foo
+		      |
+		      --- foo
+		      |
Quoted 9 lines

tools/perf/Documentation/perf-config.txt ui.*:: · line 318

Quoted 5 lines
tools/perf/Documentation/perf-config.txt +5 -0
+		      |--50.00%-- bar
+		      |           main
+		      |
+		      --50.00%-- baz
+		                 main

^
it needs one more whitespace

Quoted 4 lines

I checked this patch file and whitespace and tab characters on it. But I think the lacking whitespace because of mail client. After 'make install’ I checked it but there is no lack of whitespace. Are there different problems that I missed ?

I meant whitespace in the callchain graph (i.e. 'bar' and 'baz' should be aligned). But I think I was wrong - it should look like below:

  Overhead  Symbols
  ........  .......
    40.00%  foo
            |
            ---foo
               |
               |--50.00%--bar
               |          main
               |
                --50.00%--baz
                          main

Maybe it's because you used TAB characters for indent?

Thanks,
Namhyung

Quoted 57 lines
Quoted 56 lines
Quoted 21 lines
tools/perf/Documentation/perf-config.txt +19 -0
+
+		This output is a 'fractal' format. The 'foo' came from 'bar' and 'baz' exactly
+		half and half so 'fractal' shows 50.00% for each
+		(meaning that it assumes 100% total overhead of 'foo').
+
+		The 'graph' uses absolute overhead value of 'foo' as total so each of
+		'bar' and 'baz' callchain will have 20.00% of overhead.
+
+	call-graph.order::
+		This option controls print order of callchains. The default is
+		'callee' which means callee is printed at top and then followed by its
+		caller and so on. The 'caller' prints it in reverse order.
+
+		If this option is not set and report.children or top.children is
+		set to true (or the equivalent command line option is given),
+		the default value of this option is changed to 'caller' for the
+		execution of 'perf report' or 'perf top'. Other commands will
+		still default to 'callee'.
+

tools/perf/Documentation/perf-config.txt ui.*:: · line 347

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +10 -0
+	call-graph.sort-key::
+		The callchains are merged if they contain same information.
+		The sort-key option determines a way to compare the callchains.
+		A value of 'sort-key' can be 'function' or 'address'.
+		The default is 'function'.
+
+	call-graph.threshold::
+		When there're many callchains it'd print tons of lines.  So perf omits
+		small callchains under a certain overhead (threshold) and this option
+		control the threashold. Default is 0.5 (%).

s/threashold/threshold/

Also it'd be better to mention that the overhead is calculated by value depends on call-graph.print-type.

tools/perf/Documentation/perf-config.txt ui.*:: · line 351

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	call-graph.print-limit::
+		This is another way to control the number of callchains printed for a
+		single entry. Default is 0 which means no limitation.

This is a maximum number of lines of callchain printed for a single histogram entry.

Thanks,
Namhyung

Quoted 6 lines
tools/perf/Documentation/perf-config.txt +1 -0
+

SEE ALSO
--------
linkperf:perf[1]

Signature · 1 line
1.9.1
#28 lore raw

PATCH v11 11/24 perf config: Document variables for 'report' section in man page

In reply to Taeung Song

Explain 'report' section's variables.

'percent-limit', 'queue-size' and 'children'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tools/perf/Documentation/perf-config.txt +17 -0
index dc659d6..b9f89dd 100644
@@ -350,6 +350,23 @@ call-graph.*::
 		This is another way to control the number of callchains printed for a
 		single entry. Default is 0 which means no limitation.
 
+report.*::
+	report.percent-limit::
+		This one is mostly same as call-graph.threshold but works for
+		histogram entries. Entries have overhead lower than this percentage
+		will not be printed. Default is 0.
+		If percent-limit is 70, the output which has percentages of
+		each overhead above 70% can be printed.
+
+	report.queue-size::
+		option to setup the maximum allocation size for session's
+		ordered events queue, if not set there's no default limit.
+
+	report.children::
+		The children means that functions called from another function.
+		If the option is true, accumulate callchain of children and show total overhead.
+		Please refer to the perf-report manual. The default is true.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#29 lore raw

Re: [PATCH v11 11/24] perf config: Document variables for 'report' section in man page

Quoted 16 lines · Taeung Song

Explain 'report' section's variables.

'percent-limit', 'queue-size' and 'children'.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index dc659d6..b9f89dd 100644

tools/perf/Documentation/perf-config.txt call-graph.*:: · line 359

Quoted 10 lines
tools/perf/Documentation/perf-config.txt +7 -0
@@ -350,6 +350,23 @@ call-graph.*::
 		This is another way to control the number of callchains printed for a
 		single entry. Default is 0 which means no limitation.
 
+report.*::
+	report.percent-limit::
+		This one is mostly same as call-graph.threshold but works for
+		histogram entries. Entries have overhead lower than this percentage
+		will not be printed. Default is 0.
+		If percent-limit is 70, the output which has percentages of
+		each overhead above 70% can be printed.

70% is an unrealistric example IMHO. :) How about this?

If percent-limit is 10, entries which have more than 10% of overhead will be printed only.

tools/perf/Documentation/perf-config.txt call-graph.*:: · line 363

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	report.queue-size::
+		option to setup the maximum allocation size for session's
+		ordered events queue, if not set there's no default limit.

This option is to setup the maximum allocation size of internal event queue for ordering events. Default is 0, meaning no limit.

tools/perf/Documentation/perf-config.txt call-graph.*:: · line 367

Quoted 4 lines
tools/perf/Documentation/perf-config.txt +4 -0
+
+	report.children::
+		The children means that functions called from another function.
+		If the option is true, accumulate callchain of children and show total overhead.

If this option is true, perf report cumulates callchains of children and show (accumulated) total overhead as well as self overhead.

Thanks,
Namhyung

Quoted 8 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		Please refer to the perf-report manual. The default is true.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#30 lore raw

PATCH v11 12/24 perf config: Document 'top.chidren' variable in man page

In reply to Taeung Song

Explain 'top.children' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 6 ++++++
 1 file changed, 6 insertions(+)
tools/perf/Documentation/perf-config.txt +6 -0
index b9f89dd..344feb8 100644
@@ -367,6 +367,12 @@ report.*::
 		If the option is true, accumulate callchain of children and show total overhead.
 		Please refer to the perf-report manual. The default is true.
 
+top.*::
+	top.children::
+		This option means same as report.children. So it is true,
+		the output of 'top' is rearranged by each overhead into children group.
+		The default is true.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#31 lore raw

Re: [PATCH v11 12/24] perf config: Document 'top.chidren' variable in man page

Quoted 14 lines · Taeung Song

Explain 'top.children' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 6 ++++++
 1 file changed, 6 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index b9f89dd..344feb8 100644

tools/perf/Documentation/perf-config.txt report.*:: · line 373

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +4 -0
@@ -367,6 +367,12 @@ report.*::
 		If the option is true, accumulate callchain of children and show total overhead.
 		Please refer to the perf-report manual. The default is true.
 
+top.*::
+	top.children::
+		This option means same as report.children. So it is true,
+		the output of 'top' is rearranged by each overhead into children group.

This option means same as report.children. So if it's true, the output of 'top' command will have 'Children' overhead column as well as 'Self' overhead column by default.

Thanks,
Namhyung

Quoted 8 lines
tools/perf/Documentation/perf-config.txt +2 -0
+		The default is true.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#32 lore raw

PATCH v11 13/24 perf config: Document 'man.viewer' variable in man page

In reply to Taeung Song

Explain 'man.viewer' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +5 -0
index 344feb8..ea1d3e1 100644
@@ -373,6 +373,11 @@ top.*::
 		the output of 'top' is rearranged by each overhead into children group.
 		The default is true.
 
+man.*::
+	man.viewer::
+		This option can assign a manual tool with which a subcommand 'help' work.
+		it can used as 'man', 'woman', 'konqueror'. Default value is 'man'.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#33 lore raw

Re: [PATCH v11 13/24] perf config: Document 'man.viewer' variable in man page

Quoted 13 lines · Taeung Song

Explain 'man.viewer' variable.

---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 344feb8..ea1d3e1 100644

tools/perf/Documentation/perf-config.txt top.*:: · line 379

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +4 -0
@@ -373,6 +373,11 @@ top.*::
 		the output of 'top' is rearranged by each overhead into children group.
 		The default is true.
 
+man.*::
+	man.viewer::
+		This option can assign a manual tool with which a subcommand 'help' work.
+		it can used as 'man', 'woman', 'konqueror'. Default value is 'man'.

This option can assign a tool to view manual pages when 'help' subcommand was invoked. Supported tools are 'man', 'woman' (with emacs client), and 'konqueror'. Default is 'man'.

It seems one can also add new man viewer tool using 'man.<tool>.cmd' or use different path using 'man.<tool>.path' config option.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#34 lore raw

PATCH v11 14/24 perf config: Document 'pager.<subcommand>' variables in man page

In reply to Taeung Song

Explain 'pager.<subcommand>' variables.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +5 -0
index ea1d3e1..8e7ffde 100644
@@ -378,6 +378,11 @@ man.*::
 		This option can assign a manual tool with which a subcommand 'help' work.
 		it can used as 'man', 'woman', 'konqueror'. Default value is 'man'.
 
+pager.*::
+	pager.<subcommand>::
+		When a subcommand work as stdio instead of TUI, use pager with it.
+		Default value is 'true'.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#35 lore raw

Re: [PATCH v11 14/24] perf config: Document 'pager.<subcommand>' variables in man page

Quoted 14 lines · Taeung Song

Explain 'pager.<subcommand>' variables.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index ea1d3e1..8e7ffde 100644

tools/perf/Documentation/perf-config.txt man.*:: · line 384

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +4 -0
@@ -378,6 +378,11 @@ man.*::
 		This option can assign a manual tool with which a subcommand 'help' work.
 		it can used as 'man', 'woman', 'konqueror'. Default value is 'man'.
 
+pager.*::
+	pager.<subcommand>::
+		When a subcommand work as stdio instead of TUI, use pager with it.
+		Default value is 'true'.

When the subcommand is run on stdio, determine whether it uses pager or not based on this value. Default is 'unspecified'.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#36 lore raw

PATCH v11 15/24 perf config: Document 'kmem.default' variable in man page

In reply to Taeung Song

Explain 'kmem.default' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 6 ++++++
 1 file changed, 6 insertions(+)
tools/perf/Documentation/perf-config.txt +6 -0
index 8e7ffde..95255a0 100644
@@ -383,6 +383,12 @@ pager.*::
 		When a subcommand work as stdio instead of TUI, use pager with it.
 		Default value is 'true'.
 
+kmem.*::
+	kmem.default::
+		This option can decide which allocator is analyzed between 'slab' and 'page'
+		without using options '--slab' and '--page'.
+		Default value is 'slab'.
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
maintainer
#37 lore raw

Re: [PATCH v11 15/24] perf config: Document 'kmem.default' variable in man page

Quoted 14 lines · Taeung Song

Explain 'kmem.default' variable.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 6 ++++++
 1 file changed, 6 insertions(+)
tools/perf/Documentation/perf-config.txt +0 -0
index 8e7ffde..95255a0 100644

tools/perf/Documentation/perf-config.txt pager.*:: · line 390

Quoted 8 lines
tools/perf/Documentation/perf-config.txt +5 -0
@@ -383,6 +383,12 @@ pager.*::
 		When a subcommand work as stdio instead of TUI, use pager with it.
 		Default value is 'true'.
 
+kmem.*::
+	kmem.default::
+		This option can decide which allocator is analyzed between 'slab' and 'page'
+		without using options '--slab' and '--page'.
+		Default value is 'slab'.

This option decides which allocator is to be analyzed if neither '--slab' nor '--page' option is used. Default is 'slab'.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/Documentation/perf-config.txt +1 -0
+
 SEE ALSO
 --------
 linkperf:perf[1]
Signature · 1 line
1.9.1
#38 lore raw

PATCH v11 16/24 perf config: Add '--system' and '--user' options to select which config file is used

In reply to Taeung Song

The file-options '--system' means $(sysconfdir)/perfconfig and '--user' means $HOME/.perfconfig. If file-option isn't used, both system and user config file is read.
The syntax examples are like below.

perf config [<file-option>] [options]

a specific config file.
# perf config --user | --system
or
both user and system config file.
# perf config

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt | 14 +++++++++++++-
 tools/perf/builtin-config.c              | 18 +++++++++++++++++-
 tools/perf/util/cache.h                  |  3 +++
 tools/perf/util/config.c                 |  4 ++--
 4 files changed, 35 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-config.txt +13 -1
index 95255a0..f556672 100644
@@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 --------
 [verse]
-'perf config' -l | --list
+'perf config' [<file-option>] -l | --list
 
 DESCRIPTION
 -----------
@@ -21,6 +21,14 @@ OPTIONS
 --list::
 	Show current config variables, name and value, for all sections.
 
+--user::
+	For writing and reading options: write to user
+	'$HOME/.perfconfig' file or read it.
+
+--system::
+	For writing and reading options: write to system-wide
+	'$(sysconfdir)/perfconfig' or read it.
+
 CONFIGURATION FILE
 ------------------
 
@@ -30,6 +38,10 @@ The '$HOME/.perfconfig' file is used to store a per-user configuration.
 The file '$(sysconfdir)/perfconfig' can be used to
 store a system-wide default configuration.
 
+When reading or writing, the values are read from the system and user
+configuration files by default, and options '--system' and '--user'
+can be used to tell the command to read from or write to only that location.
+
 Syntax
 ~~~~~~
 
tools/perf/builtin-config.c +17 -1
index 427ea7a..e0f8b41 100644
@@ -13,8 +13,10 @@
 #include "util/util.h"
 #include "util/debug.h"
 
+static bool use_system_config, use_user_config;
+
 static const char * const config_usage[] = {
-	"perf config [options]",
+	"perf config [<file-option>] [options]",
 	NULL
 };
 
@@ -25,6 +27,8 @@ enum actions {
 static struct option config_options[] = {
 	OPT_SET_UINT('l', "list", &actions,
 		     "show current config variables", ACTION_LIST),
+	OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
+	OPT_BOOLEAN(0, "user", &use_user_config, "use user config file"),
 	OPT_END()
 };
 
@@ -46,6 +50,18 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (use_system_config && use_user_config) {
+		pr_err("Error: only one config file at a time\n");
+		parse_options_usage(config_usage, config_options, "user", 0);
+		parse_options_usage(NULL, config_options, "system", 0);
+		return -1;
+	}
+
+	if (use_system_config)
+		config_exclusive_filename = perf_etc_perfconfig();
+	else if (use_user_config)
+		config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
+
 	switch (actions) {
 	case ACTION_LIST:
 		if (argc) {
tools/perf/util/cache.h +3 -0
index c861373..d1eb75f 100644
@@ -19,6 +19,8 @@
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
+extern const char *config_exclusive_filename;
+
 typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int perf_default_config(const char *, const char *, void *);
 extern int perf_config(config_fn_t fn, void *);
@@ -27,6 +29,7 @@ extern u64 perf_config_u64(const char *, const char *);
 extern int perf_config_bool(const char *, const char *);
 extern int config_error_nonbool(const char *);
 extern const char *perf_config_dirname(const char *, const char *);
+extern const char *perf_etc_perfconfig(void);
 
 /* pager.c */
 extern void setup_pager(void);
tools/perf/util/config.c +2 -2
index 2e452ac..55ef373 100644
@@ -26,7 +26,7 @@ static const char *config_file_name;
 static int config_linenr;
 static int config_file_eof;
 
-static const char *config_exclusive_filename;
+const char *config_exclusive_filename;
 
 static int get_next_char(void)
 {
@@ -434,7 +434,7 @@ static int perf_config_from_file(config_fn_t fn, const char *filename, void *dat
 	return ret;
 }
 
-static const char *perf_etc_perfconfig(void)
+const char *perf_etc_perfconfig(void)
 {
 	static const char *system_wide;
 	if (!system_wide)
Signature · 1 line
1.9.1
maintainer Acked-by on v11 16/24
#39 lore raw

Re: [PATCH v11 16/24] perf config: Add '--system' and '--user' options to select which config file is used

Quoted 7 lines · Taeung Song

The file-options '--system' means $(sysconfdir)/perfconfig and '--user' means $HOME/.perfconfig. If file-option isn't used, both system and user config file is read.
The syntax examples are like below.

perf config [<file-option>] [options]

Quoted 8 lines

a specific config file.
# perf config --user | --system
or
both user and system config file.
# perf config

Thanks,
Namhyung

Quoted 136 lines
---
 tools/perf/Documentation/perf-config.txt | 14 +++++++++++++-
 tools/perf/builtin-config.c              | 18 +++++++++++++++++-
 tools/perf/util/cache.h                  |  3 +++
 tools/perf/util/config.c                 |  4 ++--
 4 files changed, 35 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-config.txt +13 -1
index 95255a0..f556672 100644
@@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 --------
 [verse]
-'perf config' -l | --list
+'perf config' [<file-option>] -l | --list
 
 DESCRIPTION
 -----------
@@ -21,6 +21,14 @@ OPTIONS
 --list::
 	Show current config variables, name and value, for all sections.
 
+--user::
+	For writing and reading options: write to user
+	'$HOME/.perfconfig' file or read it.
+
+--system::
+	For writing and reading options: write to system-wide
+	'$(sysconfdir)/perfconfig' or read it.
+
 CONFIGURATION FILE
 ------------------
 
@@ -30,6 +38,10 @@ The '$HOME/.perfconfig' file is used to store a per-user configuration.
 The file '$(sysconfdir)/perfconfig' can be used to
 store a system-wide default configuration.
 
+When reading or writing, the values are read from the system and user
+configuration files by default, and options '--system' and '--user'
+can be used to tell the command to read from or write to only that location.
+
 Syntax
 ~~~~~~
 
tools/perf/builtin-config.c +17 -1
index 427ea7a..e0f8b41 100644
@@ -13,8 +13,10 @@
 #include "util/util.h"
 #include "util/debug.h"
 
+static bool use_system_config, use_user_config;
+
 static const char * const config_usage[] = {
-	"perf config [options]",
+	"perf config [<file-option>] [options]",
 	NULL
 };
 
@@ -25,6 +27,8 @@ enum actions {
 static struct option config_options[] = {
 	OPT_SET_UINT('l', "list", &actions,
 		     "show current config variables", ACTION_LIST),
+	OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
+	OPT_BOOLEAN(0, "user", &use_user_config, "use user config file"),
 	OPT_END()
 };
 
@@ -46,6 +50,18 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (use_system_config && use_user_config) {
+		pr_err("Error: only one config file at a time\n");
+		parse_options_usage(config_usage, config_options, "user", 0);
+		parse_options_usage(NULL, config_options, "system", 0);
+		return -1;
+	}
+
+	if (use_system_config)
+		config_exclusive_filename = perf_etc_perfconfig();
+	else if (use_user_config)
+		config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
+
 	switch (actions) {
 	case ACTION_LIST:
 		if (argc) {
tools/perf/util/cache.h +3 -0
index c861373..d1eb75f 100644
@@ -19,6 +19,8 @@
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
+extern const char *config_exclusive_filename;
+
 typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int perf_default_config(const char *, const char *, void *);
 extern int perf_config(config_fn_t fn, void *);
@@ -27,6 +29,7 @@ extern u64 perf_config_u64(const char *, const char *);
 extern int perf_config_bool(const char *, const char *);
 extern int config_error_nonbool(const char *);
 extern const char *perf_config_dirname(const char *, const char *);
+extern const char *perf_etc_perfconfig(void);
 
 /* pager.c */
 extern void setup_pager(void);
tools/perf/util/config.c +2 -2
index 2e452ac..55ef373 100644
@@ -26,7 +26,7 @@ static const char *config_file_name;
 static int config_linenr;
 static int config_file_eof;
 
-static const char *config_exclusive_filename;
+const char *config_exclusive_filename;
 
 static int get_next_char(void)
 {
@@ -434,7 +434,7 @@ static int perf_config_from_file(config_fn_t fn, const char *filename, void *dat
 	return ret;
 }
 
-static const char *perf_etc_perfconfig(void)
+const char *perf_etc_perfconfig(void)
 {
 	static const char *system_wide;
 	if (!system_wide)
Signature · 1 line
1.9.1
#40 lore raw

PATCH v11 17/24 perf config: Collect configs to handle config variables

In reply to Taeung Song

Collecting configs into list because of two reason.

First of all, if there are same variables both user and system config file, they all will be printed when 'list' command work. But if config variables are duplicated, user config variables should only be printed because it has priority.

Lastly, list into which configs is collected will be required to keep and handle config variables and values in the near furture. For example, getting or setting functionality.

And change show_config() function.
Old show_config() worked depending on perf_config(). New show_config() work using collected configs list.

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/builtin-config.c | 150 ++++++++++++++++++++++++++++++++++++++++++--
 tools/perf/util/cache.h     |  13 ++++
 2 files changed, 158 insertions(+), 5 deletions(-)
tools/perf/builtin-config.c +145 -5
index e0f8b41..185aa5e 100644
@@ -32,13 +32,148 @@ static struct option config_options[] = {
 	OPT_END()
 };
 
-static int show_config(const char *key, const char *value,
-		       void *cb __maybe_unused)
+static struct config_section *find_section(struct list_head *sections,
+					   const char *section_name)
 {
+	struct config_section *section;
+
+	list_for_each_entry(section, sections, list)
+		if (!strcmp(section->name, section_name))
+			return section;
+
+	return NULL;
+}
+
+static struct config_element *find_element(const char *name,
+					   struct config_section *section)
+{
+	struct config_element *element;
+
+	list_for_each_entry(element, &section->element_head, list)
+		if (!strcmp(element->name, name))
+			return element;
+
+	return NULL;
+}
+
+static void find_config(struct list_head *sections,
+			struct config_section **section,
+			struct config_element **element,
+			const char *section_name, const char *name)
+{
+	*section = find_section(sections, section_name);
+
+	if (*section != NULL)
+		*element = find_element(name, *section);
+	else
+		*element = NULL;
+}
+
+static struct config_section *init_section(const char *section_name)
+{
+	struct config_section *section;
+
+	section = zalloc(sizeof(*section));
+	if (!section)
+		return NULL;
+
+	INIT_LIST_HEAD(&section->element_head);
+	section->name = strdup(section_name);
+	if (!section->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(section);
+		return NULL;
+	}
+
+	return section;
+}
+
+static int add_element(struct list_head *head,
+			      const char *name, const char *value)
+{
+	struct config_element *element;
+
+	element = zalloc(sizeof(*element));
+	if (!element)
+		return -1;
+
+	element->name = strdup(name);
+	if (!element->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(element);
+		return -1;
+	}
 	if (value)
-		printf("%s=%s\n", key, value);
+		element->value = (char *)value;
 	else
-		printf("%s\n", key);
+		element->value = NULL;
+
+	list_add_tail(&element->list, head);
+	return 0;
+}
+
+static int collect_current_config(const char *var, const char *value,
+				  void *spec_sections)
+{
+	int ret = -1;
+	char *ptr, *key;
+	char *section_name, *name;
+	struct config_section *section = NULL;
+	struct config_element *element = NULL;
+	struct list_head *sections = (struct list_head *)spec_sections;
+
+	key = ptr = strdup(var);
+	if (!key) {
+		pr_err("%s: strdup failed\n", __func__);
+		return -1;
+	}
+
+	section_name = strsep(&ptr, ".");
+	name = ptr;
+	if (name == NULL || value == NULL)
+		goto out_err;
+
+	find_config(sections, &section, &element, section_name, name);
+
+	if (!section) {
+		section = init_section(section_name);
+		if (!section)
+			goto out_err;
+		list_add_tail(&section->list, sections);
+	}
+
+	value = strdup(value);
+	if (!value) {
+		pr_err("%s: strdup failed\n", __func__);
+		goto out_err;
+	}
+
+	if (!element)
+		add_element(&section->element_head, name, value);
+	else {
+		free(element->value);
+		element->value = (char *)value;
+	}
+
+	ret = 0;
+out_err:
+	free(key);
+	return ret;
+}
+
+static int show_config(struct list_head *sections)
+{
+	struct config_section *section;
+	struct config_element *element;
+
+	if (list_empty(sections))
+		return -1;
+	list_for_each_entry(section, sections, list) {
+		list_for_each_entry(element, &section->element_head, list) {
+			printf("%s.%s=%s\n", section->name,
+				       element->name, element->value);
+		}
+	}
 
 	return 0;
 }
@@ -46,6 +181,7 @@ static int show_config(const char *key, const char *value,
 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	int ret = 0;
+	struct list_head sections;
 
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
@@ -57,18 +193,22 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 		return -1;
 	}
 
+	INIT_LIST_HEAD(&sections);
+
 	if (use_system_config)
 		config_exclusive_filename = perf_etc_perfconfig();
 	else if (use_user_config)
 		config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
 
+	perf_config(collect_current_config, &sections);
+
 	switch (actions) {
 	case ACTION_LIST:
 		if (argc) {
 			pr_err("Error: takes no arguments\n");
 			parse_options_usage(config_usage, config_options, "l", 1);
 		} else {
-			ret = perf_config(show_config, NULL);
+			ret = show_config(&sections);
 			if (ret < 0)
 				pr_err("Nothing configured, "
 				       "please check your ~/.perfconfig file\n");
tools/perf/util/cache.h +13 -0
index d1eb75f..e503371 100644
@@ -1,6 +1,7 @@
 #ifndef __PERF_CACHE_H
 #define __PERF_CACHE_H
 
+#include <linux/list.h>
 #include <stdbool.h>
 #include "util.h"
 #include "strbuf.h"
@@ -19,6 +20,18 @@
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
+struct config_element {
+	char *name;
+	char *value;
+	struct list_head list;
+};
+
+struct config_section {
+	char *name;
+	struct list_head element_head;
+	struct list_head list;
+};
+
 extern const char *config_exclusive_filename;
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
Signature · 1 line
1.9.1
maintainer Acked-by on v11 17/24
#41 lore raw

Re: [PATCH v11 17/24] perf config: Collect configs to handle config variables

Quoted 13 lines · Taeung Song

Collecting configs into list because of two reason.

First of all, if there are same variables both user and system config file, they all will be printed when 'list' command work. But if config variables are duplicated, user config variables should only be printed because it has priority.

Lastly, list into which configs is collected will be required to keep and handle config variables and values in the near furture. For example, getting or setting functionality.

Quoted 6 lines

And change show_config() function.
Old show_config() worked depending on perf_config(). New show_config() work using collected configs list.

Thanks,
Namhyung

Quoted 228 lines
---
 tools/perf/builtin-config.c | 150 ++++++++++++++++++++++++++++++++++++++++++--
 tools/perf/util/cache.h     |  13 ++++
 2 files changed, 158 insertions(+), 5 deletions(-)
tools/perf/builtin-config.c +145 -5
index e0f8b41..185aa5e 100644
@@ -32,13 +32,148 @@ static struct option config_options[] = {
 	OPT_END()
 };
 
-static int show_config(const char *key, const char *value,
-		       void *cb __maybe_unused)
+static struct config_section *find_section(struct list_head *sections,
+					   const char *section_name)
 {
+	struct config_section *section;
+
+	list_for_each_entry(section, sections, list)
+		if (!strcmp(section->name, section_name))
+			return section;
+
+	return NULL;
+}
+
+static struct config_element *find_element(const char *name,
+					   struct config_section *section)
+{
+	struct config_element *element;
+
+	list_for_each_entry(element, &section->element_head, list)
+		if (!strcmp(element->name, name))
+			return element;
+
+	return NULL;
+}
+
+static void find_config(struct list_head *sections,
+			struct config_section **section,
+			struct config_element **element,
+			const char *section_name, const char *name)
+{
+	*section = find_section(sections, section_name);
+
+	if (*section != NULL)
+		*element = find_element(name, *section);
+	else
+		*element = NULL;
+}
+
+static struct config_section *init_section(const char *section_name)
+{
+	struct config_section *section;
+
+	section = zalloc(sizeof(*section));
+	if (!section)
+		return NULL;
+
+	INIT_LIST_HEAD(&section->element_head);
+	section->name = strdup(section_name);
+	if (!section->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(section);
+		return NULL;
+	}
+
+	return section;
+}
+
+static int add_element(struct list_head *head,
+			      const char *name, const char *value)
+{
+	struct config_element *element;
+
+	element = zalloc(sizeof(*element));
+	if (!element)
+		return -1;
+
+	element->name = strdup(name);
+	if (!element->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(element);
+		return -1;
+	}
 	if (value)
-		printf("%s=%s\n", key, value);
+		element->value = (char *)value;
 	else
-		printf("%s\n", key);
+		element->value = NULL;
+
+	list_add_tail(&element->list, head);
+	return 0;
+}
+
+static int collect_current_config(const char *var, const char *value,
+				  void *spec_sections)
+{
+	int ret = -1;
+	char *ptr, *key;
+	char *section_name, *name;
+	struct config_section *section = NULL;
+	struct config_element *element = NULL;
+	struct list_head *sections = (struct list_head *)spec_sections;
+
+	key = ptr = strdup(var);
+	if (!key) {
+		pr_err("%s: strdup failed\n", __func__);
+		return -1;
+	}
+
+	section_name = strsep(&ptr, ".");
+	name = ptr;
+	if (name == NULL || value == NULL)
+		goto out_err;
+
+	find_config(sections, &section, &element, section_name, name);
+
+	if (!section) {
+		section = init_section(section_name);
+		if (!section)
+			goto out_err;
+		list_add_tail(&section->list, sections);
+	}
+
+	value = strdup(value);
+	if (!value) {
+		pr_err("%s: strdup failed\n", __func__);
+		goto out_err;
+	}
+
+	if (!element)
+		add_element(&section->element_head, name, value);
+	else {
+		free(element->value);
+		element->value = (char *)value;
+	}
+
+	ret = 0;
+out_err:
+	free(key);
+	return ret;
+}
+
+static int show_config(struct list_head *sections)
+{
+	struct config_section *section;
+	struct config_element *element;
+
+	if (list_empty(sections))
+		return -1;
+	list_for_each_entry(section, sections, list) {
+		list_for_each_entry(element, &section->element_head, list) {
+			printf("%s.%s=%s\n", section->name,
+				       element->name, element->value);
+		}
+	}
 
 	return 0;
 }
@@ -46,6 +181,7 @@ static int show_config(const char *key, const char *value,
 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	int ret = 0;
+	struct list_head sections;
 
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
@@ -57,18 +193,22 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 		return -1;
 	}
 
+	INIT_LIST_HEAD(&sections);
+
 	if (use_system_config)
 		config_exclusive_filename = perf_etc_perfconfig();
 	else if (use_user_config)
 		config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
 
+	perf_config(collect_current_config, &sections);
+
 	switch (actions) {
 	case ACTION_LIST:
 		if (argc) {
 			pr_err("Error: takes no arguments\n");
 			parse_options_usage(config_usage, config_options, "l", 1);
 		} else {
-			ret = perf_config(show_config, NULL);
+			ret = show_config(&sections);
 			if (ret < 0)
 				pr_err("Nothing configured, "
 				       "please check your ~/.perfconfig file\n");
tools/perf/util/cache.h +13 -0
index d1eb75f..e503371 100644
@@ -1,6 +1,7 @@
 #ifndef __PERF_CACHE_H
 #define __PERF_CACHE_H
 
+#include <linux/list.h>
 #include <stdbool.h>
 #include "util.h"
 #include "strbuf.h"
@@ -19,6 +20,18 @@
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
+struct config_element {
+	char *name;
+	char *value;
+	struct list_head list;
+};
+
+struct config_section {
+	char *name;
+	struct list_head element_head;
+	struct list_head list;
+};
+
 extern const char *config_exclusive_filename;
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
Signature · 1 line
1.9.1
#42 lore raw

Re: [PATCH v11 17/24] perf config: Collect configs to handle config variables

Hi, Namhyung and all

(I'm modifying this patch to be tidy)
I have a mere question about name of a variable for current config list that contains section list which has key-value pairs from ~/.perfconfig or $(sysconfdir)/perfconfig config file.

(This variable is designed to be used by several functions that handle config information(key-value pairs).)

I used 'sections' for this variable (type is 'struct list_head'), but IMHO, I think that renaming it is better e.g.

1) 'cfglist'
2) 'configlist'
3) 'config_list'
4) 'cfgset'
5) 'configset'
6) 'config_set'
... :-\

It is trivial question,
but I wanna know a opinion of other people. :-)

Thanks,
Taeung

Quoted 255 lines · Namhyung Kim
Quoted 13 lines · Taeung Song

Collecting configs into list because of two reason.

First of all, if there are same variables both user and system config file, they all will be printed when 'list' command work. But if config variables are duplicated, user config variables should only be printed because it has priority.

Lastly, list into which configs is collected will be required to keep and handle config variables and values in the near furture. For example, getting or setting functionality.

Quoted 6 lines

And change show_config() function.
Old show_config() worked depending on perf_config(). New show_config() work using collected configs list.

Thanks,
Namhyung

Quoted 228 lines
---
  tools/perf/builtin-config.c | 150 ++++++++++++++++++++++++++++++++++++++++++--
  tools/perf/util/cache.h     |  13 ++++
  2 files changed, 158 insertions(+), 5 deletions(-)
tools/perf/builtin-config.c +145 -5
index e0f8b41..185aa5e 100644
@@ -32,13 +32,148 @@ static struct option config_options[] = {
  	OPT_END()
  };
 
-static int show_config(const char *key, const char *value,
-		       void *cb __maybe_unused)
+static struct config_section *find_section(struct list_head *sections,
+					   const char *section_name)
  {
+	struct config_section *section;
+
+	list_for_each_entry(section, sections, list)
+		if (!strcmp(section->name, section_name))
+			return section;
+
+	return NULL;
+}
+
+static struct config_element *find_element(const char *name,
+					   struct config_section *section)
+{
+	struct config_element *element;
+
+	list_for_each_entry(element, &section->element_head, list)
+		if (!strcmp(element->name, name))
+			return element;
+
+	return NULL;
+}
+
+static void find_config(struct list_head *sections,
+			struct config_section **section,
+			struct config_element **element,
+			const char *section_name, const char *name)
+{
+	*section = find_section(sections, section_name);
+
+	if (*section != NULL)
+		*element = find_element(name, *section);
+	else
+		*element = NULL;
+}
+
+static struct config_section *init_section(const char *section_name)
+{
+	struct config_section *section;
+
+	section = zalloc(sizeof(*section));
+	if (!section)
+		return NULL;
+
+	INIT_LIST_HEAD(&section->element_head);
+	section->name = strdup(section_name);
+	if (!section->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(section);
+		return NULL;
+	}
+
+	return section;
+}
+
+static int add_element(struct list_head *head,
+			      const char *name, const char *value)
+{
+	struct config_element *element;
+
+	element = zalloc(sizeof(*element));
+	if (!element)
+		return -1;
+
+	element->name = strdup(name);
+	if (!element->name) {
+		pr_err("%s: strdup failed\n", __func__);
+		free(element);
+		return -1;
+	}
  	if (value)
-		printf("%s=%s\n", key, value);
+		element->value = (char *)value;
  	else
-		printf("%s\n", key);
+		element->value = NULL;
+
+	list_add_tail(&element->list, head);
+	return 0;
+}
+
+static int collect_current_config(const char *var, const char *value,
+				  void *spec_sections)
+{
+	int ret = -1;
+	char *ptr, *key;
+	char *section_name, *name;
+	struct config_section *section = NULL;
+	struct config_element *element = NULL;
+	struct list_head *sections = (struct list_head *)spec_sections;
+
+	key = ptr = strdup(var);
+	if (!key) {
+		pr_err("%s: strdup failed\n", __func__);
+		return -1;
+	}
+
+	section_name = strsep(&ptr, ".");
+	name = ptr;
+	if (name == NULL || value == NULL)
+		goto out_err;
+
+	find_config(sections, &section, &element, section_name, name);
+
+	if (!section) {
+		section = init_section(section_name);
+		if (!section)
+			goto out_err;
+		list_add_tail(&section->list, sections);
+	}
+
+	value = strdup(value);
+	if (!value) {
+		pr_err("%s: strdup failed\n", __func__);
+		goto out_err;
+	}
+
+	if (!element)
+		add_element(&section->element_head, name, value);
+	else {
+		free(element->value);
+		element->value = (char *)value;
+	}
+
+	ret = 0;
+out_err:
+	free(key);
+	return ret;
+}
+
+static int show_config(struct list_head *sections)
+{
+	struct config_section *section;
+	struct config_element *element;
+
+	if (list_empty(sections))
+		return -1;
+	list_for_each_entry(section, sections, list) {
+		list_for_each_entry(element, &section->element_head, list) {
+			printf("%s.%s=%s\n", section->name,
+				       element->name, element->value);
+		}
+	}
 
  	return 0;
  }
@@ -46,6 +181,7 @@ static int show_config(const char *key, const char *value,
  int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
  {
  	int ret = 0;
+	struct list_head sections;
 
  	argc = parse_options(argc, argv, config_options, config_usage,
  			     PARSE_OPT_STOP_AT_NON_OPTION);
@@ -57,18 +193,22 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
  		return -1;
  	}
 
+	INIT_LIST_HEAD(&sections);
+
  	if (use_system_config)
  		config_exclusive_filename = perf_etc_perfconfig();
  	else if (use_user_config)
  		config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
 
+	perf_config(collect_current_config, &sections);
+
  	switch (actions) {
  	case ACTION_LIST:
  		if (argc) {
  			pr_err("Error: takes no arguments\n");
  			parse_options_usage(config_usage, config_options, "l", 1);
  		} else {
-			ret = perf_config(show_config, NULL);
+			ret = show_config(&sections);
  			if (ret < 0)
  				pr_err("Nothing configured, "
  				       "please check your ~/.perfconfig file\n");
tools/perf/util/cache.h +13 -1
index d1eb75f..e503371 100644
@@ -1,6 +1,7 @@
  #ifndef __PERF_CACHE_H
  #define __PERF_CACHE_H
 
+#include <linux/list.h>
  #include <stdbool.h>
  #include "util.h"
  #include "strbuf.h"
@@ -19,6 +20,18 @@
  #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
  #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
+struct config_element {
+	char *name;
+	char *value;
+	struct list_head list;
+};
+
+struct config_section {
+	char *name;
+	struct list_head element_head;
+	struct list_head list;
+};
+
  extern const char *config_exclusive_filename;
 
  typedef int (*config_fn_t)(const char *, const char *, void *);
--

1.9.1

maintainer
#43 lore raw

Re: [PATCH v11 17/24] perf config: Collect configs to handle config variables

Hi Taeung,

Quoted 21 lines · Taeung Song

Hi, Namhyung and all

(I'm modifying this patch to be tidy)
I have a mere question about name of a variable for current config list that contains section list which has key-value pairs from ~/.perfconfig or $(sysconfdir)/perfconfig config file.

(This variable is designed to be used by several functions that handle config information(key-value pairs).)

I used 'sections' for this variable (type is 'struct list_head'), but IMHO, I think that renaming it is better e.g.

1) 'cfglist'
2) 'configlist'
3) 'config_list'
4) 'cfgset'
5) 'configset'
6) 'config_set'
... :-\

Quoted 2 lines

It is trivial question,
but I wanna know a opinion of other people. :-)

I'd go with 3 or 6. Or simply 'configs' or 'perf_configs' is fine for me.

Thanks,
Namhyung

#44 lore raw

Re: [PATCH v11 17/24] perf config: Collect configs to handle config variables

Quoted 24 lines · Namhyung Kim

Hi Taeung,

Quoted 21 lines · Taeung Song

Hi, Namhyung and all

(I'm modifying this patch to be tidy)
I have a mere question about name of a variable for current config list that contains section list which has key-value pairs from ~/.perfconfig or $(sysconfdir)/perfconfig config file.

(This variable is designed to be used by several functions that handle config information(key-value pairs).)

I used 'sections' for this variable (type is 'struct list_head'), but IMHO, I think that renaming it is better e.g.

1) 'cfglist'
2) 'configlist'
3) 'config_list'
4) 'cfgset'
5) 'configset'
6) 'config_set'
... :-\

Quoted 6 lines
Quoted 2 lines

It is trivial question,
but I wanna know a opinion of other people. :-)

I'd go with 3 or 6. Or simply 'configs' or 'perf_configs' is fine for me.

Thank you for your opinion. :-)

Taeung

#45 lore raw

PATCH v11 18/24 perf config: Add 'list-all' option to perf-config

In reply to Taeung Song

'list-all' option is to display both current config variables and all possible config variables with default values. The syntax examples are like below

perf config [<file-option>] [options]

display all perf config with default values.
# perf config -a | --list-all

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt |   6 +
 tools/perf/builtin-config.c              | 222 ++++++++++++++++++++++++++++++-
 2 files changed, 226 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-config.txt +6 -0
index f556672..61f336b 100644
@@ -9,6 +9,8 @@ SYNOPSIS
 --------
 [verse]
 'perf config' [<file-option>] -l | --list
+or
+'perf config' [<file-option>] -a | --list-all
 
 DESCRIPTION
 -----------
@@ -29,6 +31,10 @@ OPTIONS
 	For writing and reading options: write to system-wide
 	'$(sysconfdir)/perfconfig' or read it.
 
+-a::
+--list-all::
+	Show current and all possible config variables with default values.
+
 CONFIGURATION FILE
 ------------------
 
tools/perf/builtin-config.c +220 -2

259 lines not on this page · raw message

Signature · 1 line
1.9.1
#46 lore raw

PATCH v11 19/24 perf config: Add a option 'skel' to perf-config

In reply to Taeung Song

Produce an skeleton with the possible config variables so that one could then use $EDITOR ~/.perfconfig or $(sysconfdir)/perfconfigand go on setting the knobs.

For the syntax examples,

    # perf config -k | --skel
    Initialize the possible config variables on config file.
    # perf config --skel > ~/.perfconfig
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/builtin-config.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
tools/perf/builtin-config.c +29 -1
index 1073ac4..2f8be59 100644
@@ -22,7 +22,8 @@ static const char * const config_usage[] = {
 
 enum actions {
 	ACTION_LIST = 1,
-	ACTION_LIST_ALL
+	ACTION_LIST_ALL,
+	ACTION_SKEL
 } actions;
 
 static struct option config_options[] = {
@@ -31,6 +32,9 @@ static struct option config_options[] = {
 	OPT_SET_UINT('a', "list-all", &actions,
 		     "show current and all possible config"
 		     " variables with default values", ACTION_LIST_ALL),
+	OPT_SET_UINT('k', "skel", &actions,
+		     "produce an skeleton with the possible"
+		     " config variables", ACTION_SKEL),
 	OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
 	OPT_BOOLEAN(0, "user", &use_user_config, "use user config file"),
 	OPT_END()
@@ -276,6 +280,24 @@ static char *get_value(struct config_item *config)
 	return value;
 }
 
+static int show_skel_config(void)
+{
+	char *section;
+
+	for (int i = 0; default_configs[i].type != CONFIG_END; i++) {
+		struct config_item *config = &default_configs[i];
+		char *value = get_value(config);
+		if (strcmp(section, config->section) != 0) {
+			section = (char *)config->section;
+			printf("\n[%s]\n", config->section);
+		}
+		printf("\t%s = %s\n", config->name, value);
+		free(value);
+	}
+
+	return 0;
+}
+
 static int show_all_config(struct list_head *sections)
 {
 	int i;
@@ -412,6 +434,12 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 	perf_config(collect_current_config, &sections);
 
 	switch (actions) {
+	case ACTION_SKEL:
+		if (argc)
+			parse_options_usage(config_usage, config_options, "k", 1);
+		else
+			ret = show_skel_config();
+		break;
 	case ACTION_LIST_ALL:
 		if (argc == 0) {
 			ret = show_all_config(&sections);
Signature · 1 line
1.9.1
#47 lore raw

PATCH v11 20/24 perf config: Add --verbose option for showing config description

In reply to Taeung Song

To explain what each of variable options configures, this option can be used with --skel option, i.e.

print the possible config variables with comments over each of them. # perf config -k -v | --skel --verbose

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/builtin-config.c | 161 ++++++++++++++++++++++++++++----------------
 1 file changed, 104 insertions(+), 57 deletions(-)
tools/perf/builtin-config.c +104 -57
index 2f8be59..c84ea7d 100644
@@ -35,6 +35,8 @@ static struct option config_options[] = {
 	OPT_SET_UINT('k', "skel", &actions,
 		     "produce an skeleton with the possible"
 		     " config variables", ACTION_SKEL),
+	OPT_INCR('v', "verbose", &verbose, "Be more verbose"
+		 " (show config description)"),
 	OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
 	OPT_BOOLEAN(0, "user", &use_user_config, "use user config file"),
 	OPT_END()
@@ -108,68 +110,111 @@ struct config_item {
 		const char *s;
 	} value;
 	enum config_type type;
+	const char *desc;
 };
 
-#define CONF_VAR(_sec, _name, _field, _val, _type) \
-	{ .section = _sec, .name = _name, .value._field = _val, .type = _type }
-
-#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL)
-#define CONF_INT_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT)
-#define CONF_LONG_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG)
-#define CONF_U64_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64)
-#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT)
-#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE)
-#define CONF_STR_VAR(_idx, _sec, _name, _val) \
-	[CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING)
+#define CONF_VAR(_sec, _name, _field, _val, _type, _desc)			\
+	{ .section = _sec, .name = _name, .value._field = _val, .type = _type, .desc = _desc}
+
+#define CONF_BOOL_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL, _desc)
+#define CONF_INT_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT, _desc)
+#define CONF_LONG_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG, _desc)
+#define CONF_U64_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64, _desc)
+#define CONF_FLOAT_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT, _desc)
+#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE, _desc)
+#define CONF_STR_VAR(_idx, _sec, _name, _val, _desc) \
+	[CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING, _desc)
 #define CONF_END() { .type = CONFIG_END }
 
 struct config_item default_configs[] = {
-	CONF_STR_VAR(COLORS_TOP, "colors", "top", "red, default"),
-	CONF_STR_VAR(COLORS_MEDIUM, "colors", "medium", "green, default"),
-	CONF_STR_VAR(COLORS_NORMAL, "colors", "normal", "lightgray, default"),
-	CONF_STR_VAR(COLORS_SELECTED, "colors", "selected", "white, lightgray"),
-	CONF_STR_VAR(COLORS_CODE, "colors", "code", "blue, default"),
-	CONF_STR_VAR(COLORS_ADDR, "colors", "addr", "magenta, default"),
-	CONF_STR_VAR(COLORS_ROOT, "colors", "root", "white, blue"),
-	CONF_BOOL_VAR(TUI_REPORT, "tui", "report", true),
-	CONF_BOOL_VAR(TUI_ANNOTATE, "tui", "annotate", true),
-	CONF_BOOL_VAR(TUI_TOP, "tui", "top", true),
-	CONF_STR_VAR(BUILDID_DIR, "buildid", "dir", "~/.debug"),
-	CONF_BOOL_VAR(ANNOTATE_HIDE_SRC_CODE, "annotate", "hide_src_code", false),
-	CONF_BOOL_VAR(ANNOTATE_USE_OFFSET, "annotate", "use_offset", true),
-	CONF_BOOL_VAR(ANNOTATE_JUMP_ARROWS, "annotate", "jump_arrows", true),
-	CONF_BOOL_VAR(ANNOTATE_SHOW_NR_JUMPS, "annotate", "show_nr_jumps", false),
-	CONF_BOOL_VAR(GTK_ANNOTATE, "gtk", "annotate", false),
-	CONF_BOOL_VAR(GTK_REPORT, "gtk", "report", false),
-	CONF_BOOL_VAR(GTK_TOP, "gtk", "top", false),
-	CONF_BOOL_VAR(PAGER_CMD, "pager", "cmd", true),
-	CONF_BOOL_VAR(PAGER_REPORT, "pager", "report", true),
-	CONF_BOOL_VAR(PAGER_ANNOTATE, "pager", "annotate", true),
-	CONF_BOOL_VAR(PAGER_TOP, "pager", "top", true),
-	CONF_BOOL_VAR(PAGER_DIFF, "pager", "diff", true),
-	CONF_STR_VAR(HELP_FORMAT, "help", "format", "man"),
-	CONF_INT_VAR(HELP_AUTOCORRECT, "help", "autocorrect", 0),
-	CONF_STR_VAR(HIST_PERCENTAGE, "hist", "percentage", "absolute"),
-	CONF_BOOL_VAR(UI_SHOW_HEADERS, "ui", "show-headers", true),
-	CONF_STR_VAR(CALL_GRAPH_RECORD_MODE, "call-graph", "record-mode", "fp"),
-	CONF_LONG_VAR(CALL_GRAPH_DUMP_SIZE, "call-graph", "dump-size", 8192),
-	CONF_STR_VAR(CALL_GRAPH_PRINT_TYPE, "call-graph", "print-type", "graph"),
-	CONF_STR_VAR(CALL_GRAPH_ORDER, "call-graph", "order", "callee"),
-	CONF_STR_VAR(CALL_GRAPH_SORT_KEY, "call-graph", "sort-key", "function"),
-	CONF_DOUBLE_VAR(CALL_GRAPH_THRESHOLD, "call-graph", "threshold", 0.5),
-	CONF_LONG_VAR(CALL_GRAPH_PRINT_LIMIT, "call-graph", "print-limit", 0),
-	CONF_BOOL_VAR(REPORT_CHILDREN, "report", "children", true),
-	CONF_FLOAT_VAR(REPORT_PERCENT_LIMIT, "report", "percent-limit", 0),
-	CONF_U64_VAR(REPORT_QUEUE_SIZE, "report", "queue-size", 0),
-	CONF_BOOL_VAR(TOP_CHILDREN, "top", "children", true),
-	CONF_STR_VAR(MAN_VIEWER, "man", "viewer", "man"),
-	CONF_STR_VAR(KMEM_DEFAULT, "kmem", "default", "slab"),
+	CONF_STR_VAR(COLORS_TOP, "colors", "top", "red, default",
+		     "A overhead percentage which is more than 5%"),
+	CONF_STR_VAR(COLORS_MEDIUM, "colors", "medium", "green, default",
+		     "A overhead percentage which has more than 0.5%"),
+	CONF_STR_VAR(COLORS_NORMAL, "colors", "normal", "lightgray, default",
+		     "The rest of overhead percentages"),
+	CONF_STR_VAR(COLORS_SELECTED, "colors", "selected", "white, lightgray",
+		     "The current entry in a list of entries on TUI"),
+	CONF_STR_VAR(COLORS_CODE, "colors", "code", "blue, default",
+		     "Arrows and lines in jumps on  assembly code listings"),
+	CONF_STR_VAR(COLORS_ADDR, "colors", "addr", "magenta, default",
+		     "Addresses from 'annotate"),
+	CONF_STR_VAR(COLORS_ROOT, "colors", "root", "white, blue",
+		     "Headers in the output of a sub-command 'top'"),
+	CONF_BOOL_VAR(TUI_REPORT, "tui", "report", true,
+		      "TUI can be enabled or not"),
+	CONF_BOOL_VAR(TUI_ANNOTATE, "tui", "annotate", true,
+		      "TUI can be enabled or not"),
+	CONF_BOOL_VAR(TUI_TOP, "tui", "top", true,
+		      "TUI can be enabled or not"),
+	CONF_STR_VAR(BUILDID_DIR, "buildid", "dir", "~/.debug",
+		     "The directory location of binaries, shared libraries,"
+		     " /proc/kallsyms and /proc/kcore files to be used"
+		     " at analysis time"),
+	CONF_BOOL_VAR(ANNOTATE_HIDE_SRC_CODE, "annotate", "hide_src_code", false,
+		      "Print a list of assembly code without the source code or not"),
+	CONF_BOOL_VAR(ANNOTATE_USE_OFFSET, "annotate", "use_offset", true,
+		      "Addresses subtracted from a base address can be printed"),
+	CONF_BOOL_VAR(ANNOTATE_JUMP_ARROWS, "annotate", "jump_arrows", true,
+		      "Arrows for jump instruction can be printed or not"),
+	CONF_BOOL_VAR(ANNOTATE_SHOW_NR_JUMPS, "annotate", "show_nr_jumps", false,
+		      "The number of branches branching to that address can be printed"),
+	CONF_BOOL_VAR(GTK_ANNOTATE, "gtk", "annotate", false,
+		      "GTK can be enabled or not"),
+	CONF_BOOL_VAR(GTK_REPORT, "gtk", "report", false,
+		      "GTK can be enabled or not"),
+	CONF_BOOL_VAR(GTK_TOP, "gtk", "top", false,
+		      "GTK can be enabled or not"),
+	CONF_BOOL_VAR(PAGER_CMD, "pager", "cmd", true,
+		      "As stdio instead of TUI"),
+	CONF_BOOL_VAR(PAGER_REPORT, "pager", "report", true,
+		      "As stdio instead of TUI"),
+	CONF_BOOL_VAR(PAGER_ANNOTATE, "pager", "annotate", true,
+		      "As stdio instead of TUI"),
+	CONF_BOOL_VAR(PAGER_TOP, "pager", "top", true,
+		      "As stdio instead of TUI"),
+	CONF_BOOL_VAR(PAGER_DIFF, "pager", "diff", true,
+		      "As stdio instead of TUI"),
+	CONF_STR_VAR(HELP_FORMAT, "help", "format", "man", "A format of manual page"),
+	CONF_INT_VAR(HELP_AUTOCORRECT, "help", "autocorrect", 0,
+		     "Automatically correct and execute mistyped commands after"
+		     " waiting for the given number of deciseconds"),
+	CONF_STR_VAR(HIST_PERCENTAGE, "hist", "percentage", "absolute",
+		     "Control a way to calcurate overhead of filtered entries"),
+	CONF_BOOL_VAR(UI_SHOW_HEADERS, "ui", "show-headers", true,
+		      "Show or hide columns as header on TUI"),
+	CONF_STR_VAR(CALL_GRAPH_RECORD_MODE, "call-graph", "record-mode", "fp",
+		     "The mode can be 'fp' (frame pointer) and 'dwarf'"),
+	CONF_LONG_VAR(CALL_GRAPH_DUMP_SIZE, "call-graph", "dump-size", 8192,
+		      "The size of stack to dump in order to do post-unwinding"),
+	CONF_STR_VAR(CALL_GRAPH_PRINT_TYPE, "call-graph", "print-type", "graph",
+		     "The type can be graph (graph absolute), fractal (graph relative), fla"),
+	CONF_STR_VAR(CALL_GRAPH_ORDER, "call-graph", "order", "callee",
+		     "Controls print order of callchains (callee or caller)"),
+	CONF_STR_VAR(CALL_GRAPH_SORT_KEY, "call-graph", "sort-key", "function",
+		     "It can be 'function' or 'address'"),
+	CONF_DOUBLE_VAR(CALL_GRAPH_THRESHOLD, "call-graph", "threshold", 0.5,
+			"Small callchains can be omitted under a certain overhead (threshold)"),
+	CONF_LONG_VAR(CALL_GRAPH_PRINT_LIMIT, "call-graph", "print-limit", 0,
+		      "Control the number of callchains printed for a single entry"),
+	CONF_BOOL_VAR(REPORT_CHILDREN, "report", "children", true,
+		      "Accumulate callchain of children and show total overhead or not"),
+	CONF_FLOAT_VAR(REPORT_PERCENT_LIMIT, "report", "percent-limit", 0,
+		       "Entries have overhead lower than this percentage will not be printed"),
+	CONF_U64_VAR(REPORT_QUEUE_SIZE, "report", "queue-size", 0,
+		     "The maximum allocation size for session's ordered events queue"),
+	CONF_BOOL_VAR(TOP_CHILDREN, "top", "children", true,
+		      "Similar as report.children"),
+	CONF_STR_VAR(MAN_VIEWER, "man", "viewer", "man",
+		     "Select manual tools that work a sub-command 'help'"),
+	CONF_STR_VAR(KMEM_DEFAULT, "kmem", "default", "slab",
+		     "Which allocator is analyzed between 'slab' and 'page"),
 	CONF_END()
 };
 
@@ -291,6 +336,8 @@ static int show_skel_config(void)
 			section = (char *)config->section;
 			printf("\n[%s]\n", config->section);
 		}
+		if (verbose)
+			printf("\t# %s\n", config->desc);
 		printf("\t%s = %s\n", config->name, value);
 		free(value);
 	}
Signature · 1 line
1.9.1
#48 lore raw

PATCH v11 21/24 perf config: Add 'get' functionality

In reply to Taeung Song

This patch consists of functions
which can get specific config variables.
For the syntax examples,

perf config [<file-option>] [section.name ...]

display key-value pairs of specific config variables # perf config report.queue-size report.children

In addition, the functionality can work with --verbose option to show the config description, i.e.

    # perf config -v report.queue-size
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt |  2 +
 tools/perf/builtin-config.c              | 83 ++++++++++++++++++++++++++++++--
 tools/perf/util/cache.h                  |  1 +
 3 files changed, 82 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-config.txt +2 -0
index 61f336b..ef4ddf6 100644
@@ -8,6 +8,8 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 --------
 [verse]
+'perf config' [<file-option>] [section.name ...]
+or
 'perf config' [<file-option>] -l | --list
 or
 'perf config' [<file-option>] -a | --list-all
tools/perf/builtin-config.c +79 -4

119 lines not on this page · raw message

tools/perf/util/cache.h +1 -0
index e503371..71aefed 100644
@@ -35,6 +35,7 @@ struct config_section {
 extern const char *config_exclusive_filename;
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
+typedef int (*configset_fn_t)(struct list_head *, const char *, const char *);
 extern int perf_default_config(const char *, const char *, void *);
 extern int perf_config(config_fn_t fn, void *);
 extern int perf_config_int(const char *, const char *);
Signature · 1 line
1.9.1
#49 lore raw

PATCH v11 22/24 perf config: Add 'set' feature

In reply to Taeung Song

This patch consists of functions which can set specific config variables. For the syntax examples,

perf config [<file-option>] [options] [section.name[=value] ...]

set specific config variables
# perf config report.queue-size=100M report.children=true

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt |   2 +-
 tools/perf/builtin-config.c              | 127 +++++++++++++++++++++++++------
 tools/perf/util/cache.h                  |   5 +-
 tools/perf/util/config.c                 |  27 ++++++-
 4 files changed, 134 insertions(+), 27 deletions(-)
tools/perf/Documentation/perf-config.txt +1 -1
index ef4ddf6..9892d11 100644
@@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 --------
 [verse]
-'perf config' [<file-option>] [section.name ...]
+'perf config' [<file-option>] [section.name[=value] ...]
 or
 'perf config' [<file-option>] -l | --list
 or
tools/perf/builtin-config.c +103 -24

194 lines not on this page · raw message

tools/perf/util/cache.h +4 -1
index 71aefed..2ec958e 100644
@@ -35,9 +35,12 @@ struct config_section {
 extern const char *config_exclusive_filename;
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
-typedef int (*configset_fn_t)(struct list_head *, const char *, const char *);
+typedef int (*configset_fn_t)(struct list_head *, const char *,
+			      const char *, const char *, char *);
+extern int perf_configset_write_in_full(struct list_head *sections, const char *file_name);
 extern int perf_default_config(const char *, const char *, void *);
 extern int perf_config(config_fn_t fn, void *);
+extern int perf_config_from_file(config_fn_t fn, const char *filename, void *data);
 extern int perf_config_int(const char *, const char *);
 extern u64 perf_config_u64(const char *, const char *);
 extern int perf_config_bool(const char *, const char *);
tools/perf/util/config.c +26 -1
index 55ef373..2111695 100644
@@ -416,7 +416,7 @@ int perf_default_config(const char *var, const char *value,
 	return 0;
 }
 
-static int perf_config_from_file(config_fn_t fn, const char *filename, void *data)
+int perf_config_from_file(config_fn_t fn, const char *filename, void *data)
 {
 	int ret;
 	FILE *f = fopen(filename, "r");
@@ -506,6 +506,31 @@ out:
 	return ret;
 }
 
+int perf_configset_write_in_full(struct list_head *sections, const char *file_name)
+{
+	struct config_section *section;
+	struct config_element *element;
+	const char *first_line = "# this file is auto-generated.";
+	FILE *fp = fopen(file_name, "w");
+
+	if (!fp)
+		return -1;
+
+	fprintf(fp, "%s\n", first_line);
+	/* overwrite configvariables */
+	list_for_each_entry(section, sections, list) {
+		fprintf(fp, "[%s]\n", section->name);
+		list_for_each_entry(element, &section->element_head, list) {
+			if (element->value)
+				fprintf(fp, "\t%s = %s\n",
+					element->name, element->value);
+		}
+	}
+	fclose(fp);
+
+	return 0;
+}
+
 /*
  * Call this to report error for your variable that should not
  * get a boolean value (i.e. "[my] var" means "true").
Signature · 1 line
1.9.1
#50 lore raw

PATCH v11 23/24 perf config: normalize a value depending on default type of it

In reply to Taeung Song

Whether or not user mis-type wrong data type to set config, normalize the value. If a config user enter isn't contained in default configs, just pass as it is.
For the examples,

   # perf config report.queue-size=1M
   # perf config report.queue-size
   report.queue-size=1048576
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/builtin-config.c | 54 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 49 insertions(+), 5 deletions(-)
tools/perf/builtin-config.c +49 -5
index 59d7842..cf65250 100644
@@ -423,6 +423,54 @@ static int show_spec_config(struct list_head *sections,
 	return -1;
 }
 
+static char *normalize_value(const char *section_name, const char *name, const char *value)
+{
+	int i, ret = 0;
+	char *endptr;
+	char key[BUFSIZ];
+	char *normalized;
+
+	scnprintf(key, sizeof(key), "%s.%s", section_name, name);
+	for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+		struct config_item *config = &default_configs[i];
+
+		if (!strcmp(config->section, section_name) &&
+		    !strcmp(config->name, name)) {
+			if (config->type == CONFIG_TYPE_BOOL)
+				ret = asprintf(&normalized, "%s",
+					       perf_config_bool(key, value) ? "true" : "false");
+			else if (config->type == CONFIG_TYPE_INT ||
+				 config->type == CONFIG_TYPE_LONG)
+				ret = asprintf(&normalized, "%d",
+					       perf_config_int(key, value));
+			else if (config->type == CONFIG_TYPE_U64)
+				ret = asprintf(&normalized, "%"PRId64,
+					       perf_config_u64(key, value));
+			else if (config->type == CONFIG_TYPE_FLOAT)
+				ret = asprintf(&normalized, "%f",
+					       strtof(value, &endptr));
+			else if (config->type == CONFIG_TYPE_DOUBLE)
+				ret = asprintf(&normalized, "%f",
+					       strtod(value, &endptr));
+			else
+				ret = asprintf(&normalized, "%s", value);
+
+			if (ret < 0)
+				return NULL;
+
+			return normalized;
+		}
+	}
+
+	normalized = strdup(value);
+	if (!normalized) {
+		pr_err("%s: strdup failed\n", __func__);
+		return NULL;
+	}
+
+	return normalized;
+}
+
 static int set_config(struct list_head *sections, const char *config_file_name,
 		      const char *section_name, const char *name, char *value)
 {
@@ -431,11 +479,7 @@ static int set_config(struct list_head *sections, const char *config_file_name,
 
 	find_config(sections, &section, &element, section_name, name);
 	if (value != NULL) {
-		value = strdup(value);
-		if (!value) {
-			pr_err("%s: strdup failed\n", __func__);
-			return -1;
-		}
+		value = normalize_value(section_name, name, value);
 
 		/* if there isn't existent section, add a new section */
 		if (!section) {
Signature · 1 line
1.9.1
#51 lore raw

PATCH v11 24/24 perf config: Add a option 'remove' to perf-config

In reply to Taeung Song

A option 'remove' is to remove specific config variables. For the syntax examples,

    # perf config [<file-option>] -r | --remove [section.name ...]
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 tools/perf/Documentation/perf-config.txt |  6 ++++++
 tools/perf/builtin-config.c              | 37 ++++++++++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-config.txt +6 -0
index 9892d11..7b33d96 100644
@@ -13,6 +13,8 @@ or
 'perf config' [<file-option>] -l | --list
 or
 'perf config' [<file-option>] -a | --list-all
+or
+'perf config' [<file-option>] -r | --remove [section.name ...]
 
 DESCRIPTION
 -----------
@@ -37,6 +39,10 @@ OPTIONS
 --list-all::
 	Show current and all possible config variables with default values.
 
+-r::
+--remove::
+	Remove specific config variables.
+
 CONFIGURATION FILE
 ------------------
 
tools/perf/builtin-config.c +35 -2
index cf65250..53fe844 100644
@@ -23,7 +23,8 @@ static const char * const config_usage[] = {
 enum actions {
 	ACTION_LIST = 1,
 	ACTION_LIST_ALL,
-	ACTION_SKEL
+	ACTION_SKEL,
+	ACTION_REMOVE
 } actions;
 
 static struct option config_options[] = {
@@ -35,6 +36,8 @@ static struct option config_options[] = {
 	OPT_SET_UINT('k', "skel", &actions,
 		     "produce an skeleton with the possible"
 		     " config variables", ACTION_SKEL),
+	OPT_SET_UINT('r', "remove", &actions,
+		     "remove specific variables: [section.name ...]", ACTION_REMOVE),
 	OPT_INCR('v', "verbose", &verbose, "Be more verbose"
 		 " (show config description)"),
 	OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
@@ -478,7 +481,13 @@ static int set_config(struct list_head *sections, const char *config_file_name,
 	struct config_element *element = NULL;
 
 	find_config(sections, &section, &element, section_name, name);
-	if (value != NULL) {
+	if (!value) {
+		/* value == NULL means remove the variable */
+		if (section && element) {
+			free(element->value);
+			element->value = NULL;
+		}
+	} else {
 		value = normalize_value(section_name, name, value);
 
 		/* if there isn't existent section, add a new section */
@@ -629,6 +638,7 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	set_option_flag(config_options, 'l', "list", PARSE_OPT_EXCLUSIVE);
 	set_option_flag(config_options, 'a', "list-all", PARSE_OPT_EXCLUSIVE);
+	set_option_flag(config_options, 'r', "remove", PARSE_OPT_EXCLUSIVE);
 
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
@@ -658,6 +668,29 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 	}
 
 	switch (actions) {
+	case ACTION_REMOVE:
+		if (argc) {
+			for (i = 0; argv[i]; i++) {
+				if (!use_system_config && !use_user_config) {
+					ret = perf_configset_with_option(set_config,
+									 &system_sections,
+									 system_config,
+									 argv[i], NULL);
+					ret = perf_configset_with_option(set_config,
+									 &user_sections,
+									 user_config,
+									 argv[i], NULL);
+				} else
+					ret = perf_configset_with_option(set_config, sections,
+									 config_exclusive_filename,
+									 argv[i], NULL);
+			}
+		} else {
+			pr_err("Error: Missing arguments\n");
+			parse_options_usage(config_usage, config_options, "r", 1);
+			return -1;
+		}
+		break;
 	case ACTION_SKEL:
 		if (argc)
 			parse_options_usage(config_usage, config_options, "k", 1);
Signature · 1 line
1.9.1
Acked-by on v11 1/24
#52 lore raw
In reply to Taeung Song

Hi Taeung,

Quoted 7 lines · Taeung Song

The perf configuration file contains many variables to change various aspects of each of its tools, including output, disk usage, etc. But looking through state of configuration is difficult and there's no knowing what kind of other variables except variables in perfconfig.example exist. So This patch adds 'perf-config' command with '--list' option.

Quoted 7 lines

perf config [options]

display current perf config variables.

   # perf config -l | --list

Thanks
Namhyung

Quoted 134 lines

---
tools/perf/Build | 1 +
tools/perf/builtin-config.c | 66
+++++++++++++++++++++++++++++++++++++++++++++

tools/perf/builtin.h        |  1 +
tools/perf/command-list.txt |  1 +
tools/perf/perf.c           |  1 +
5 files changed, 70 insertions(+)

create mode 100644 tools/perf/builtin-config.c

tools/perf/Build +0 -0
index 7223745..2c7aaf2 100644
@@ -1,5 +1,6 @@

perf-y += builtin-bench.o
perf-y += builtin-annotate.o
+perf-y += builtin-config.o
perf-y += builtin-diff.o
perf-y += builtin-evlist.o
perf-y += builtin-help.o

tools/perf/builtin-config.c new file +42 -0
new file mode 100644
index 0000000..427ea7a
@@ -0,0 +1,66 @@
+/*
+ * builtin-config.c
+ *
+ * Copyright (C) 2015, Taeung Song <[email protected]>
+ *
+ */
+#include "builtin.h"
+
+#include "perf.h"
+
+#include "util/cache.h"
+#include "util/parse-options.h"
+#include "util/util.h"
+#include "util/debug.h"
+
+static const char * const config_usage[] = {
+	"perf config [options]",
+	NULL
+};
+
+enum actions {
+	ACTION_LIST = 1
+} actions;
+
+static struct option config_options[] = {
+	OPT_SET_UINT('l', "list", &actions,
+		     "show current config variables", ACTION_LIST),
+	OPT_END()
+};
+
+static int show_config(const char *key, const char *value,
+		       void *cb __maybe_unused)
+{
+	if (value)
+		printf("%s=%s\n", key, value);
+	else
+		printf("%s\n", key);
+
+	return 0;
+}
+
+int cmd_config(int argc, const char **argv, const char *prefix

__maybe_unused)

tools/perf/builtin-config.c new file +24 -0
+{
+	int ret = 0;
+
+	argc = parse_options(argc, argv, config_options, config_usage,
+			     PARSE_OPT_STOP_AT_NON_OPTION);
+
+	switch (actions) {
+	case ACTION_LIST:
+		if (argc) {
+			pr_err("Error: takes no arguments\n");
+			parse_options_usage(config_usage, config_options, "l", 1);
+		} else {
+			ret = perf_config(show_config, NULL);
+			if (ret < 0)
+				pr_err("Nothing configured, "
+				       "please check your ~/.perfconfig file\n");
+		}
+		break;
+	default:
+		usage_with_options(config_usage, config_options);
+	}
+
+	return ret;
+}
tools/perf/builtin.h +0 -0
index 3688ad2..3f871b5 100644
@@ -17,6 +17,7 @@ extern int cmd_annotate(int argc, const char **argv,
 const char *prefix);
 extern int cmd_bench(int argc, const char **argv, const char *prefix);

extern int cmd_buildid_cache(int argc, const char **argv, const char *prefix);
extern int cmd_buildid_list(int argc, const char **argv, const char *prefix);
+extern int cmd_config(int argc, const char **argv, const char *prefix);
extern int cmd_diff(int argc, const char **argv, const char *prefix); extern int cmd_evlist(int argc, const char **argv, const char *prefix); extern int cmd_help(int argc, const char **argv, const char *prefix);

tools/perf/command-list.txt +0 -0
index 00fcaf8..acc3ea7 100644
@@ -9,6 +9,7 @@ perf-buildid-cache		mainporcelain common

perf-buildid-list mainporcelain common
perf-data mainporcelain common
perf-diff mainporcelain common
+perf-config mainporcelain common
perf-evlist mainporcelain common
perf-inject mainporcelain common
perf-kmem mainporcelain common

tools/perf/perf.c +1 -0
index 3d4c7c0..4bee53c 100644
@@ -39,6 +39,7 @@ struct cmd_struct {
 static struct cmd_struct commands[] = {
 	{ "buildid-cache", cmd_buildid_cache, 0 },
 	{ "buildid-list", cmd_buildid_list, 0 },
+	{ "config",	cmd_config,	0 },
 	{ "diff",	cmd_diff,	0 },
 	{ "evlist",	cmd_evlist,	0 },
 	{ "help",	cmd_help,	0 },
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#53 lore raw

[tip:perf/core] perf tools: Add 'perf config' command

In reply to Taeung Song
perf tools: Add 'perf config' command
Commit-ID:  30862f2c5725c46afcfab5af710fdf5163bf0f81
Gitweb:     http://git.kernel.org/tip/30862f2c5725c46afcfab5af710fdf5163bf0f81
Author:     Taeung Song <[email protected]>
AuthorDate: Tue, 17 Nov 2015 22:53:21 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 23 Nov 2015 18:31:24 -0300

perf tools: Add 'perf config' command

The perf configuration file contains many variables to change various aspects of each of its tools, including output, disk usage, etc.

But looking at the state of configuration is difficult and there's no documentation about config variables except for the variables in perfconfig.example exist.

So this patch adds a 'perf-config' command with a '--list' option.

perf config [options]

display current perf config variables.
# perf config -l | --list

---
 tools/perf/Build            |  1 +
 tools/perf/builtin-config.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h        |  1 +
 tools/perf/command-list.txt |  1 +
 tools/perf/perf.c           |  1 +
 5 files changed, 70 insertions(+)
tools/perf/Build +1 -0
index 7223745..2c7aaf2 100644
@@ -1,5 +1,6 @@
 perf-y += builtin-bench.o
 perf-y += builtin-annotate.o
+perf-y += builtin-config.o
 perf-y += builtin-diff.o
 perf-y += builtin-evlist.o
 perf-y += builtin-help.o
tools/perf/builtin-config.c new file +66 -0

66 lines not on this page · raw message

tools/perf/builtin.h +1 -0
index 3688ad2..3f871b5 100644
@@ -17,6 +17,7 @@ extern int cmd_annotate(int argc, const char **argv, const char *prefix);
 extern int cmd_bench(int argc, const char **argv, const char *prefix);
 extern int cmd_buildid_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_buildid_list(int argc, const char **argv, const char *prefix);
+extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_diff(int argc, const char **argv, const char *prefix);
 extern int cmd_evlist(int argc, const char **argv, const char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
tools/perf/command-list.txt +1 -0
index 00fcaf8..acc3ea7 100644
@@ -9,6 +9,7 @@ perf-buildid-cache		mainporcelain common
 perf-buildid-list		mainporcelain common
 perf-data			mainporcelain common
 perf-diff			mainporcelain common
+perf-config			mainporcelain common
 perf-evlist			mainporcelain common
 perf-inject			mainporcelain common
 perf-kmem			mainporcelain common
tools/perf/perf.c +1 -0
index 3d4c7c0..4bee53c 100644
@@ -39,6 +39,7 @@ struct cmd_struct {
 static struct cmd_struct commands[] = {
 	{ "buildid-cache", cmd_buildid_cache, 0 },
 	{ "buildid-list", cmd_buildid_list, 0 },
+	{ "config",	cmd_config,	0 },
 	{ "diff",	cmd_diff,	0 },
 	{ "evlist",	cmd_evlist,	0 },
 	{ "help",	cmd_help,	0 },