-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 147516 b: refs/heads/master c: 8ad8db3 h: refs/heads/master v: v3
- Loading branch information
Ingo Molnar
committed
May 26, 2009
1 parent
a3e630f
commit cb72b0c
Showing
5 changed files
with
146 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 0e9b20b8a1cab6c6ab4f98f917a2d98783103969 | ||
refs/heads/master: 8ad8db3788fd9a449941fb2392ca85af4ee1cde1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
|
||
#include "../perf.h" | ||
#include "util.h" | ||
#include "parse-options.h" | ||
#include "parse-events.h" | ||
#include "exec_cmd.h" | ||
|
||
int nr_counters; | ||
|
||
__u64 event_id[MAX_COUNTERS] = { }; | ||
|
||
struct event_symbol { | ||
__u64 event; | ||
char *symbol; | ||
}; | ||
|
||
static struct event_symbol event_symbols[] = { | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_CPU_CYCLES), "cpu-cycles", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_CPU_CYCLES), "cycles", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_INSTRUCTIONS), "instructions", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_CACHE_REFERENCES), "cache-references", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_CACHE_MISSES), "cache-misses", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_BRANCH_INSTRUCTIONS), "branch-instructions", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_BRANCH_INSTRUCTIONS), "branches", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_BRANCH_MISSES), "branch-misses", }, | ||
{EID(PERF_TYPE_HARDWARE, PERF_COUNT_BUS_CYCLES), "bus-cycles", }, | ||
|
||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_CPU_CLOCK), "cpu-clock", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_TASK_CLOCK), "task-clock", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_PAGE_FAULTS), "page-faults", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_PAGE_FAULTS), "faults", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_PAGE_FAULTS_MIN), "minor-faults", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_PAGE_FAULTS_MAJ), "major-faults", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_CONTEXT_SWITCHES), "context-switches", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_CONTEXT_SWITCHES), "cs", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_CPU_MIGRATIONS), "cpu-migrations", }, | ||
{EID(PERF_TYPE_SOFTWARE, PERF_COUNT_CPU_MIGRATIONS), "migrations", }, | ||
}; | ||
|
||
/* | ||
* Each event can have multiple symbolic names. | ||
* Symbolic names are (almost) exactly matched. | ||
*/ | ||
static __u64 match_event_symbols(const char *str) | ||
{ | ||
__u64 config, id; | ||
int type; | ||
unsigned int i; | ||
|
||
if (sscanf(str, "r%llx", &config) == 1) | ||
return config | PERF_COUNTER_RAW_MASK; | ||
|
||
if (sscanf(str, "%d:%llu", &type, &id) == 2) | ||
return EID(type, id); | ||
|
||
for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { | ||
if (!strncmp(str, event_symbols[i].symbol, | ||
strlen(event_symbols[i].symbol))) | ||
return event_symbols[i].event; | ||
} | ||
|
||
return ~0ULL; | ||
} | ||
|
||
int parse_events(const struct option *opt, const char *str, int unset) | ||
{ | ||
__u64 config; | ||
|
||
again: | ||
if (nr_counters == MAX_COUNTERS) | ||
return -1; | ||
|
||
config = match_event_symbols(str); | ||
if (config == ~0ULL) | ||
return -1; | ||
|
||
event_id[nr_counters] = config; | ||
nr_counters++; | ||
|
||
str = strstr(str, ","); | ||
if (str) { | ||
str++; | ||
goto again; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
#define __PERF_COUNTER_FIELD(config, name) \ | ||
((config & PERF_COUNTER_##name##_MASK) >> PERF_COUNTER_##name##_SHIFT) | ||
|
||
#define PERF_COUNTER_RAW(config) __PERF_COUNTER_FIELD(config, RAW) | ||
#define PERF_COUNTER_CONFIG(config) __PERF_COUNTER_FIELD(config, CONFIG) | ||
#define PERF_COUNTER_TYPE(config) __PERF_COUNTER_FIELD(config, TYPE) | ||
#define PERF_COUNTER_ID(config) __PERF_COUNTER_FIELD(config, EVENT) | ||
|
||
/* | ||
* Create the help text for the event symbols: | ||
*/ | ||
void create_events_help(char *events_help_msg) | ||
{ | ||
unsigned int i; | ||
char *str; | ||
__u64 e; | ||
|
||
str = events_help_msg; | ||
|
||
str += sprintf(str, | ||
"event name: ["); | ||
|
||
for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { | ||
int type, id; | ||
|
||
e = event_symbols[i].event; | ||
type = PERF_COUNTER_TYPE(e); | ||
id = PERF_COUNTER_ID(e); | ||
|
||
if (i) | ||
str += sprintf(str, "|"); | ||
|
||
str += sprintf(str, "%s", | ||
event_symbols[i].symbol); | ||
} | ||
|
||
str += sprintf(str, "|rNNN]"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
extern int nr_counters; | ||
extern __u64 event_id[MAX_COUNTERS]; | ||
|
||
extern int parse_events(const struct option *opt, const char *str, int unset); | ||
|
||
#define EVENTS_HELP_MAX (128*1024) | ||
|
||
extern void create_events_help(char *help_msg); | ||
|