Skip to contentSkip to conversation

perf: trivial follow-ons to --list-cmds

PATCH In review Ramkumar Ramachandra 3 participants 11 messages Mar 15, 2014 – Apr 17, 2014 perf events

lore
Share & tools
lore
#0 lore raw

cover perf: trivial follow-ons to --list-cmds

Hi,

With "perf kvm: introduce --list-cmds for use by scripts" accepted, these are trivial follow-on patches to enable the same functionality in kmem, mem, lock, and sched.

Thanks.

Ramkumar Ramachandra (4):
perf kmem: introduce --list-cmds for use by scripts perf mem: introduce --list-cmds for use by scripts perf lock: introduce --list-cmds for use by scripts perf sched: introduce --list-cmds for use by scripts

 tools/perf/builtin-kmem.c     |  8 +++++---
 tools/perf/builtin-lock.c     | 10 ++++++----
 tools/perf/builtin-mem.c      | 15 ++++++++-------
 tools/perf/builtin-sched.c    | 10 ++++++----
 tools/perf/perf-completion.sh |  4 ++--
 5 files changed, 27 insertions(+), 20 deletions(-)
Signature · 1 line
1.9.rc0.1.g9d22d25
#1 lore raw

PATCH 1/4 perf kmem: introduce --list-cmds for use by scripts

---
 tools/perf/builtin-kmem.c     | 8 +++++---
 tools/perf/perf-completion.sh | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-kmem.c +5 -3
index 929462a..bd91de0 100644
@@ -756,11 +756,13 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
 	OPT_END()
 	};
-	const char * const kmem_usage[] = {
-		"perf kmem [<options>] {record|stat}",
+	const char *const kmem_subcommands[] = { "record", "stat", NULL };
+	const char *kmem_usage[] = {
+		NULL,
 		NULL
 	};
-	argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
+	argc = parse_options_subcommand(argc, argv, kmem_options,
+					kmem_subcommands, kmem_usage, 0);
 
 	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
tools/perf/perf-completion.sh +2 -2
index ae3a576..0ef59dd 100644
@@ -121,8 +121,8 @@ __perf_main ()
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
-	# List subcommands for 'perf kvm'
-	elif [[ $prev == "kvm" ]]; then
+	# List subcommands for perf commands
+	elif [[ $prev == @(kvm|kmem) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Signature · 1 line
1.9.rc0.1.g9d22d25
#2 lore raw

[tip:perf/core] perf kmem: Introduce --list-cmds for use by scripts

perf kmem: Introduce --list-cmds for use by scripts
Commit-ID:  3bca23543b910a84d3c58a819663e0a4fad72bb6
Gitweb:     http://git.kernel.org/tip/3bca23543b910a84d3c58a819663e0a4fad72bb6
Author:     Ramkumar Ramachandra <[email protected]>
AuthorDate: Fri, 14 Mar 2014 23:17:51 -0400
Committer:  Jiri Olsa <[email protected]>
CommitDate: Wed, 16 Apr 2014 17:16:04 +0200

perf kmem: Introduce --list-cmds for use by scripts

---
 tools/perf/builtin-kmem.c     | 8 +++++---
 tools/perf/perf-completion.sh | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-kmem.c +5 -3
index 929462a..bd91de0 100644
@@ -756,11 +756,13 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
 	OPT_END()
 	};
-	const char * const kmem_usage[] = {
-		"perf kmem [<options>] {record|stat}",
+	const char *const kmem_subcommands[] = { "record", "stat", NULL };
+	const char *kmem_usage[] = {
+		NULL,
 		NULL
 	};
-	argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
+	argc = parse_options_subcommand(argc, argv, kmem_options,
+					kmem_subcommands, kmem_usage, 0);
 
 	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
tools/perf/perf-completion.sh +2 -2
index ae3a576..0ef59dd 100644
@@ -121,8 +121,8 @@ __perf_main ()
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
-	# List subcommands for 'perf kvm'
-	elif [[ $prev == "kvm" ]]; then
+	# List subcommands for perf commands
+	elif [[ $prev == @(kvm|kmem) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
#3 lore raw

PATCH 2/4 perf mem: introduce --list-cmds for use by scripts

In reply to Ramkumar Ramachandra
---
 tools/perf/builtin-mem.c      | 15 ++++++++-------
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)
tools/perf/builtin-mem.c +8 -7
index 2e3ade69..4a1a6c9 100644
@@ -21,11 +21,6 @@ struct perf_mem {
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
-static const char * const mem_usage[] = {
-	"perf mem [<options>] {record <command> |report}",
-	NULL
-};
-
 static int __cmd_record(int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
@@ -220,9 +215,15 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   " between columns '.' is reserved."),
 	OPT_END()
 	};
+	const char *const mem_subcommands[] = { "record", "report", NULL };
+	const char *mem_usage[] = {
+		NULL,
+		NULL
+	};
+
 
-	argc = parse_options(argc, argv, mem_options, mem_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
+					mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 
 	if (!argc || !(strncmp(argv[0], "rec", 3) || mem_operation))
 		usage_with_options(mem_usage, mem_options);
tools/perf/perf-completion.sh +1 -1
index 0ef59dd..f44c04b 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Signature · 1 line
1.9.rc0.1.g9d22d25
#4 lore raw

[tip:perf/core] perf mem: Introduce --list-cmds for use by scripts

perf mem: Introduce --list-cmds for use by scripts
Commit-ID:  8d2a2a1d885d36e978c4619a3db8791f9768dd6a
Gitweb:     http://git.kernel.org/tip/8d2a2a1d885d36e978c4619a3db8791f9768dd6a
Author:     Ramkumar Ramachandra <[email protected]>
AuthorDate: Fri, 14 Mar 2014 23:17:52 -0400
Committer:  Jiri Olsa <[email protected]>
CommitDate: Wed, 16 Apr 2014 17:16:04 +0200

perf mem: Introduce --list-cmds for use by scripts

---
 tools/perf/builtin-mem.c      | 15 ++++++++-------
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)
tools/perf/builtin-mem.c +8 -7
index 2e3ade69..4a1a6c9 100644
@@ -21,11 +21,6 @@ struct perf_mem {
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
-static const char * const mem_usage[] = {
-	"perf mem [<options>] {record <command> |report}",
-	NULL
-};
-
 static int __cmd_record(int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
@@ -220,9 +215,15 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   " between columns '.' is reserved."),
 	OPT_END()
 	};
+	const char *const mem_subcommands[] = { "record", "report", NULL };
+	const char *mem_usage[] = {
+		NULL,
+		NULL
+	};
+
 
-	argc = parse_options(argc, argv, mem_options, mem_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
+					mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 
 	if (!argc || !(strncmp(argv[0], "rec", 3) || mem_operation))
 		usage_with_options(mem_usage, mem_options);
tools/perf/perf-completion.sh +1 -1
index 0ef59dd..f44c04b 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
#5 lore raw

PATCH 3/4 perf lock: introduce --list-cmds for use by scripts

In reply to Ramkumar Ramachandra
---
 tools/perf/builtin-lock.c     | 10 ++++++----
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-lock.c +6 -4
index c852c7a..6148afc 100644
@@ -961,8 +961,10 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
 		"perf lock info [<options>]",
 		NULL
 	};
-	const char * const lock_usage[] = {
-		"perf lock [<options>] {record|report|script|info}",
+	const char *const lock_subcommands[] = { "record", "report", "script",
+						 "info", NULL };
+	const char *lock_usage[] = {
+		NULL,
 		NULL
 	};
 	const char * const report_usage[] = {
@@ -976,8 +978,8 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
 	for (i = 0; i < LOCKHASH_SIZE; i++)
 		INIT_LIST_HEAD(lockhash_table + i);
 
-	argc = parse_options(argc, argv, lock_options, lock_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, lock_options, lock_subcommands,
+					lock_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 	if (!argc)
 		usage_with_options(lock_usage, lock_options);
 
tools/perf/perf-completion.sh +1 -1
index f44c04b..ecedab6 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem|mem) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Signature · 1 line
1.9.rc0.1.g9d22d25
#6 lore raw

[tip:perf/core] perf lock: Introduce --list-cmds for use by scripts

perf lock: Introduce --list-cmds for use by scripts
Commit-ID:  a2368c3199eba493d72c6d0e5b804f908a09706c
Gitweb:     http://git.kernel.org/tip/a2368c3199eba493d72c6d0e5b804f908a09706c
Author:     Ramkumar Ramachandra <[email protected]>
AuthorDate: Fri, 14 Mar 2014 23:17:53 -0400
Committer:  Jiri Olsa <[email protected]>
CommitDate: Wed, 16 Apr 2014 17:16:04 +0200

perf lock: Introduce --list-cmds for use by scripts

---
 tools/perf/builtin-lock.c     | 10 ++++++----
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-lock.c +6 -4
index c852c7a..6148afc 100644
@@ -961,8 +961,10 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
 		"perf lock info [<options>]",
 		NULL
 	};
-	const char * const lock_usage[] = {
-		"perf lock [<options>] {record|report|script|info}",
+	const char *const lock_subcommands[] = { "record", "report", "script",
+						 "info", NULL };
+	const char *lock_usage[] = {
+		NULL,
 		NULL
 	};
 	const char * const report_usage[] = {
@@ -976,8 +978,8 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
 	for (i = 0; i < LOCKHASH_SIZE; i++)
 		INIT_LIST_HEAD(lockhash_table + i);
 
-	argc = parse_options(argc, argv, lock_options, lock_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, lock_options, lock_subcommands,
+					lock_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 	if (!argc)
 		usage_with_options(lock_usage, lock_options);
 
tools/perf/perf-completion.sh +1 -1
index f44c04b..ecedab6 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem|mem) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
#7 lore raw

PATCH 4/4 perf sched: introduce --list-cmds for use by scripts

In reply to Ramkumar Ramachandra
---
 tools/perf/builtin-sched.c    | 10 ++++++----
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-sched.c +6 -4
index 6a76a07..347bd32 100644
@@ -1713,8 +1713,10 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
 		"perf sched replay [<options>]",
 		NULL
 	};
-	const char * const sched_usage[] = {
-		"perf sched [<options>] {record|latency|map|replay|script}",
+	const char *const sched_subcommands[] = { "record", "latency", "map",
+						  "replay", "script", NULL };
+	const char *sched_usage[] = {
+		NULL,
 		NULL
 	};
 	struct trace_sched_handler lat_ops  = {
@@ -1736,8 +1738,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
 	for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
 		sched.curr_pid[i] = -1;
 
-	argc = parse_options(argc, argv, sched_options, sched_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands,
+					sched_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 	if (!argc)
 		usage_with_options(sched_usage, sched_options);
 
tools/perf/perf-completion.sh +1 -1
index ecedab6..3356984 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Signature · 1 line
1.9.rc0.1.g9d22d25
#8 lore raw

[tip:perf/core] perf sched: Introduce --list-cmds for use by scripts

perf sched: Introduce --list-cmds for use by scripts
Commit-ID:  a83edb2dfc5989fbadc594109c933bae528a2809
Gitweb:     http://git.kernel.org/tip/a83edb2dfc5989fbadc594109c933bae528a2809
Author:     Ramkumar Ramachandra <[email protected]>
AuthorDate: Fri, 14 Mar 2014 23:17:54 -0400
Committer:  Jiri Olsa <[email protected]>
CommitDate: Wed, 16 Apr 2014 17:16:05 +0200

perf sched: Introduce --list-cmds for use by scripts

---
 tools/perf/builtin-sched.c    | 10 ++++++----
 tools/perf/perf-completion.sh |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/builtin-sched.c +6 -4
index 9ac0a49..d3fb0ed 100644
@@ -1713,8 +1713,10 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
 		"perf sched replay [<options>]",
 		NULL
 	};
-	const char * const sched_usage[] = {
-		"perf sched [<options>] {record|latency|map|replay|script}",
+	const char *const sched_subcommands[] = { "record", "latency", "map",
+						  "replay", "script", NULL };
+	const char *sched_usage[] = {
+		NULL,
 		NULL
 	};
 	struct trace_sched_handler lat_ops  = {
@@ -1736,8 +1738,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
 	for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
 		sched.curr_pid[i] = -1;
 
-	argc = parse_options(argc, argv, sched_options, sched_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION);
+	argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands,
+					sched_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 	if (!argc)
 		usage_with_options(sched_usage, sched_options);
 
tools/perf/perf-completion.sh +1 -1
index ecedab6..3356984 100644
@@ -122,7 +122,7 @@ __perf_main ()
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
 	# List subcommands for perf commands
-	elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then
+	elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
Acked-by on the v1 series
#9 lore raw
In reply to Ramkumar Ramachandra
Quoted 6 lines · Ramkumar Ramachandra

Hi,

With "perf kvm: introduce --list-cmds for use by scripts" accepted, these are trivial follow-on patches to enable the same functionality in kmem, mem, lock, and sched.

Quoted 8 lines

Thanks.

Ramkumar Ramachandra (4):
perf kmem: introduce --list-cmds for use by scripts perf mem: introduce --list-cmds for use by scripts perf lock: introduce --list-cmds for use by scripts perf sched: introduce --list-cmds for use by scripts

All 4 look good to me.

#10 lore raw
Quoted 10 lines · David Ahern
Quoted 6 lines

Ramkumar Ramachandra (4):
perf kmem: introduce --list-cmds for use by scripts perf mem: introduce --list-cmds for use by scripts perf lock: introduce --list-cmds for use by scripts perf sched: introduce --list-cmds for use by scripts

All 4 look good to me.

Arnaldo: I noticed that you haven't picked these up yet. Let me know if they're not okay.

Thanks.

Ram