perfmon.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2001-2003 Hewlett-Packard Co
  3. * Stephane Eranian <eranian@hpl.hp.com>
  4. */
  5. #ifndef _ASM_IA64_PERFMON_H
  6. #define _ASM_IA64_PERFMON_H
  7. #include <uapi/asm/perfmon.h>
  8. extern long perfmonctl(int fd, int cmd, void *arg, int narg);
  9. typedef struct {
  10. void (*handler)(int irq, void *arg, struct pt_regs *regs);
  11. } pfm_intr_handler_desc_t;
  12. extern void pfm_save_regs (struct task_struct *);
  13. extern void pfm_load_regs (struct task_struct *);
  14. extern void pfm_exit_thread(struct task_struct *);
  15. extern int pfm_use_debug_registers(struct task_struct *);
  16. extern int pfm_release_debug_registers(struct task_struct *);
  17. extern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, int is_ctxswin);
  18. extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs);
  19. extern void pfm_init_percpu(void);
  20. extern void pfm_handle_work(void);
  21. extern int pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
  22. extern int pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
  23. /*
  24. * Reset PMD register flags
  25. */
  26. #define PFM_PMD_SHORT_RESET 0
  27. #define PFM_PMD_LONG_RESET 1
  28. typedef union {
  29. unsigned int val;
  30. struct {
  31. unsigned int notify_user:1; /* notify user program of overflow */
  32. unsigned int reset_ovfl_pmds:1; /* reset overflowed PMDs */
  33. unsigned int block_task:1; /* block monitored task on kernel exit */
  34. unsigned int mask_monitoring:1; /* mask monitors via PMCx.plm */
  35. unsigned int reserved:28; /* for future use */
  36. } bits;
  37. } pfm_ovfl_ctrl_t;
  38. typedef struct {
  39. unsigned char ovfl_pmd; /* index of overflowed PMD */
  40. unsigned char ovfl_notify; /* =1 if monitor requested overflow notification */
  41. unsigned short active_set; /* event set active at the time of the overflow */
  42. pfm_ovfl_ctrl_t ovfl_ctrl; /* return: perfmon controls to set by handler */
  43. unsigned long pmd_last_reset; /* last reset value of of the PMD */
  44. unsigned long smpl_pmds[4]; /* bitmask of other PMD of interest on overflow */
  45. unsigned long smpl_pmds_values[PMU_MAX_PMDS]; /* values for the other PMDs of interest */
  46. unsigned long pmd_value; /* current 64-bit value of the PMD */
  47. unsigned long pmd_eventid; /* eventid associated with PMD */
  48. } pfm_ovfl_arg_t;
  49. typedef struct {
  50. char *fmt_name;
  51. pfm_uuid_t fmt_uuid;
  52. size_t fmt_arg_size;
  53. unsigned long fmt_flags;
  54. int (*fmt_validate)(struct task_struct *task, unsigned int flags, int cpu, void *arg);
  55. int (*fmt_getsize)(struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size);
  56. int (*fmt_init)(struct task_struct *task, void *buf, unsigned int flags, int cpu, void *arg);
  57. int (*fmt_handler)(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct pt_regs *regs, unsigned long stamp);
  58. int (*fmt_restart)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
  59. int (*fmt_restart_active)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
  60. int (*fmt_exit)(struct task_struct *task, void *buf, struct pt_regs *regs);
  61. struct list_head fmt_list;
  62. } pfm_buffer_fmt_t;
  63. extern int pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt);
  64. extern int pfm_unregister_buffer_fmt(pfm_uuid_t uuid);
  65. /*
  66. * perfmon interface exported to modules
  67. */
  68. extern int pfm_mod_read_pmds(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
  69. extern int pfm_mod_write_pmcs(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
  70. extern int pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
  71. extern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
  72. /*
  73. * describe the content of the local_cpu_date->pfm_syst_info field
  74. */
  75. #define PFM_CPUINFO_SYST_WIDE 0x1 /* if set a system wide session exists */
  76. #define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */
  77. #define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */
  78. /*
  79. * sysctl control structure. visible to sampling formats
  80. */
  81. typedef struct {
  82. int debug; /* turn on/off debugging via syslog */
  83. int debug_ovfl; /* turn on/off debug printk in overflow handler */
  84. int fastctxsw; /* turn on/off fast (unsecure) ctxsw */
  85. int expert_mode; /* turn on/off value checking */
  86. } pfm_sysctl_t;
  87. extern pfm_sysctl_t pfm_sysctl;
  88. #endif /* _ASM_IA64_PERFMON_H */