perfmon.h 4.3 KB

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