* [PATCH 1/2] perf list: Remove a level of indentation
@ 2013-10-30 16:15 David Ahern
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Ahern @ 2013-10-30 16:15 UTC (permalink / raw)
To: acme, linux-kernel
Cc: David Ahern, Ingo Molnar, Peter Zijlstra, Frederic Weisbecker,
Jiri Olsa, Namhyung Kim, Stephane Eranian
With a return after the if check an indentation level can be removed.
Indentation shift only; no functional changes.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/builtin-list.c | 73 ++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index e79f423cc302..45000e7d4398 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -17,48 +17,49 @@
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
+ int i;
+
setup_pager();
- if (argc == 1)
+ if (argc == 1) {
print_events(NULL, false);
- else {
- int i;
-
- for (i = 1; i < argc; ++i) {
- if (i > 2)
- putchar('\n');
- if (strncmp(argv[i], "tracepoint", 10) == 0)
- print_tracepoint_events(NULL, NULL, false);
- else if (strcmp(argv[i], "hw") == 0 ||
- strcmp(argv[i], "hardware") == 0)
- print_events_type(PERF_TYPE_HARDWARE);
- else if (strcmp(argv[i], "sw") == 0 ||
- strcmp(argv[i], "software") == 0)
- print_events_type(PERF_TYPE_SOFTWARE);
- else if (strcmp(argv[i], "cache") == 0 ||
- strcmp(argv[i], "hwcache") == 0)
- print_hwcache_events(NULL, false);
- else if (strcmp(argv[i], "pmu") == 0)
- print_pmu_events(NULL, false);
- else if (strcmp(argv[i], "--raw-dump") == 0)
- print_events(NULL, true);
- else {
- char *sep = strchr(argv[i], ':'), *s;
- int sep_idx;
+ return 0;
+ }
- if (sep == NULL) {
- print_events(argv[i], false);
- continue;
- }
- sep_idx = sep - argv[i];
- s = strdup(argv[i]);
- if (s == NULL)
- return -1;
+ for (i = 1; i < argc; ++i) {
+ if (i > 2)
+ putchar('\n');
+ if (strncmp(argv[i], "tracepoint", 10) == 0)
+ print_tracepoint_events(NULL, NULL, false);
+ else if (strcmp(argv[i], "hw") == 0 ||
+ strcmp(argv[i], "hardware") == 0)
+ print_events_type(PERF_TYPE_HARDWARE);
+ else if (strcmp(argv[i], "sw") == 0 ||
+ strcmp(argv[i], "software") == 0)
+ print_events_type(PERF_TYPE_SOFTWARE);
+ else if (strcmp(argv[i], "cache") == 0 ||
+ strcmp(argv[i], "hwcache") == 0)
+ print_hwcache_events(NULL, false);
+ else if (strcmp(argv[i], "pmu") == 0)
+ print_pmu_events(NULL, false);
+ else if (strcmp(argv[i], "--raw-dump") == 0)
+ print_events(NULL, true);
+ else {
+ char *sep = strchr(argv[i], ':'), *s;
+ int sep_idx;
- s[sep_idx] = '\0';
- print_tracepoint_events(s, s + sep_idx + 1, false);
- free(s);
+ if (sep == NULL) {
+ print_events(argv[i], false);
+ continue;
}
+ sep_idx = sep - argv[i];
+ s = strdup(argv[i]);
+ if (s == NULL)
+ return -1;
+
+ s[sep_idx] = '\0';
+ print_tracepoint_events(s, s + sep_idx + 1, false);
+ free(s);
}
}
return 0;
--
1.8.3.4 (Apple Git-47)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2] perf list: Add usage
2013-10-30 16:15 [PATCH 1/2] perf list: Remove a level of indentation David Ahern
@ 2013-10-30 16:15 ` David Ahern
2013-10-30 16:28 ` David Ahern
2013-10-30 19:06 ` [PATCH 2/2] " Ingo Molnar
2013-10-30 19:07 ` [PATCH 1/2] perf list: Remove a level of indentation Ingo Molnar
2013-11-06 5:43 ` [tip:perf/core] " tip-bot for David Ahern
2 siblings, 2 replies; 7+ messages in thread
From: David Ahern @ 2013-10-30 16:15 UTC (permalink / raw)
To: acme, linux-kernel
Cc: David Ahern, Ingo Molnar, Peter Zijlstra, Frederic Weisbecker,
Jiri Olsa, Namhyung Kim, Stephane Eranian
Currently perf list is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/builtin-list.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 45000e7d4398..a5ad93206044 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,10 +14,21 @@
#include "util/parse-events.h"
#include "util/cache.h"
#include "util/pmu.h"
+#include "util/parse-options.h"
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
int i;
+ const struct option list_options[] = {
+ OPT_END()
+ };
+ const char * const list_usage[] = {
+ "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+ NULL
+ };
+
+ argc = parse_options(argc, argv, list_options, list_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
setup_pager();
--
1.8.3.4 (Apple Git-47)
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/2] perf list: Add usage
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
@ 2013-10-30 16:28 ` David Ahern
2013-11-06 5:43 ` [tip:perf/core] " tip-bot for David Ahern
2013-10-30 19:06 ` [PATCH 2/2] " Ingo Molnar
1 sibling, 1 reply; 7+ messages in thread
From: David Ahern @ 2013-10-30 16:28 UTC (permalink / raw)
To: acme, linux-kernel
Cc: David Ahern, Ingo Molnar, Peter Zijlstra, Frederic Weisbecker,
Jiri Olsa, Namhyung Kim, Stephane Eranian
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
On 10/30/13, 10:15 AM, David Ahern wrote:
> Currently perf list is not very helpful if you forget the syntax:
> $ perf list -h
>
> List of pre-defined events (to be used in -e):
>
> After:
> $ perf list -h
>
> usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
gah, this version breaks perf-list. Updated patch attached.
[-- Attachment #2: 0002-perf-list-Add-usage-v2.patch --]
[-- Type: text/plain, Size: 1856 bytes --]
>From d08747060ba5af3507831e0265044be17636869d Mon Sep 17 00:00:00 2001
From: David Ahern <dsahern@gmail.com>
Date: Wed, 30 Oct 2013 10:26:45 -0600
Subject: [PATCH 2/2] perf list: Add usage - v2
Currently perf list is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
v2: reset index counter based on option parsing.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/builtin-list.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 45000e7d4398..011195e38f21 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,20 +14,31 @@
#include "util/parse-events.h"
#include "util/cache.h"
#include "util/pmu.h"
+#include "util/parse-options.h"
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
int i;
+ const struct option list_options[] = {
+ OPT_END()
+ };
+ const char * const list_usage[] = {
+ "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+ NULL
+ };
+
+ argc = parse_options(argc, argv, list_options, list_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
setup_pager();
- if (argc == 1) {
+ if (argc == 0) {
print_events(NULL, false);
return 0;
}
- for (i = 1; i < argc; ++i) {
- if (i > 2)
+ for (i = 0; i < argc; ++i) {
+ if (i)
putchar('\n');
if (strncmp(argv[i], "tracepoint", 10) == 0)
print_tracepoint_events(NULL, NULL, false);
--
1.8.3.4 (Apple Git-47)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [tip:perf/core] perf list: Add usage
2013-10-30 16:28 ` David Ahern
@ 2013-11-06 5:43 ` tip-bot for David Ahern
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for David Ahern @ 2013-11-06 5:43 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, eranian, hpa, mingo, peterz, namhyung, jolsa,
fweisbec, dsahern, tglx
Commit-ID: 44d742e01e6d3dd544ee1873b660a3c8bc1413bb
Gitweb: http://git.kernel.org/tip/44d742e01e6d3dd544ee1873b660a3c8bc1413bb
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Wed, 30 Oct 2013 10:28:29 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 5 Nov 2013 14:26:41 -0300
perf list: Add usage
Currently 'perf list' is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/527133AD.4030003@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-list.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 45000e7..011195e 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,20 +14,31 @@
#include "util/parse-events.h"
#include "util/cache.h"
#include "util/pmu.h"
+#include "util/parse-options.h"
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
int i;
+ const struct option list_options[] = {
+ OPT_END()
+ };
+ const char * const list_usage[] = {
+ "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+ NULL
+ };
+
+ argc = parse_options(argc, argv, list_options, list_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
setup_pager();
- if (argc == 1) {
+ if (argc == 0) {
print_events(NULL, false);
return 0;
}
- for (i = 1; i < argc; ++i) {
- if (i > 2)
+ for (i = 0; i < argc; ++i) {
+ if (i)
putchar('\n');
if (strncmp(argv[i], "tracepoint", 10) == 0)
print_tracepoint_events(NULL, NULL, false);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] perf list: Add usage
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
2013-10-30 16:28 ` David Ahern
@ 2013-10-30 19:06 ` Ingo Molnar
1 sibling, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2013-10-30 19:06 UTC (permalink / raw)
To: David Ahern
Cc: acme, linux-kernel, Peter Zijlstra, Frederic Weisbecker,
Jiri Olsa, Namhyung Kim, Stephane Eranian
* David Ahern <dsahern@gmail.com> wrote:
> Currently perf list is not very helpful if you forget the syntax:
> $ perf list -h
>
> List of pre-defined events (to be used in -e):
>
> After:
> $ perf list -h
>
> usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Stephane Eranian <eranian@google.com>
> ---
> tools/perf/builtin-list.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
Acked-by: Ingo Molnar <mingo@kernel.org>
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] perf list: Remove a level of indentation
2013-10-30 16:15 [PATCH 1/2] perf list: Remove a level of indentation David Ahern
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
@ 2013-10-30 19:07 ` Ingo Molnar
2013-11-06 5:43 ` [tip:perf/core] " tip-bot for David Ahern
2 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2013-10-30 19:07 UTC (permalink / raw)
To: David Ahern
Cc: acme, linux-kernel, Peter Zijlstra, Frederic Weisbecker,
Jiri Olsa, Namhyung Kim, Stephane Eranian
* David Ahern <dsahern@gmail.com> wrote:
> With a return after the if check an indentation level can be removed.
> Indentation shift only; no functional changes.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Stephane Eranian <eranian@google.com>
Haven't tested it but it looks like a good change.
Acked-by: Ingo Molnar <mingo@kernel.org>
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/core] perf list: Remove a level of indentation
2013-10-30 16:15 [PATCH 1/2] perf list: Remove a level of indentation David Ahern
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
2013-10-30 19:07 ` [PATCH 1/2] perf list: Remove a level of indentation Ingo Molnar
@ 2013-11-06 5:43 ` tip-bot for David Ahern
2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for David Ahern @ 2013-11-06 5:43 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, eranian, hpa, mingo, peterz, namhyung, jolsa,
fweisbec, dsahern, tglx
Commit-ID: 8e00ddc9dfe09ee131144fdaf6c96ebe95bbbbcb
Gitweb: http://git.kernel.org/tip/8e00ddc9dfe09ee131144fdaf6c96ebe95bbbbcb
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Wed, 30 Oct 2013 10:15:06 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 5 Nov 2013 14:25:26 -0300
perf list: Remove a level of indentation
With a return after the if check an indentation level can be removed.
Indentation shift only; no functional changes.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1383149707-1008-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-list.c | 73 ++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index e79f423..45000e7 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -17,48 +17,49 @@
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
+ int i;
+
setup_pager();
- if (argc == 1)
+ if (argc == 1) {
print_events(NULL, false);
- else {
- int i;
-
- for (i = 1; i < argc; ++i) {
- if (i > 2)
- putchar('\n');
- if (strncmp(argv[i], "tracepoint", 10) == 0)
- print_tracepoint_events(NULL, NULL, false);
- else if (strcmp(argv[i], "hw") == 0 ||
- strcmp(argv[i], "hardware") == 0)
- print_events_type(PERF_TYPE_HARDWARE);
- else if (strcmp(argv[i], "sw") == 0 ||
- strcmp(argv[i], "software") == 0)
- print_events_type(PERF_TYPE_SOFTWARE);
- else if (strcmp(argv[i], "cache") == 0 ||
- strcmp(argv[i], "hwcache") == 0)
- print_hwcache_events(NULL, false);
- else if (strcmp(argv[i], "pmu") == 0)
- print_pmu_events(NULL, false);
- else if (strcmp(argv[i], "--raw-dump") == 0)
- print_events(NULL, true);
- else {
- char *sep = strchr(argv[i], ':'), *s;
- int sep_idx;
+ return 0;
+ }
- if (sep == NULL) {
- print_events(argv[i], false);
- continue;
- }
- sep_idx = sep - argv[i];
- s = strdup(argv[i]);
- if (s == NULL)
- return -1;
+ for (i = 1; i < argc; ++i) {
+ if (i > 2)
+ putchar('\n');
+ if (strncmp(argv[i], "tracepoint", 10) == 0)
+ print_tracepoint_events(NULL, NULL, false);
+ else if (strcmp(argv[i], "hw") == 0 ||
+ strcmp(argv[i], "hardware") == 0)
+ print_events_type(PERF_TYPE_HARDWARE);
+ else if (strcmp(argv[i], "sw") == 0 ||
+ strcmp(argv[i], "software") == 0)
+ print_events_type(PERF_TYPE_SOFTWARE);
+ else if (strcmp(argv[i], "cache") == 0 ||
+ strcmp(argv[i], "hwcache") == 0)
+ print_hwcache_events(NULL, false);
+ else if (strcmp(argv[i], "pmu") == 0)
+ print_pmu_events(NULL, false);
+ else if (strcmp(argv[i], "--raw-dump") == 0)
+ print_events(NULL, true);
+ else {
+ char *sep = strchr(argv[i], ':'), *s;
+ int sep_idx;
- s[sep_idx] = '\0';
- print_tracepoint_events(s, s + sep_idx + 1, false);
- free(s);
+ if (sep == NULL) {
+ print_events(argv[i], false);
+ continue;
}
+ sep_idx = sep - argv[i];
+ s = strdup(argv[i]);
+ if (s == NULL)
+ return -1;
+
+ s[sep_idx] = '\0';
+ print_tracepoint_events(s, s + sep_idx + 1, false);
+ free(s);
}
}
return 0;
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-06 5:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-30 16:15 [PATCH 1/2] perf list: Remove a level of indentation David Ahern
2013-10-30 16:15 ` [PATCH 2/2] perf list: Add usage David Ahern
2013-10-30 16:28 ` David Ahern
2013-11-06 5:43 ` [tip:perf/core] " tip-bot for David Ahern
2013-10-30 19:06 ` [PATCH 2/2] " Ingo Molnar
2013-10-30 19:07 ` [PATCH 1/2] perf list: Remove a level of indentation Ingo Molnar
2013-11-06 5:43 ` [tip:perf/core] " tip-bot for David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox