event.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2013, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #ifndef _SELFTESTS_POWERPC_PMU_EVENT_H
  6. #define _SELFTESTS_POWERPC_PMU_EVENT_H
  7. #include <unistd.h>
  8. #include <linux/perf_event.h>
  9. #include "utils.h"
  10. struct event {
  11. struct perf_event_attr attr;
  12. char *name;
  13. int fd;
  14. /* This must match the read_format we use */
  15. struct {
  16. u64 value;
  17. u64 running;
  18. u64 enabled;
  19. } result;
  20. };
  21. void event_init(struct event *e, u64 config);
  22. void event_init_named(struct event *e, u64 config, char *name);
  23. void event_init_opts(struct event *e, u64 config, int type, char *name);
  24. int event_open_with_options(struct event *e, pid_t pid, int cpu, int group_fd);
  25. int event_open_with_group(struct event *e, int group_fd);
  26. int event_open_with_pid(struct event *e, pid_t pid);
  27. int event_open_with_cpu(struct event *e, int cpu);
  28. int event_open(struct event *e);
  29. void event_close(struct event *e);
  30. int event_enable(struct event *e);
  31. int event_disable(struct event *e);
  32. int event_reset(struct event *e);
  33. int event_read(struct event *e);
  34. void event_report_justified(struct event *e, int name_width, int result_width);
  35. void event_report(struct event *e);
  36. #endif /* _SELFTESTS_POWERPC_PMU_EVENT_H */