mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-10 02:21:34 -04:00
perf parse-events: Minor tidy up of event_type helper
Add missing breakpoint and raw types. Avoid a switch, just use a lookup array. Switch the type to unsigned to avoid checking negative values. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250710235126.1086011-3-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -135,26 +135,21 @@ const struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
|
||||
},
|
||||
};
|
||||
|
||||
const char *event_type(int type)
|
||||
static const char *const event_types[] = {
|
||||
[PERF_TYPE_HARDWARE] = "hardware",
|
||||
[PERF_TYPE_SOFTWARE] = "software",
|
||||
[PERF_TYPE_TRACEPOINT] = "tracepoint",
|
||||
[PERF_TYPE_HW_CACHE] = "hardware-cache",
|
||||
[PERF_TYPE_RAW] = "raw",
|
||||
[PERF_TYPE_BREAKPOINT] = "breakpoint",
|
||||
};
|
||||
|
||||
const char *event_type(size_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case PERF_TYPE_HARDWARE:
|
||||
return "hardware";
|
||||
if (type >= PERF_TYPE_MAX)
|
||||
return "unknown";
|
||||
|
||||
case PERF_TYPE_SOFTWARE:
|
||||
return "software";
|
||||
|
||||
case PERF_TYPE_TRACEPOINT:
|
||||
return "tracepoint";
|
||||
|
||||
case PERF_TYPE_HW_CACHE:
|
||||
return "hardware-cache";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
return event_types[type];
|
||||
}
|
||||
|
||||
static char *get_config_str(const struct parse_events_terms *head_terms,
|
||||
|
||||
@@ -21,7 +21,7 @@ struct option;
|
||||
struct perf_pmu;
|
||||
struct strbuf;
|
||||
|
||||
const char *event_type(int type);
|
||||
const char *event_type(size_t type);
|
||||
|
||||
/* Arguments encoded in opt->value. */
|
||||
struct parse_events_option_args {
|
||||
|
||||
Reference in New Issue
Block a user