cpupower-monitor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
  3. *
  4. * Licensed under the terms of the GNU GPL License version 2.
  5. *
  6. */
  7. #ifndef __CPUIDLE_INFO_HW__
  8. #define __CPUIDLE_INFO_HW__
  9. #include <stdarg.h>
  10. #include <time.h>
  11. #include "idle_monitor/idle_monitors.h"
  12. #define MONITORS_MAX 20
  13. #define MONITOR_NAME_LEN 20
  14. #define CSTATE_NAME_LEN 5
  15. #define CSTATE_DESC_LEN 60
  16. int cpu_count;
  17. /* Hard to define the right names ...: */
  18. enum power_range_e {
  19. RANGE_THREAD, /* Lowest in topology hierarcy, AMD: core, Intel: thread
  20. kernel sysfs: cpu */
  21. RANGE_CORE, /* AMD: unit, Intel: core, kernel_sysfs: core_id */
  22. RANGE_PACKAGE, /* Package, processor socket */
  23. RANGE_MACHINE, /* Machine, platform wide */
  24. RANGE_MAX };
  25. typedef struct cstate {
  26. int id;
  27. enum power_range_e range;
  28. char name[CSTATE_NAME_LEN];
  29. char desc[CSTATE_DESC_LEN];
  30. /* either provide a percentage or a general count */
  31. int (*get_count_percent)(unsigned int self_id, double *percent,
  32. unsigned int cpu);
  33. int (*get_count)(unsigned int self_id, unsigned long long *count,
  34. unsigned int cpu);
  35. } cstate_t;
  36. struct cpuidle_monitor {
  37. /* Name must not contain whitespaces */
  38. char name[MONITOR_NAME_LEN];
  39. int name_len;
  40. int hw_states_num;
  41. cstate_t *hw_states;
  42. int (*start) (void);
  43. int (*stop) (void);
  44. struct cpuidle_monitor* (*do_register) (void);
  45. void (*unregister)(void);
  46. unsigned int overflow_s;
  47. int needs_root;
  48. };
  49. extern long long timespec_diff_us(struct timespec start, struct timespec end);
  50. #define print_overflow_err(mes, ov) \
  51. { \
  52. fprintf(stderr, gettext("Measure took %u seconds, but registers could " \
  53. "overflow at %u seconds, results " \
  54. "could be inaccurate\n"), mes, ov); \
  55. }
  56. #endif /* __CPUIDLE_INFO_HW__ */