All of lore.kernel.org
 help / color / mirror / Atom feed
* Some minor fixes for the perf tools json event code
@ 2016-10-05 19:47 Andi Kleen
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Andi Kleen @ 2016-10-05 19:47 UTC (permalink / raw)
  To: acme; +Cc: sukadev, jolsa, linux-kernel

Fix some issues that turned up in recent testing.

-Andi

^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH 1/3] perf, tools: Add support for perf list json
@ 2016-10-06 19:23 Andi Kleen
  2016-10-06 19:23 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
  0 siblings, 1 reply; 18+ messages in thread
From: Andi Kleen @ 2016-10-06 19:23 UTC (permalink / raw)
  To: acme; +Cc: jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Add an argument to perf list to only list json events. To be used
for the command line completion script. This requires adding
a new flag to the alias structure.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-list.txt |  2 +-
 tools/perf/builtin-list.c              |  9 ++++++---
 tools/perf/util/parse-events.c         |  2 +-
 tools/perf/util/pmu.c                  | 14 ++++++++++----
 tools/perf/util/pmu.h                  |  3 ++-
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index 41857cce5e86..50a35b27a64d 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -8,7 +8,7 @@ perf-list - List all symbolic event types
 SYNOPSIS
 --------
 [verse]
-'perf list' [--no-desc] [--long-desc] [hw|sw|cache|tracepoint|pmu|event_glob]
+'perf list' [--no-desc] [--long-desc] [hw|sw|cache|tracepoint|pmu|json|sdt|event_glob]
 
 DESCRIPTION
 -----------
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index ba9322ff858b..b9ccdc7ec733 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -32,7 +32,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 		OPT_END()
 	};
 	const char * const list_usage[] = {
-		"perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|event_glob]",
+		"perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|json|event_glob]",
 		NULL
 	};
 
@@ -69,9 +69,12 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 			print_hwcache_events(NULL, raw_dump);
 		else if (strcmp(argv[i], "pmu") == 0)
 			print_pmu_events(NULL, raw_dump, !desc_flag,
-						long_desc_flag);
+						long_desc_flag, false);
 		else if (strcmp(argv[i], "sdt") == 0)
 			print_sdt_events(NULL, NULL, raw_dump);
+		else if (strcmp(argv[i], "json") == 0)
+			print_pmu_events(NULL, raw_dump, !desc_flag,
+					long_desc_flag, true);
 		else if ((sep = strchr(argv[i], ':')) != NULL) {
 			int sep_idx;
 
@@ -100,7 +103,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 					    event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
 			print_hwcache_events(s, raw_dump);
 			print_pmu_events(s, raw_dump, !desc_flag,
-						long_desc_flag);
+						long_desc_flag, false);
 			print_tracepoint_events(NULL, s, raw_dump);
 			print_sdt_events(NULL, s, raw_dump);
 			free(s);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4e778eae1510..948ef84e4c6a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2275,7 +2275,7 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
 
 	print_hwcache_events(event_glob, name_only);
 
-	print_pmu_events(event_glob, name_only, quiet_flag, long_desc);
+	print_pmu_events(event_glob, name_only, quiet_flag, long_desc, false);
 
 	if (event_glob != NULL)
 		return;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index b1474dcadfa2..d8d7d4c0319c 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -224,7 +224,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
 
 static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
 				 char *desc, char *val, char *long_desc,
-				 char *topic)
+				 char *topic, bool json)
 {
 	struct perf_pmu_alias *alias;
 	int ret;
@@ -238,6 +238,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
 	alias->unit[0] = '\0';
 	alias->per_pkg = false;
 	alias->snapshot = false;
+	alias->json = json;
 
 	ret = parse_events_terms(&alias->terms, val);
 	if (ret) {
@@ -278,7 +279,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
 
 	buf[ret] = 0;
 
-	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL);
+	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, false);
 }
 
 static inline bool pmu_alias_info_file(char *name)
@@ -537,7 +538,8 @@ static void pmu_add_cpu_aliases(struct list_head *head)
 		/* need type casts to override 'const' */
 		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
 				(char *)pe->desc, (char *)pe->event,
-				(char *)pe->long_desc, (char *)pe->topic);
+				(char *)pe->long_desc, (char *)pe->topic,
+				true);
 	}
 
 out:
@@ -1103,7 +1105,7 @@ static void wordwrap(char *s, int start, int max, int corr)
 }
 
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
-			bool long_desc)
+			bool long_desc, bool json_only)
 {
 	struct perf_pmu *pmu;
 	struct perf_pmu_alias *alias;
@@ -1134,6 +1136,9 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 				format_alias(buf, sizeof(buf), pmu, alias);
 			bool is_cpu = !strcmp(pmu->name, "cpu");
 
+			if (json_only && !alias->json)
+				continue;
+
 			if (event_glob != NULL &&
 			    !(strglobmatch(name, event_glob) ||
 			      (!is_cpu && strglobmatch(alias->name,
@@ -1158,6 +1163,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 			j++;
 		}
 		if (pmu->selectable &&
+		    !json_only &&
 		    (event_glob == NULL || strglobmatch(pmu->name, event_glob))) {
 			char *s;
 			if (asprintf(&s, "%s//", pmu->name) < 0)
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 25712034c815..19fa2e19dbe9 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -49,6 +49,7 @@ struct perf_pmu_alias {
 	double scale;
 	bool per_pkg;
 	bool snapshot;
+	bool json;
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
@@ -75,7 +76,7 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);
 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
 
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
-		      bool long_desc);
+		      bool long_desc, bool json_only);
 bool pmu_have_event(const char *pname, const char *name);
 
 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH 1/3] perf, tools: Add support for perf list vendor
@ 2016-10-18 23:20 Andi Kleen
  2016-10-18 23:21 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
  0 siblings, 1 reply; 18+ messages in thread
From: Andi Kleen @ 2016-10-18 23:20 UTC (permalink / raw)
  To: acme; +Cc: jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Add an argument to perf list to only list vendor events. To be used
for the command line completion script. This requires adding
a new flag to the alias structure.

v2: Rename to perf list vendor/model/cpu-model
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-list.txt |  4 +++-
 tools/perf/builtin-list.c              | 17 ++++++++++++-----
 tools/perf/util/parse-events.c         |  2 +-
 tools/perf/util/pmu.c                  | 14 ++++++++++----
 tools/perf/util/pmu.h                  |  3 ++-
 5 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index 41857cce5e86..290f021af1cd 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -8,7 +8,7 @@ perf-list - List all symbolic event types
 SYNOPSIS
 --------
 [verse]
-'perf list' [--no-desc] [--long-desc] [hw|sw|cache|tracepoint|pmu|event_glob]
+'perf list' [--no-desc] [--long-desc] [hw|sw|cache|tracepoint|pmu|vendor|sdt|event_glob]
 
 DESCRIPTION
 -----------
@@ -240,6 +240,8 @@ To limit the list use:
 
 . 'pmu' to print the kernel supplied PMU events.
 
+. 'vendor' or 'model' or 'cpu-model' to print vendor supplied events
+
 . If none of the above is matched, it will apply the supplied glob to all
   events, printing the ones that match.
 
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index ba9322ff858b..1095a6dada66 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -32,7 +32,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 		OPT_END()
 	};
 	const char * const list_usage[] = {
-		"perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|event_glob]",
+		"perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|vendor|event_glob]",
 		NULL
 	};
 
@@ -57,10 +57,12 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 		if (strcmp(argv[i], "tracepoint") == 0)
 			print_tracepoint_events(NULL, NULL, raw_dump);
 		else if (strcmp(argv[i], "hw") == 0 ||
-			 strcmp(argv[i], "hardware") == 0)
+			 strcmp(argv[i], "hardware") == 0) {
 			print_symbol_events(NULL, PERF_TYPE_HARDWARE,
 					event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
-		else if (strcmp(argv[i], "sw") == 0 ||
+			print_pmu_events(NULL, raw_dump, !desc_flag,
+					long_desc_flag, true);
+		} else if (strcmp(argv[i], "sw") == 0 ||
 			 strcmp(argv[i], "software") == 0)
 			print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
 					event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
@@ -69,9 +71,14 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 			print_hwcache_events(NULL, raw_dump);
 		else if (strcmp(argv[i], "pmu") == 0)
 			print_pmu_events(NULL, raw_dump, !desc_flag,
-						long_desc_flag);
+						long_desc_flag, false);
 		else if (strcmp(argv[i], "sdt") == 0)
 			print_sdt_events(NULL, NULL, raw_dump);
+		else if (strcmp(argv[i], "vendor") == 0 ||
+			 strcmp(argv[i], "model") == 0 ||
+			 strcmp(argv[i], "cpu-model") == 0)
+			print_pmu_events(NULL, raw_dump, !desc_flag,
+					long_desc_flag, true);
 		else if ((sep = strchr(argv[i], ':')) != NULL) {
 			int sep_idx;
 
@@ -100,7 +107,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 					    event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
 			print_hwcache_events(s, raw_dump);
 			print_pmu_events(s, raw_dump, !desc_flag,
-						long_desc_flag);
+						long_desc_flag, false);
 			print_tracepoint_events(NULL, s, raw_dump);
 			print_sdt_events(NULL, s, raw_dump);
 			free(s);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4e778eae1510..948ef84e4c6a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2275,7 +2275,7 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
 
 	print_hwcache_events(event_glob, name_only);
 
-	print_pmu_events(event_glob, name_only, quiet_flag, long_desc);
+	print_pmu_events(event_glob, name_only, quiet_flag, long_desc, false);
 
 	if (event_glob != NULL)
 		return;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index b1474dcadfa2..d8d7d4c0319c 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -224,7 +224,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
 
 static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
 				 char *desc, char *val, char *long_desc,
-				 char *topic)
+				 char *topic, bool json)
 {
 	struct perf_pmu_alias *alias;
 	int ret;
@@ -238,6 +238,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
 	alias->unit[0] = '\0';
 	alias->per_pkg = false;
 	alias->snapshot = false;
+	alias->json = json;
 
 	ret = parse_events_terms(&alias->terms, val);
 	if (ret) {
@@ -278,7 +279,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
 
 	buf[ret] = 0;
 
-	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL);
+	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, false);
 }
 
 static inline bool pmu_alias_info_file(char *name)
@@ -537,7 +538,8 @@ static void pmu_add_cpu_aliases(struct list_head *head)
 		/* need type casts to override 'const' */
 		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
 				(char *)pe->desc, (char *)pe->event,
-				(char *)pe->long_desc, (char *)pe->topic);
+				(char *)pe->long_desc, (char *)pe->topic,
+				true);
 	}
 
 out:
@@ -1103,7 +1105,7 @@ static void wordwrap(char *s, int start, int max, int corr)
 }
 
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
-			bool long_desc)
+			bool long_desc, bool json_only)
 {
 	struct perf_pmu *pmu;
 	struct perf_pmu_alias *alias;
@@ -1134,6 +1136,9 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 				format_alias(buf, sizeof(buf), pmu, alias);
 			bool is_cpu = !strcmp(pmu->name, "cpu");
 
+			if (json_only && !alias->json)
+				continue;
+
 			if (event_glob != NULL &&
 			    !(strglobmatch(name, event_glob) ||
 			      (!is_cpu && strglobmatch(alias->name,
@@ -1158,6 +1163,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 			j++;
 		}
 		if (pmu->selectable &&
+		    !json_only &&
 		    (event_glob == NULL || strglobmatch(pmu->name, event_glob))) {
 			char *s;
 			if (asprintf(&s, "%s//", pmu->name) < 0)
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 25712034c815..19fa2e19dbe9 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -49,6 +49,7 @@ struct perf_pmu_alias {
 	double scale;
 	bool per_pkg;
 	bool snapshot;
+	bool json;
 };
 
 struct perf_pmu *perf_pmu__find(const char *name);
@@ -75,7 +76,7 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);
 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
 
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
-		      bool long_desc);
+		      bool long_desc, bool json_only);
 bool pmu_have_event(const char *pname, const char *name);
 
 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-10-18 23:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05 19:47 Some minor fixes for the perf tools json event code Andi Kleen
2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
2016-10-05 22:47   ` Arnaldo Carvalho de Melo
2016-10-06 16:55     ` Andi Kleen
2016-10-06 20:07       ` Arnaldo Carvalho de Melo
2016-10-06 20:18   ` Arnaldo Carvalho de Melo
2016-10-08  4:02     ` Wangnan (F)
2016-10-08  4:16     ` [PATCH] " Wang Nan
2016-10-17 14:52       ` [tip:perf/urgent] perf jevents: " tip-bot for Wang Nan
2016-10-05 19:47 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
2016-10-05 21:50   ` Arnaldo Carvalho de Melo
2016-10-05 22:18     ` Andi Kleen
2016-10-05 22:35       ` Arnaldo Carvalho de Melo
2016-10-05 19:47 ` [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions Andi Kleen
2016-10-06 22:41   ` [tip:perf/urgent] perf jevents: Fix Intel JSON " tip-bot for Andi Kleen
2016-10-06 19:23 [PATCH 1/3] perf, tools: Add support for perf list json Andi Kleen
2016-10-06 19:23 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
2016-10-06 20:05   ` Arnaldo Carvalho de Melo
2016-10-18 23:20 [PATCH 1/3] perf, tools: Add support for perf list vendor Andi Kleen
2016-10-18 23:21 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.