Skip to contentSkip to conversation

perf:Adding --list-opts to usage string

PATCH Superseded Arnaldo Carvalho de Melo 6 participants 18 messages Oct 13, 2015 – Oct 21, 2015 2 messages not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Arnaldo Carvalho de Melo

author maintainer
#1 lore raw

Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:

Quoted 3 lines

Minor change, adding --list-opts to usage string. So that it is visible to the user on running perf --help. or just perf from command line.

Ramkumar, Yunlong, are you ok with this?

- Arnaldo

Quoted 20 lines
---
 tools/perf/perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf.c +1 -2
index 07dbff5..92b5007 100644
@@ -19,7 +19,7 @@
 #include <pthread.h>
 
 const char perf_usage_string[] =
-	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+	"perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
 
 const char perf_more_info_string[] =
 	"See 'perf help COMMAND' for more information on a specific command.";
--

2.6.1

#2 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:

Quoted 3 lines

Minor change, adding --list-opts to usage string. So that it is visible to the user on running perf --help. or just perf from command line.

Ramkumar, Yunlong, are you ok with this?

Not sure I understand the motivation, but I suppose it can't hurt to show this detail?

Ram

Quoted 20 lines
Quoted 20 lines
---
 tools/perf/perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf.c +1 -2
index 07dbff5..92b5007 100644
@@ -19,7 +19,7 @@
 #include <pthread.h>
 
 const char perf_usage_string[] =
-     "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+     "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
 
 const char perf_more_info_string[] =
      "See 'perf help COMMAND' for more information on a specific command.";
--

2.6.1

#3 lore raw
Quoted 7 lines · Ramkumar Ramachandra
Quoted 6 lines · Arnaldo Carvalho de Melo

Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:

Quoted 3 lines

Minor change, adding --list-opts to usage string. So that it is visible to the user on running perf --help. or just perf from command line.

Quoted 6 lines
Quoted 1 line

Ramkumar, Yunlong, are you ok with this?

Not sure I understand the motivation, but I suppose it can't hurt to show this detail?

Ram

Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in the perf_usage_string[].

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

const char perf_usage_string[] =

(quoted diff) +1 -1
-     "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+     "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
Signature · 2 lines
Thanks,
Yunlong Song
author maintainer
#4 lore raw

Em Wed, Oct 14, 2015 at 10:29:05AM +0800, Yunlong Song escreveu:

Quoted 7 lines · Ramkumar Ramachandra
Quoted 6 lines
Quoted 5 lines · Arnaldo Carvalho de Melo

Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:

Quoted 3 lines

Minor change, adding --list-opts to usage string. So that it is visible to the user on running perf --help. or just perf from command line.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Ramkumar, Yunlong, are you ok with this?

Not sure I understand the motivation, but I suppose it can't hurt to show this detail?

Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in the perf_usage_string[].

I see, thinking about it now, it seems that this is because 'perf -h' behaves differently from other tools, i.e.:

$ perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

   annotate        Read perf.data (created by perf record) and display annotated code
   archive         Create archive with object files with build-ids found in perf.data file
   bench           General framework for benchmark suites
   buildid-cache   Manage build-id cache.
   buildid-list    List the buildids in a perf.data file
<SNIP>
   test            Runs sanity tests.
   timechart       Tool to visualize total system behavior during a workload
   top             System profiling tool.
   trace           strace inspired tool
   probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

--------------------------

While:

$ perf stat -h

usage: perf stat [<options>] [<command>]

-T, --transaction hardware transaction statistics
-e, --event <event> event selector. use 'perf list' to list available events
--filter <filter>
event filter
-i, --no-inherit child tasks do not inherit counters
-p, --pid <pid> stat events on existing process id
-t, --tid <tid> stat events on existing thread id
-a, --all-cpus system-wide collection from all CPUs
<SNIP>
-I, --interval-print <n>
print counts at regular interval in ms (>= 10)
--per-socket aggregate counts per processor socket
--per-core aggregate counts per physical processor core
--per-thread aggregate counts per thread
-D, --delay <n> ms to wait before starting measurement after program start

--------------------------

One doesn't show what options can be used, the other does, so there is an inconsistency, this and the fact that 'perf -h' outputs to stdout, 'perf stat -h' and the other builtins output to stderr. I think all should output to stdout, just like 'ls --help', what do you think?

- Arnaldo

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

const char perf_usage_string[] =

(quoted diff) +1 -1
-     "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+     "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
Signature · 2 lines
Thanks,
Yunlong Song
maintainer
#5 lore raw

Hi Arnaldo,

Quoted 15 lines · Arnaldo Carvalho de Melo

Em Wed, Oct 14, 2015 at 10:29:05AM +0800, Yunlong Song escreveu:

Quoted 14 lines · Ramkumar Ramachandra
Quoted 10 lines
Quoted 6 lines · Arnaldo Carvalho de Melo

Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:

Quoted 3 lines

Minor change, adding --list-opts to usage string. So that it is visible to the user on running perf --help. or just perf from command line.

Ramkumar, Yunlong, are you ok with this?

Not sure I understand the motivation, but I suppose it can't hurt to show this detail?

Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in the perf_usage_string[].

AFAIK the --list-cmds and --list-opts options are just for completion scripts, not for human. I don't think we need to expose them to normal users.

Quoted 9 lines

I see, thinking about it now, it seems that this is because 'perf -h' behaves differently from other tools, i.e.:

$ perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

One nit, these are not commonly used commands, but all commands. :) Anyway it'd be better to add option descriptions here for consistency.

Quoted 38 lines
   annotate        Read perf.data (created by perf record) and display annotated code
   archive         Create archive with object files with build-ids found in perf.data file
   bench           General framework for benchmark suites
   buildid-cache   Manage build-id cache.
   buildid-list    List the buildids in a perf.data file
<SNIP>
   test            Runs sanity tests.
   timechart       Tool to visualize total system behavior during a workload
   top             System profiling tool.
   trace           strace inspired tool
   probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

--------------------------

While:

$ perf stat -h

usage: perf stat [<options>] [<command>]

-T, --transaction hardware transaction statistics
-e, --event <event> event selector. use 'perf list' to list available events
--filter <filter>
event filter
-i, --no-inherit child tasks do not inherit counters
-p, --pid <pid> stat events on existing process id
-t, --tid <tid> stat events on existing thread id
-a, --all-cpus system-wide collection from all CPUs
<SNIP>
-I, --interval-print <n>
print counts at regular interval in ms (>= 10)
--per-socket aggregate counts per processor socket
--per-core aggregate counts per physical processor core
--per-thread aggregate counts per thread
-D, --delay <n> ms to wait before starting measurement after program start

Quoted 6 lines

--------------------------

One doesn't show what options can be used, the other does, so there is an inconsistency, this and the fact that 'perf -h' outputs to stdout, 'perf stat -h' and the other builtins output to stderr. I think all should output to stdout, just like 'ls --help', what do you think?

I'm ok with changing to stdout.

Thanks,
Namhyung

#6 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 7 lines · Arnaldo Carvalho de Melo

One doesn't show what options can be used, the other does, so there is an inconsistency, this and the fact that 'perf -h' outputs to stdout, 'perf stat -h' and the other builtins output to stderr. I think all should output to stdout, just like 'ls --help', what do you think?

- Arnaldo

I think the reason that options do not show in 'perf -h' but show in other builtins is not the different use of stdout or stderr. I will send a patch to fix this instead.

Signature · 2 lines
Thanks,
Yunlong Song

A message that is not in the archive (sent off-list or not yet received): CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com

#8 lore raw

PATCH 1/1 perf :redirection of usage strings to stdout

This patch is to redirect the usage/builtin help strings to stdout rather than stderr. This is follows the patter similar to that of some of the coreutils (ls, rm).

This patch originated from the discussion on a mail loop about the inconsistency usage of stdout/stderr usage.

Tested the piece of code below with

# perf stat -h > /tmp/foo 2>> /tmp/bar
# perf --help > /tmp/foo 2>&1 /tmp/bar
---
 tools/perf/util/parse-options.c | 54 ++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
tools/perf/util/parse-options.c +27 -27
index 01626be..c81b2e3 100644
@@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full)
 	int pad;
 
 	if (opts->type == OPTION_GROUP) {
-		fputc('\n', stderr);
+		fputc('\n', stdout);
 		if (*opts->help)
-			fprintf(stderr, "%s\n", opts->help);
+			fprintf(stdout, "%s\n", opts->help);
 		return;
 	}
 	if (!full && (opts->flags & PARSE_OPT_HIDDEN))
@@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full)
 	if (opts->flags & PARSE_OPT_DISABLED)
 		return;
 
-	pos = fprintf(stderr, "    ");
+	pos = fprintf(stdout, "    ");
 	if (opts->short_name)
-		pos += fprintf(stderr, "-%c", opts->short_name);
+		pos += fprintf(stdout, "-%c", opts->short_name);
 	else
-		pos += fprintf(stderr, "    ");
+		pos += fprintf(stdout, "    ");
 
 	if (opts->long_name && opts->short_name)
-		pos += fprintf(stderr, ", ");
+		pos += fprintf(stdout, ", ");
 	if (opts->long_name)
-		pos += fprintf(stderr, "--%s", opts->long_name);
+		pos += fprintf(stdout, "--%s", opts->long_name);
 
 	switch (opts->type) {
 	case OPTION_ARGUMENT:
@@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full)
 	case OPTION_UINTEGER:
 		if (opts->flags & PARSE_OPT_OPTARG)
 			if (opts->long_name)
-				pos += fprintf(stderr, "[=<n>]");
+				pos += fprintf(stdout, "[=<n>]");
 			else
-				pos += fprintf(stderr, "[<n>]");
+				pos += fprintf(stdout, "[<n>]");
 		else
-			pos += fprintf(stderr, " <n>");
+			pos += fprintf(stdout, " <n>");
 		break;
 	case OPTION_CALLBACK:
 		if (opts->flags & PARSE_OPT_NOARG)
@@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full)
 		if (opts->argh) {
 			if (opts->flags & PARSE_OPT_OPTARG)
 				if (opts->long_name)
-					pos += fprintf(stderr, "[=<%s>]", opts->argh);
+					pos += fprintf(stdout, "[=<%s>]", opts->argh);
 				else
-					pos += fprintf(stderr, "[<%s>]", opts->argh);
+					pos += fprintf(stdout, "[<%s>]", opts->argh);
 			else
-				pos += fprintf(stderr, " <%s>", opts->argh);
+				pos += fprintf(stdout, " <%s>", opts->argh);
 		} else {
 			if (opts->flags & PARSE_OPT_OPTARG)
 				if (opts->long_name)
-					pos += fprintf(stderr, "[=...]");
+					pos += fprintf(stdout, "[=...]");
 				else
-					pos += fprintf(stderr, "[...]");
+					pos += fprintf(stdout, "[...]");
 			else
-				pos += fprintf(stderr, " ...");
+				pos += fprintf(stdout, " ...");
 		}
 		break;
 	default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
@@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full)
 	if (pos <= USAGE_OPTS_WIDTH)
 		pad = USAGE_OPTS_WIDTH - pos;
 	else {
-		fputc('\n', stderr);
+		fputc('\n', stdout);
 		pad = USAGE_OPTS_WIDTH;
 	}
-	fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+	fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
 }
 
 int usage_with_options_internal(const char * const *usagestr,
@@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr,
 	if (!usagestr)
 		return PARSE_OPT_HELP;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stdout, "\n usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
-		fprintf(stderr, "    or: %s\n", *usagestr++);
+		fprintf(stdout, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
-		fprintf(stderr, "%s%s\n",
+		fprintf(stdout, "%s%s\n",
 				**usagestr ? "    " : "",
 				*usagestr);
 		usagestr++;
 	}
 
 	if (opts->type != OPTION_GROUP)
-		fputc('\n', stderr);
+		fputc('\n', stdout);
 
 	for (  ; opts->type != OPTION_END; opts++)
 		print_option_help(opts, full);
 
-	fputc('\n', stderr);
+	fputc('\n', stdout);
 
 	return PARSE_OPT_HELP;
 }
@@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr,
 	if (!usagestr)
 		goto opt;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stdout, "\n usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
-		fprintf(stderr, "    or: %s\n", *usagestr++);
+		fprintf(stdout, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
-		fprintf(stderr, "%s%s\n",
+		fprintf(stdout, "%s%s\n",
 				**usagestr ? "    " : "",
 				*usagestr);
 		usagestr++;
 	}
-	fputc('\n', stderr);
+	fputc('\n', stdout);
 
 opt:
 	for (  ; opts->type != OPTION_END; opts++) {
Signature · 1 line
2.6.1
#9 lore raw

Re: [PATCH 1/1] perf :redirection of usage strings to stdout

Sorry, I made a mistake please ignore this patch.

Sriram

Quoted 159 lines · Sriram Raghunathan

This patch is to redirect the usage/builtin help strings to stdout rather than stderr. This is follows the patter similar to that of some of the coreutils (ls, rm).

This patch originated from the discussion on a mail loop about the inconsistency usage of stdout/stderr usage.

Tested the piece of code below with

# perf stat -h > /tmp/foo 2>> /tmp/bar
# perf --help > /tmp/foo 2>&1 /tmp/bar
---
  tools/perf/util/parse-options.c | 54 ++++++++++++++++++++---------------------
  1 file changed, 27 insertions(+), 27 deletions(-)
tools/perf/util/parse-options.c +27 -27
index 01626be..c81b2e3 100644
@@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full)
  	int pad;
 
  	if (opts->type == OPTION_GROUP) {
-		fputc('\n', stderr);
+		fputc('\n', stdout);
  		if (*opts->help)
-			fprintf(stderr, "%s\n", opts->help);
+			fprintf(stdout, "%s\n", opts->help);
  		return;
  	}
  	if (!full && (opts->flags & PARSE_OPT_HIDDEN))
@@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full)
  	if (opts->flags & PARSE_OPT_DISABLED)
  		return;
 
-	pos = fprintf(stderr, "    ");
+	pos = fprintf(stdout, "    ");
  	if (opts->short_name)
-		pos += fprintf(stderr, "-%c", opts->short_name);
+		pos += fprintf(stdout, "-%c", opts->short_name);
  	else
-		pos += fprintf(stderr, "    ");
+		pos += fprintf(stdout, "    ");
 
  	if (opts->long_name && opts->short_name)
-		pos += fprintf(stderr, ", ");
+		pos += fprintf(stdout, ", ");
  	if (opts->long_name)
-		pos += fprintf(stderr, "--%s", opts->long_name);
+		pos += fprintf(stdout, "--%s", opts->long_name);
 
  	switch (opts->type) {
  	case OPTION_ARGUMENT:
@@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full)
  	case OPTION_UINTEGER:
  		if (opts->flags & PARSE_OPT_OPTARG)
  			if (opts->long_name)
-				pos += fprintf(stderr, "[=<n>]");
+				pos += fprintf(stdout, "[=<n>]");
  			else
-				pos += fprintf(stderr, "[<n>]");
+				pos += fprintf(stdout, "[<n>]");
  		else
-			pos += fprintf(stderr, " <n>");
+			pos += fprintf(stdout, " <n>");
  		break;
  	case OPTION_CALLBACK:
  		if (opts->flags & PARSE_OPT_NOARG)
@@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full)
  		if (opts->argh) {
  			if (opts->flags & PARSE_OPT_OPTARG)
  				if (opts->long_name)
-					pos += fprintf(stderr, "[=<%s>]", opts->argh);
+					pos += fprintf(stdout, "[=<%s>]", opts->argh);
  				else
-					pos += fprintf(stderr, "[<%s>]", opts->argh);
+					pos += fprintf(stdout, "[<%s>]", opts->argh);
  			else
-				pos += fprintf(stderr, " <%s>", opts->argh);
+				pos += fprintf(stdout, " <%s>", opts->argh);
  		} else {
  			if (opts->flags & PARSE_OPT_OPTARG)
  				if (opts->long_name)
-					pos += fprintf(stderr, "[=...]");
+					pos += fprintf(stdout, "[=...]");
  				else
-					pos += fprintf(stderr, "[...]");
+					pos += fprintf(stdout, "[...]");
  			else
-				pos += fprintf(stderr, " ...");
+				pos += fprintf(stdout, " ...");
  		}
  		break;
  	default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
@@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full)
  	if (pos <= USAGE_OPTS_WIDTH)
  		pad = USAGE_OPTS_WIDTH - pos;
  	else {
-		fputc('\n', stderr);
+		fputc('\n', stdout);
  		pad = USAGE_OPTS_WIDTH;
  	}
-	fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+	fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
  }
 
  int usage_with_options_internal(const char * const *usagestr,
@@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr,
  	if (!usagestr)
  		return PARSE_OPT_HELP;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stdout, "\n usage: %s\n", *usagestr++);
  	while (*usagestr && **usagestr)
-		fprintf(stderr, "    or: %s\n", *usagestr++);
+		fprintf(stdout, "    or: %s\n", *usagestr++);
  	while (*usagestr) {
-		fprintf(stderr, "%s%s\n",
+		fprintf(stdout, "%s%s\n",
  				**usagestr ? "    " : "",
  				*usagestr);
  		usagestr++;
  	}
 
  	if (opts->type != OPTION_GROUP)
-		fputc('\n', stderr);
+		fputc('\n', stdout);
 
  	for (  ; opts->type != OPTION_END; opts++)
  		print_option_help(opts, full);
 
-	fputc('\n', stderr);
+	fputc('\n', stdout);
 
  	return PARSE_OPT_HELP;
  }
@@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr,
  	if (!usagestr)
  		goto opt;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stdout, "\n usage: %s\n", *usagestr++);
  	while (*usagestr && **usagestr)
-		fprintf(stderr, "    or: %s\n", *usagestr++);
+		fprintf(stdout, "    or: %s\n", *usagestr++);
  	while (*usagestr) {
-		fprintf(stderr, "%s%s\n",
+		fprintf(stdout, "%s%s\n",
  				**usagestr ? "    " : "",
  				*usagestr);
  		usagestr++;
  	}
-	fputc('\n', stderr);
+	fputc('\n', stdout);
 
  opt:
  	for (  ; opts->type != OPTION_END; opts++) {
#10 lore raw
In reply to a message not in the archive
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 8 lines · Le 14 oct. 2015 10:33 AM, "Yunlong Song" <[email protected]…
Quoted 5 lines · Arnaldo Carvalho de Melo

One doesn't show what options can be used, the other does, so there is an inconsistency, this and the fact that 'perf -h' outputs to stdout, 'perf stat -h' and the other builtins output to stderr. I think all should output to stdout, just like 'ls --help', what do you think?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

- Arnaldo

I think the reason that options do not show in 'perf -h' but show in other builtins is not the different use of stdout or stderr. I will send a patch to fix this instead.

Sure, I mentioned two problems. The invonsistency in stdout/stderr usage has nothing to do with options being not showed in 'perf -h'. :-)

Quoted 1 line

Sorry, I understand now. I think it makes sense that the builtins use stderr everywhere to show its usage info when the opts or cmds are incorrectly used. Usually, there is an error description followed with the usage info, for example:

 # ./perf stat -f
  Error: unknown switch `f'

Usage: perf stat [<options>] [<command>]

-T, --transaction hardware transaction statistics
-e, --event <event> event selector. use 'perf list' to list available events
--filter <filter>
event filter
-i, --no-inherit child tasks do not inherit counters
<SNIP>
-I, --interval-print <n>
print counts at regular interval in ms (>= 10)
--per-socket aggregate counts per processor socket
--per-core aggregate counts per physical processor core
--per-thread aggregate counts per thread
-D, --delay <n> ms to wait before starting measurement after program start

As shown above, I think the error description and the usage info should output to the same stderr area as it is now to be clear.

Thus I think it is better to make perf output its usage info to stderr instead of stdout for consistency. I will resend patches to fix this.

Signature · 2 lines
Thanks,
Yunlong Song
#11 lore raw

PATCH 1/1 perf help: Add options description to 'perf -h'

In reply to Arnaldo Carvalho de Melo

Add options description to 'perf -h' to make it consistent with other builtins (e.g., 'perf stat -h').

Example:

Before this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

After this patch:

 # perf -h

Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

         --help            help
         --version         version
         --exec-path       exec-path
         --html-path       html-path
         --paginate        paginate
         --no-pager        no-pager
         --perf-dir        perf-dir
         --work-tree       work-tree
         --debugfs-dir     debugfs-dir
         --buildid-dir     buildid-dir
         --list-cmds       list-cmds
         --list-opts       list-opts
         --debug           debug

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

As shown above, the options description really appears now.

---
 tools/perf/builtin-help.c       |  2 +-
 tools/perf/builtin.h            |  3 +++
 tools/perf/perf.c               | 12 ++++++++----
 tools/perf/util/parse-options.c |  9 ++++++++-
 tools/perf/util/parse-options.h |  3 +++
 5 files changed, 23 insertions(+), 6 deletions(-)
tools/perf/builtin-help.c +1 -1
index 36486ea..5cb29fe 100644
@@ -470,7 +470,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
 	}
 
 	if (!argv[0]) {
-		printf("\n usage: %s\n\n", perf_usage_string);
+		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
 		printf("\n %s\n\n", perf_more_info_string);
 		return 0;
tools/perf/builtin.h +3 -0
index 3688ad2..4439db0 100644
@@ -3,9 +3,12 @@
 
 #include "util/util.h"
 #include "util/strbuf.h"
+#include "util/parse-options.h"
 
 extern const char perf_usage_string[];
 extern const char perf_more_info_string[];
+extern const char * const perf_usage[];
+extern struct option perf_options[];
 
 extern void list_common_cmds_help(void);
 extern const char *help_unknown_cmd(const char *cmd);
tools/perf/perf.c +8 -4
index 5437134..3bcaa10d 100644
@@ -21,6 +21,10 @@
 
 const char perf_usage_string[] =
 	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+const char * const perf_usage[] = {
+	perf_usage_string,
+	NULL
+};
 
 const char perf_more_info_string[] =
 	"See 'perf help COMMAND' for more information on a specific command.";
@@ -127,7 +131,7 @@ static void commit_pager_choice(void)
 	}
 }
 
-struct option options[] = {
+struct option perf_options[] = {
 	OPT_ARGUMENT("help", "help"),
 	OPT_ARGUMENT("version", "version"),
 	OPT_ARGUMENT("exec-path", "exec-path"),
@@ -261,8 +265,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 		} else if (!strcmp(cmd, "--list-opts")) {
 			unsigned int i;
 
-			for (i = 0; i < ARRAY_SIZE(options)-1; i++) {
-				struct option *p = options+i;
+			for (i = 0; i < ARRAY_SIZE(perf_options)-1; i++) {
+				struct option *p = perf_options+i;
 				printf("--%s ", p->long_name);
 			}
 			putchar('\n');
@@ -578,7 +582,7 @@ int main(int argc, const char **argv)
 			argv[0] += 2;
 	} else {
 		/* The user didn't specify a command; give them help */
-		printf("\n usage: %s\n\n", perf_usage_string);
+		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
 		printf("\n %s\n\n", perf_more_info_string);
 		goto out;
tools/perf/util/parse-options.c +8 -1
index 9a38b05..0ebfa4d 100644
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
 	if (!usagestr)
 		return PARSE_OPT_HELP;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stderr, "\n Usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
 		fprintf(stderr, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
@@ -677,6 +677,13 @@ void usage_with_options(const char * const *usagestr,
 	exit(129);
 }
 
+void usage_with_options_return(const char * const *usagestr,
+			const struct option *opts)
+{
+	exit_browser(false);
+	usage_with_options_internal(usagestr, opts, 0);
+}
+
 int parse_options_usage(const char * const *usagestr,
 			const struct option *opts,
 			const char *optstr, bool short_opt)
tools/perf/util/parse-options.h +3 -0
index 367d8b8..8130f83 100644
@@ -161,6 +161,9 @@ extern int parse_options_subcommand(int argc, const char **argv,
 extern NORETURN void usage_with_options(const char * const *usagestr,
                                         const struct option *options);
 
+extern void usage_with_options_return(const char * const *usagestr,
+                                      const struct option *options);
+
 /*----- incremantal advanced APIs -----*/
 
 enum {
Signature · 1 line
1.8.5.2
#12 lore raw

v2 cover perf help: Make perf's help consistent with other builtins

In reply to Arnaldo Carvalho de Melo

Hi,
Make some fixes to perf's help for consistency.

Yunlong Song (3):
perf help: Add options description to 'perf -h'
perf help: Change 'usage' to 'Usage' for consistency perf help: Change the usage's stdout to stderr for consistency

 tools/perf/builtin-help.c       | 13 +++++++------
 tools/perf/builtin.h            |  3 +++
 tools/perf/perf.c               | 14 +++++++++-----
 tools/perf/util/parse-options.c | 11 +++++++++--
 tools/perf/util/parse-options.h |  3 +++
 5 files changed, 31 insertions(+), 13 deletions(-)
Signature · 1 line
1.8.5.2
#13 lore raw

PATCH v2 1/3 perf help: Add options description to 'perf -h'

Add options description to 'perf -h' to make it consistent with other builtins (e.g., 'perf stat -h').

Example:

Before this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

After this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

         --help            help
         --version         version
         --exec-path       exec-path
         --html-path       html-path
         --paginate        paginate
         --no-pager        no-pager
         --perf-dir        perf-dir
         --work-tree       work-tree
         --debugfs-dir     debugfs-dir
         --buildid-dir     buildid-dir
         --list-cmds       list-cmds
         --list-opts       list-opts
         --debug           debug

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

As shown above, the options description really appears now.

---
 tools/perf/builtin-help.c       |  2 +-
 tools/perf/builtin.h            |  3 +++
 tools/perf/perf.c               | 12 ++++++++----
 tools/perf/util/parse-options.c |  7 +++++++
 tools/perf/util/parse-options.h |  3 +++
 5 files changed, 22 insertions(+), 5 deletions(-)
tools/perf/builtin-help.c +1 -1
index 36486ea..5cb29fe 100644
@@ -470,7 +470,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
 	}
 
 	if (!argv[0]) {
-		printf("\n usage: %s\n\n", perf_usage_string);
+		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
 		printf("\n %s\n\n", perf_more_info_string);
 		return 0;
tools/perf/builtin.h +3 -0
index 3688ad2..4439db0 100644
@@ -3,9 +3,12 @@
 
 #include "util/util.h"
 #include "util/strbuf.h"
+#include "util/parse-options.h"
 
 extern const char perf_usage_string[];
 extern const char perf_more_info_string[];
+extern const char * const perf_usage[];
+extern struct option perf_options[];
 
 extern void list_common_cmds_help(void);
 extern const char *help_unknown_cmd(const char *cmd);
tools/perf/perf.c +8 -4
index 5437134..3bcaa10d 100644
@@ -21,6 +21,10 @@
 
 const char perf_usage_string[] =
 	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+const char * const perf_usage[] = {
+	perf_usage_string,
+	NULL
+};
 
 const char perf_more_info_string[] =
 	"See 'perf help COMMAND' for more information on a specific command.";
@@ -127,7 +131,7 @@ static void commit_pager_choice(void)
 	}
 }
 
-struct option options[] = {
+struct option perf_options[] = {
 	OPT_ARGUMENT("help", "help"),
 	OPT_ARGUMENT("version", "version"),
 	OPT_ARGUMENT("exec-path", "exec-path"),
@@ -261,8 +265,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 		} else if (!strcmp(cmd, "--list-opts")) {
 			unsigned int i;
 
-			for (i = 0; i < ARRAY_SIZE(options)-1; i++) {
-				struct option *p = options+i;
+			for (i = 0; i < ARRAY_SIZE(perf_options)-1; i++) {
+				struct option *p = perf_options+i;
 				printf("--%s ", p->long_name);
 			}
 			putchar('\n');
@@ -578,7 +582,7 @@ int main(int argc, const char **argv)
 			argv[0] += 2;
 	} else {
 		/* The user didn't specify a command; give them help */
-		printf("\n usage: %s\n\n", perf_usage_string);
+		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
 		printf("\n %s\n\n", perf_more_info_string);
 		goto out;
tools/perf/util/parse-options.c +7 -0
index 9a38b05..494089b 100644
@@ -677,6 +677,13 @@ void usage_with_options(const char * const *usagestr,
 	exit(129);
 }
 
+void usage_with_options_return(const char * const *usagestr,
+			const struct option *opts)
+{
+	exit_browser(false);
+	usage_with_options_internal(usagestr, opts, 0);
+}
+
 int parse_options_usage(const char * const *usagestr,
 			const struct option *opts,
 			const char *optstr, bool short_opt)
tools/perf/util/parse-options.h +3 -0
index 367d8b8..8130f83 100644
@@ -161,6 +161,9 @@ extern int parse_options_subcommand(int argc, const char **argv,
 extern NORETURN void usage_with_options(const char * const *usagestr,
                                         const struct option *options);
 
+extern void usage_with_options_return(const char * const *usagestr,
+                                      const struct option *options);
+
 /*----- incremantal advanced APIs -----*/
 
 enum {
Signature · 1 line
1.8.5.2
maintainer
#14 lore raw

Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'

Hi,

Quoted 32 lines · Yunlong Song

Add options description to 'perf -h' to make it consistent with other builtins (e.g., 'perf stat -h').

Example:

Before this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

After this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

Quoted 13 lines
         --help            help
         --version         version
         --exec-path       exec-path
         --html-path       html-path
         --paginate        paginate
         --no-pager        no-pager
         --perf-dir        perf-dir
         --work-tree       work-tree
         --debugfs-dir     debugfs-dir
         --buildid-dir     buildid-dir
         --list-cmds       list-cmds
         --list-opts       list-opts
         --debug           debug

IMHO this *help* message is not very useful in its current form. Also please consider updating Documentation/perf.txt too.

Thanks,
Namhyung

Quoted 19 lines

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

As shown above, the options description really appears now.

#15 lore raw

Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'

Quoted 49 lines · Namhyung Kim

Hi,

Quoted 32 lines · Yunlong Song

Add options description to 'perf -h' to make it consistent with other builtins (e.g., 'perf stat -h').

Example:

Before this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

After this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

Quoted 13 lines
         --help            help
         --version         version
         --exec-path       exec-path
         --html-path       html-path
         --paginate        paginate
         --no-pager        no-pager
         --perf-dir        perf-dir
         --work-tree       work-tree
         --debugfs-dir     debugfs-dir
         --buildid-dir     buildid-dir
         --list-cmds       list-cmds
         --list-opts       list-opts
         --debug           debug
Quoted 5 lines

IMHO this *help* message is not very useful in its current form. Also please consider updating Documentation/perf.txt too.

Thanks,
Namhyung

OK, I will update the struct option of perf to a more interpretative style soon.

Quoted 23 lines
Quoted 15 lines

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints
Quoted 5 lines

See 'perf help COMMAND' for more information on a specific command.

As shown above, the options description really appears now.

.

Signature · 2 lines
Thanks,
Yunlong Song
maintainer
#16 lore raw

Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'

Quoted 50 lines · Yunlong Song
Quoted 49 lines · Namhyung Kim

Hi,

Quoted 45 lines · Yunlong Song

Add options description to 'perf -h' to make it consistent with other builtins (e.g., 'perf stat -h').

Example:

Before this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

The most commonly used perf commands are:

    annotate        Read perf.data (created by perf record) and display annotated code
    archive         Create archive with object files with build-ids found in perf.data file
    bench           General framework for benchmark suites
    buildid-cache   Manage build-id cache.
    buildid-list    List the buildids in a perf.data file
 <SNIP>
    test            Runs sanity tests.
    timechart       Tool to visualize total system behavior during a workload
    top             System profiling tool.
    trace           strace inspired tool
    probe           Define new dynamic tracepoints

See 'perf help COMMAND' for more information on a specific command.

After this patch:

 # perf -h

usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

         --help            help
         --version         version
         --exec-path       exec-path
         --html-path       html-path
         --paginate        paginate
         --no-pager        no-pager
         --perf-dir        perf-dir
         --work-tree       work-tree
         --debugfs-dir     debugfs-dir
         --buildid-dir     buildid-dir
         --list-cmds       list-cmds
         --list-opts       list-opts
         --debug           debug
Quoted 7 lines
Quoted 5 lines

IMHO this *help* message is not very useful in its current form. Also please consider updating Documentation/perf.txt too.

Thanks,
Namhyung

OK, I will update the struct option of perf to a more interpretative style soon.

In addition, --help and --version options are duplicate. And I think --perf-dir and --work-tree options are never used. Also I doubt anyone uses html help page with --html-path. Finally I think it'd be better to hide --list-cmds and --list-opts options as they're only intended to be used by completion scripts.

Thanks,
Namhyung

#17 lore raw

PATCH v2 2/3 perf help: Change 'usage' to 'Usage' for consistency

In reply to Yunlong Song

Capitalize 'usage' to make it consistent with all the other 'Usage' in the codes, e.g., usage_builtin.

---
 tools/perf/builtin-help.c       | 2 +-
 tools/perf/util/parse-options.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-help.c +1 -1
index 5cb29fe..09b0368 100644
@@ -463,7 +463,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
 			builtin_help_subcommands, builtin_help_usage, 0);
 
 	if (show_all) {
-		printf("\n usage: %s\n\n", perf_usage_string);
+		printf("\n Usage: %s\n\n", perf_usage_string);
 		list_commands("perf commands", &main_cmds, &other_cmds);
 		printf(" %s\n\n", perf_more_info_string);
 		return 0;
tools/perf/util/parse-options.c +2 -2
index 494089b..06793d9 100644
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
 	if (!usagestr)
 		return PARSE_OPT_HELP;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stderr, "\n Usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
 		fprintf(stderr, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
@@ -691,7 +691,7 @@ int parse_options_usage(const char * const *usagestr,
 	if (!usagestr)
 		goto opt;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stderr, "\n Usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
 		fprintf(stderr, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
Signature · 1 line
1.8.5.2
#18 lore raw

[tip:perf/core] perf help: Change 'usage' to 'Usage' for consistency

perf help: Change 'usage' to 'Usage' for consistency
Commit-ID:  3a134ae96ca0af06804d343019b85026486e6fe1
Gitweb:     http://git.kernel.org/tip/3a134ae96ca0af06804d343019b85026486e6fe1
Author:     Yunlong Song <[email protected]>
AuthorDate: Thu, 15 Oct 2015 15:39:51 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 19 Oct 2015 16:51:44 -0300

perf help: Change 'usage' to 'Usage' for consistency

Capitalize 'usage' to make it consistent with all the other 'Usage' in the codes, e.g., usage_builtin.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ramkumar Ramachandra <[email protected]>
Cc Sriram Raghunathan <[email protected]>
Cc Wang Nan <[email protected]>
---
 tools/perf/builtin-help.c       | 2 +-
 tools/perf/util/parse-options.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-help.c +1 -1
index 36486ea..a7d588b 100644
@@ -463,7 +463,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
 			builtin_help_subcommands, builtin_help_usage, 0);
 
 	if (show_all) {
-		printf("\n usage: %s\n\n", perf_usage_string);
+		printf("\n Usage: %s\n\n", perf_usage_string);
 		list_commands("perf commands", &main_cmds, &other_cmds);
 		printf(" %s\n\n", perf_more_info_string);
 		return 0;
tools/perf/util/parse-options.c +2 -2
index 9a38b05..8aa7922 100644
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
 	if (!usagestr)
 		return PARSE_OPT_HELP;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stderr, "\n Usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
 		fprintf(stderr, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
@@ -684,7 +684,7 @@ int parse_options_usage(const char * const *usagestr,
 	if (!usagestr)
 		goto opt;
 
-	fprintf(stderr, "\n usage: %s\n", *usagestr++);
+	fprintf(stderr, "\n Usage: %s\n", *usagestr++);
 	while (*usagestr && **usagestr)
 		fprintf(stderr, "    or: %s\n", *usagestr++);
 	while (*usagestr) {
#19 lore raw

PATCH v2 3/3 perf help: Change the usage's stdout to stderr for consistency

In reply to Yunlong Song

The builtins use stderr everywhere to show the usage info when the opts or cmds are incorrectly used, for consistency, change perf's stdout to stderr to show its usage info when it is incorrectly (including no command) used.

---
 tools/perf/builtin-help.c | 9 +++++----
 tools/perf/perf.c         | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
tools/perf/builtin-help.c +5 -4
index 09b0368..8cee457 100644
@@ -287,10 +287,11 @@ void list_common_cmds_help(void)
 			longest = strlen(common_cmds[i].name);
 	}
 
-	puts(" The most commonly used perf commands are:");
+	fputs(" The most commonly used perf commands are:\n", stderr);
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %-*s   ", longest, common_cmds[i].name);
-		puts(common_cmds[i].help);
+		fprintf(stderr, "   %-*s   ", longest, common_cmds[i].name);
+		fputs(common_cmds[i].help, stderr);
+		fputc('\n', stderr);
 	}
 }
 
@@ -472,7 +473,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!argv[0]) {
 		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
-		printf("\n %s\n\n", perf_more_info_string);
+		fprintf(stderr, "\n %s\n\n", perf_more_info_string);
 		return 0;
 	}
 
tools/perf/perf.c +1 -1
index 3bcaa10d..54ef361 100644
@@ -584,7 +584,7 @@ int main(int argc, const char **argv)
 		/* The user didn't specify a command; give them help */
 		usage_with_options_return(perf_usage, perf_options);
 		list_common_cmds_help();
-		printf("\n %s\n\n", perf_more_info_string);
+		fprintf(stderr, "\n %s\n\n", perf_more_info_string);
 		goto out;
 	}
 	cmd = argv[0];
Signature · 1 line
1.8.5.2