perf parse-events: Break out tracepoint and printing
Ian Rogers
reviewerv3 cover perf parse-events: Break out tracepoint and printing
parse-events.c is a large piece of code that doesn't need to contain the printing (perf list) and tracepoint functionality. Split apart.
v3. Split removal of #define to its own change as suggested by Jiri
Olsa <[email protected]>.
v2. Rebase in particular after hybrid PMU changes.
Ian Rogers (2):
perf parse-events: Don't #define YY_EXTRA_TYPE perf parse-events: Break out tracepoint and printing.
tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/util/Build | 2 + tools/perf/util/parse-events.c | 714 +---------------------------- tools/perf/util/parse-events.h | 31 -- tools/perf/util/print-events.c | 571 +++++++++++++++++++++++ tools/perf/util/print-events.h | 22 + tools/perf/util/trace-event-info.c | 96 ++++ tools/perf/util/tracepoint.c | 63 +++ tools/perf/util/tracepoint.h | 25 + 12 files changed, 790 insertions(+), 739 deletions(-) create mode 100644 tools/perf/util/print-events.c create mode 100644 tools/perf/util/print-events.h create mode 100644 tools/perf/util/tracepoint.c create mode 100644 tools/perf/util/tracepoint.h
Signature · 1 line
2.37.1.455.g008518b4e5-goog
Ian Rogers
reviewerPATCH v3 1/2 perf parse-events: Don't #define YY_EXTRA_TYPE
Adding a #define to side-effect a local include isn't clean, for example, it inhibits header precompilation. YY_EXTRA_TYPE is defined to be void* by default, so just remove.
--- tools/perf/util/parse-events.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/parse-events.c +0 -1
@@ -24,7 +24,6 @@#include <api/fs/tracing_path.h> #include <perf/cpumap.h> #include "parse-events-bison.h" -#define YY_EXTRA_TYPE void*#include "parse-events-flex.h" #include "pmu.h" #include "thread_map.h"
Signature · 1 line
2.37.1.455.g008518b4e5-goog
Ian Rogers
reviewerPATCH v3 2/2 perf parse-events: Break out tracepoint and printing.
In reply to Ian RogersMove print_*_events functions out of parse-events.c into a new print-events.c. Move tracepoint code into tracepoint.c or trace-event-info.c (sole user). This reduces the dependencies of parse-events.c and makes it more amenable to being a library in the future.
Remove some unnecessary definitions from parse-events.h. Fix a checkpatch.pl warning on using unsigned rather than unsigned int. Fix some line length warnings too.
--- tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/util/Build | 2 + tools/perf/util/parse-events.c | 713 +---------------------------- tools/perf/util/parse-events.h | 31 -- tools/perf/util/print-events.c | 571 +++++++++++++++++++++++ tools/perf/util/print-events.h | 22 + tools/perf/util/trace-event-info.c | 96 ++++ tools/perf/util/tracepoint.c | 63 +++ tools/perf/util/tracepoint.h | 25 + 12 files changed, 790 insertions(+), 738 deletions(-) create mode 100644 tools/perf/util/print-events.c create mode 100644 tools/perf/util/print-events.h create mode 100644 tools/perf/util/tracepoint.c create mode 100644 tools/perf/util/tracepoint.h
tools/perf/builtin-list.c +1 -1
@@ -10,7 +10,7 @@*/ #include "builtin.h" -#include "util/parse-events.h" +#include "util/print-events.h" #include "util/pmu.h" #include "util/pmu-hybrid.h" #include "util/debug.h"
tools/perf/builtin-lock.c +1 -0
@@ -14,6 +14,7 @@#include <subcmd/pager.h> #include <subcmd/parse-options.h> #include "util/trace-event.h" +#include "util/tracepoint.h" #include "util/debug.h" #include "util/session.h"
tools/perf/builtin-timechart.c +1 -0
@@ -36,6 +36,7 @@#include "util/data.h" #include "util/debug.h" #include "util/string2.h" +#include "util/tracepoint.h" #include <linux/err.h> #ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE
tools/perf/builtin-trace.c +1 -0
@@ -53,6 +53,7 @@#include "trace-event.h" #include "util/parse-events.h" #include "util/bpf-loader.h" +#include "util/tracepoint.h" #include "callchain.h" #include "print_binary.h" #include "string2.h"
tools/perf/util/Build +2 -0
@@ -26,6 +26,8 @@ perf-y += mmap.o perf-y += memswap.o perf-y += parse-events.o perf-y += parse-events-hybrid.o +perf-y += print-events.o +perf-y += tracepoint.o perf-y += perf_regs.o perf-y += path.o perf-y += print_binary.o
tools/perf/util/parse-events.c +7 -706
758 lines not on this page · raw message
tools/perf/util/parse-events.h +0 -31
@@ -11,7 +11,6 @@#include <linux/perf_event.h> #include <string.h> -struct list_head ;struct evsel ;struct evlist ;struct parse_events_error ;
@@ -19,14 +18,6 @@ struct parse_events_error;struct option ;struct perf_pmu ; -struct tracepoint_path { -char *system; -char *name; -struct tracepoint_path *next; -}; - -struct tracepoint_path *tracepoint_id_to_path (u64 config); -struct tracepoint_path *tracepoint_name_to_path (const char *name);bool have_tracepoints (struct list_head *evlist);const char *event_type (int type);
@@ -46,8 +37,6 @@ int parse_events_terms(struct list_head *terms, const char *str);int parse_filter (const struct option *opt,const char *str,int unset);int exclude_perf (const struct option *opt,const char *arg,int unset); -#define EVENTS_HELP_MAX (128*1024) -enum perf_pmu_event_symbol_type {PMU_EVENT_SYMBOL_ERR ,/* not a PMU EVENT */ PMU_EVENT_SYMBOL ,/* normal style PMU event */
@@ -56,11 +45,6 @@ enum perf_pmu_event_symbol_type { PMU_EVENT_SYMBOL_SUFFIX2, /* suffix of pre-suf2 style event */ }; -struct perf_pmu_event_symbol { -char *symbol; -enum perf_pmu_event_symbol_type type; -}; -enum {PARSE_EVENTS__TERM_TYPE_NUM ,PARSE_EVENTS__TERM_TYPE_STR ,
@@ -219,28 +203,13 @@ void parse_events_update_lists(struct list_head *list_event,void parse_events_evlist_error (struct parse_events_state *parse_state,int idx,const char *str); -void print_events (const char *event_glob,bool name_only,bool quiet, -bool long_desc,bool details_flag,bool deprecated, -const char *pmu_name); -struct event_symbol {const char *symbol;const char *alias; };extern struct event_symbol event_symbols_hw[];extern struct event_symbol event_symbols_sw[]; -void print_symbol_events (const char *event_glob,unsigned type, -struct event_symbol *syms,unsigned max, -bool name_only); -void print_tool_events (const char *event_glob,bool name_only); -void print_tracepoint_events (const char *subsys_glob,const char *event_glob, -bool name_only); -int print_hwcache_events (const char *event_glob,bool name_only); -void print_sdt_events (const char *subsys_glob,const char *event_glob, -bool name_only); -int is_valid_tracepoint (const char *event_string); -int valid_event_mount (const char *eventfs);char *parse_events_formats_error_string (char *additional_terms);void parse_events_error__init (struct parse_events_error *err);
tools/perf/util/print-events.c new file +571 -0
571 lines not on this page · raw message
tools/perf/util/print-events.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_PRINT_EVENTS_H +#define __PERF_PRINT_EVENTS_H + +#include <stdbool.h> + +struct event_symbol ; + +void print_events (const char *event_glob,bool name_only,bool quiet_flag, +bool long_desc,bool details_flag,bool deprecated, +const char *pmu_name); +int print_hwcache_events (const char *event_glob,bool name_only); +void print_sdt_events (const char *subsys_glob,const char *event_glob, +bool name_only); +void print_symbol_events (const char *event_glob,unsigned int type, +struct event_symbol *syms,unsigned int max, +bool name_only); +void print_tool_events (const char *event_glob,bool name_only); +void print_tracepoint_events (const char *subsys_glob,const char *event_glob, +bool name_only); + +#endif /* __PERF_PRINT_EVENTS_H */
tools/perf/util/trace-event-info.c +96 -0
118 lines not on this page · raw message
tools/perf/util/tracepoint.c new file +63 -0
63 lines not on this page · raw message
tools/perf/util/tracepoint.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_TRACEPOINT_H +#define __PERF_TRACEPOINT_H + +#include <dirent.h> +#include <string.h> + +int tp_event_has_id (const char *dir_path,struct dirent *evt_dir); + +#define for_each_event (dir_path, evt_dir, evt_dirent) \ + while ((evt_dirent = readdir(evt_dir)) != NULL) \ + if (evt_dirent->d_type == DT_DIR && \ + (strcmp(evt_dirent->d_name, ".")) && \ + (strcmp(evt_dirent->d_name, "..")) && \ + (!tp_event_has_id(dir_path, evt_dirent))) + +#define for_each_subsystem (sys_dir, sys_dirent) \ + while ((sys_dirent = readdir(sys_dir)) != NULL) \ + if (sys_dirent->d_type == DT_DIR && \ + (strcmp(sys_dirent->d_name, ".")) && \ + (strcmp(sys_dirent->d_name, ".."))) + +int is_valid_tracepoint (const char *event_string); + +#endif /* __PERF_TRACEPOINT_H */
Signature · 1 line
2.37.1.455.g008518b4e5-goog