op_x86_model.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * @file op_x86_model.h
  3. * interface to x86 model-specific MSR operations
  4. *
  5. * @remark Copyright 2002 OProfile authors
  6. * @remark Read the file COPYING
  7. *
  8. * @author Graydon Hoare
  9. * @author Robert Richter <robert.richter@amd.com>
  10. */
  11. #ifndef OP_X86_MODEL_H
  12. #define OP_X86_MODEL_H
  13. #include <asm/types.h>
  14. #include <asm/perf_event.h>
  15. struct op_msr {
  16. unsigned long addr;
  17. u64 saved;
  18. };
  19. struct op_msrs {
  20. struct op_msr *counters;
  21. struct op_msr *controls;
  22. struct op_msr *multiplex;
  23. };
  24. struct pt_regs;
  25. struct oprofile_operations;
  26. /* The model vtable abstracts the differences between
  27. * various x86 CPU models' perfctr support.
  28. */
  29. struct op_x86_model_spec {
  30. unsigned int num_counters;
  31. unsigned int num_controls;
  32. unsigned int num_virt_counters;
  33. u64 reserved;
  34. u16 event_mask;
  35. int (*init)(struct oprofile_operations *ops);
  36. int (*fill_in_addresses)(struct op_msrs * const msrs);
  37. void (*setup_ctrs)(struct op_x86_model_spec const *model,
  38. struct op_msrs const * const msrs);
  39. void (*cpu_down)(void);
  40. int (*check_ctrs)(struct pt_regs * const regs,
  41. struct op_msrs const * const msrs);
  42. void (*start)(struct op_msrs const * const msrs);
  43. void (*stop)(struct op_msrs const * const msrs);
  44. void (*shutdown)(struct op_msrs const * const msrs);
  45. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  46. void (*switch_ctrl)(struct op_x86_model_spec const *model,
  47. struct op_msrs const * const msrs);
  48. #endif
  49. };
  50. struct op_counter_config;
  51. static inline void op_x86_warn_in_use(int counter)
  52. {
  53. /*
  54. * The warning indicates an already running counter. If
  55. * oprofile doesn't collect data, then try using a different
  56. * performance counter on your platform to monitor the desired
  57. * event. Delete counter #%d from the desired event by editing
  58. * the /usr/share/oprofile/%s/<cpu>/events file. If the event
  59. * cannot be monitored by any other counter, contact your
  60. * hardware or BIOS vendor.
  61. */
  62. pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
  63. counter, smp_processor_id());
  64. }
  65. static inline void op_x86_warn_reserved(int counter)
  66. {
  67. pr_warning("oprofile: counter #%d is already reserved\n", counter);
  68. }
  69. extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
  70. struct op_counter_config *counter_config);
  71. extern int op_x86_phys_to_virt(int phys);
  72. extern int op_x86_virt_to_phys(int virt);
  73. extern struct op_x86_model_spec op_ppro_spec;
  74. extern struct op_x86_model_spec op_p4_spec;
  75. extern struct op_x86_model_spec op_p4_ht2_spec;
  76. extern struct op_x86_model_spec op_amd_spec;
  77. extern struct op_x86_model_spec op_arch_perfmon_spec;
  78. #endif /* OP_X86_MODEL_H */