perf_counter.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _ASM_X86_PERF_COUNTER_H
  2. #define _ASM_X86_PERF_COUNTER_H
  3. /*
  4. * Performance counter hw details:
  5. */
  6. #define X86_PMC_MAX_GENERIC 8
  7. #define X86_PMC_MAX_FIXED 3
  8. #define MSR_ARCH_PERFMON_PERFCTR0 0xc1
  9. #define MSR_ARCH_PERFMON_PERFCTR1 0xc2
  10. #define MSR_ARCH_PERFMON_EVENTSEL0 0x186
  11. #define MSR_ARCH_PERFMON_EVENTSEL1 0x187
  12. #define ARCH_PERFMON_EVENTSEL0_ENABLE (1 << 22)
  13. #define ARCH_PERFMON_EVENTSEL_INT (1 << 20)
  14. #define ARCH_PERFMON_EVENTSEL_OS (1 << 17)
  15. #define ARCH_PERFMON_EVENTSEL_USR (1 << 16)
  16. #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c
  17. #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
  18. #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX 0
  19. #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \
  20. (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX))
  21. #define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6
  22. /*
  23. * Intel "Architectural Performance Monitoring" CPUID
  24. * detection/enumeration details:
  25. */
  26. union cpuid10_eax {
  27. struct {
  28. unsigned int version_id:8;
  29. unsigned int num_counters:8;
  30. unsigned int bit_width:8;
  31. unsigned int mask_length:8;
  32. } split;
  33. unsigned int full;
  34. };
  35. union cpuid10_edx {
  36. struct {
  37. unsigned int num_counters_fixed:4;
  38. unsigned int reserved:28;
  39. } split;
  40. unsigned int full;
  41. };
  42. /*
  43. * Fixed-purpose performance counters:
  44. */
  45. /* Instr_Retired.Any: */
  46. #define MSR_ARCH_PERFMON_FIXED_CTR0 0x309
  47. /* CPU_CLK_Unhalted.Core: */
  48. #define MSR_ARCH_PERFMON_FIXED_CTR1 0x30a
  49. /* CPU_CLK_Unhalted.Ref: */
  50. #define MSR_ARCH_PERFMON_FIXED_CTR2 0x30b
  51. #ifdef CONFIG_PERF_COUNTERS
  52. extern void init_hw_perf_counters(void);
  53. extern void perf_counters_lapic_init(int nmi);
  54. #else
  55. static inline void init_hw_perf_counters(void) { }
  56. static inline void perf_counters_lapic_init(int nmi) { }
  57. #endif
  58. #endif /* _ASM_X86_PERF_COUNTER_H */