Lines Matching refs:e
24 static void __event_init_opts(struct event *e, u64 config, in __event_init_opts() argument
27 memset(e, 0, sizeof(*e)); in __event_init_opts()
29 e->name = name; in __event_init_opts()
31 e->attr.type = type; in __event_init_opts()
32 e->attr.config = config; in __event_init_opts()
33 e->attr.size = sizeof(e->attr); in __event_init_opts()
35 e->attr.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | \ in __event_init_opts()
38 e->attr.sample_period = 1000; in __event_init_opts()
39 e->attr.sample_type = PERF_SAMPLE_REGS_INTR; in __event_init_opts()
40 e->attr.disabled = 1; in __event_init_opts()
44 void event_init_opts(struct event *e, u64 config, int type, char *name) in event_init_opts() argument
46 __event_init_opts(e, config, type, name, false); in event_init_opts()
49 void event_init_named(struct event *e, u64 config, char *name) in event_init_named() argument
51 event_init_opts(e, config, PERF_TYPE_RAW, name); in event_init_named()
54 void event_init(struct event *e, u64 config) in event_init() argument
56 event_init_opts(e, config, PERF_TYPE_RAW, "event"); in event_init()
59 void event_init_sampling(struct event *e, u64 config) in event_init_sampling() argument
61 __event_init_opts(e, config, PERF_TYPE_RAW, "event", true); in event_init_sampling()
69 int event_open_with_options(struct event *e, pid_t pid, int cpu, int group_fd) in event_open_with_options() argument
71 e->fd = perf_event_open(&e->attr, pid, cpu, group_fd, 0); in event_open_with_options()
72 if (e->fd == -1) { in event_open_with_options()
80 int event_open_with_group(struct event *e, int group_fd) in event_open_with_group() argument
82 return event_open_with_options(e, PERF_CURRENT_PID, PERF_NO_CPU, group_fd); in event_open_with_group()
85 int event_open_with_pid(struct event *e, pid_t pid) in event_open_with_pid() argument
87 return event_open_with_options(e, pid, PERF_NO_CPU, PERF_NO_GROUP); in event_open_with_pid()
90 int event_open_with_cpu(struct event *e, int cpu) in event_open_with_cpu() argument
92 return event_open_with_options(e, PERF_NO_PID, cpu, PERF_NO_GROUP); in event_open_with_cpu()
95 int event_open(struct event *e) in event_open() argument
97 return event_open_with_options(e, PERF_CURRENT_PID, PERF_NO_CPU, PERF_NO_GROUP); in event_open()
100 void event_close(struct event *e) in event_close() argument
102 close(e->fd); in event_close()
105 int event_enable(struct event *e) in event_enable() argument
107 return ioctl(e->fd, PERF_EVENT_IOC_ENABLE); in event_enable()
110 int event_disable(struct event *e) in event_disable() argument
112 return ioctl(e->fd, PERF_EVENT_IOC_DISABLE); in event_disable()
115 int event_reset(struct event *e) in event_reset() argument
117 return ioctl(e->fd, PERF_EVENT_IOC_RESET); in event_reset()
120 int event_read(struct event *e) in event_read() argument
124 rc = read(e->fd, &e->result, sizeof(e->result)); in event_read()
125 if (rc != sizeof(e->result)) { in event_read()
126 fprintf(stderr, "read error on event %p!\n", e); in event_read()
133 void event_report_justified(struct event *e, int name_width, int result_width) in event_report_justified() argument
135 printf("%*s: result %*llu ", name_width, e->name, result_width, in event_report_justified()
136 e->result.value); in event_report_justified()
138 if (e->result.running == e->result.enabled) in event_report_justified()
139 printf("running/enabled %llu\n", e->result.running); in event_report_justified()
141 printf("running %llu enabled %llu\n", e->result.running, in event_report_justified()
142 e->result.enabled); in event_report_justified()
145 void event_report(struct event *e) in event_report() argument
147 event_report_justified(e, 0, 0); in event_report()