perf_event.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Performance event support - s390 specific definitions.
  4. *
  5. * Copyright IBM Corp. 2009, 2017
  6. * Author(s): Martin Schwidefsky <[email protected]>
  7. * Hendrik Brueckner <[email protected]>
  8. */
  9. #ifndef _ASM_S390_PERF_EVENT_H
  10. #define _ASM_S390_PERF_EVENT_H
  11. #include <linux/perf_event.h>
  12. #include <linux/device.h>
  13. #include <asm/stacktrace.h>
  14. /* Per-CPU flags for PMU states */
  15. #define PMU_F_RESERVED 0x1000
  16. #define PMU_F_ENABLED 0x2000
  17. #define PMU_F_IN_USE 0x4000
  18. #define PMU_F_ERR_IBE 0x0100
  19. #define PMU_F_ERR_LSDA 0x0200
  20. #define PMU_F_ERR_MASK (PMU_F_ERR_IBE|PMU_F_ERR_LSDA)
  21. /* Perf definitions for PMU event attributes in sysfs */
  22. extern __init const struct attribute_group **cpumf_cf_event_group(void);
  23. extern ssize_t cpumf_events_sysfs_show(struct device *dev,
  24. struct device_attribute *attr,
  25. char *page);
  26. #define EVENT_VAR(_cat, _name) event_attr_##_cat##_##_name
  27. #define EVENT_PTR(_cat, _name) (&EVENT_VAR(_cat, _name).attr.attr)
  28. #define CPUMF_EVENT_ATTR(cat, name, id) \
  29. PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show)
  30. #define CPUMF_EVENT_PTR(cat, name) EVENT_PTR(cat, name)
  31. /* Perf callbacks */
  32. struct pt_regs;
  33. extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
  34. extern unsigned long perf_misc_flags(struct pt_regs *regs);
  35. #define perf_misc_flags(regs) perf_misc_flags(regs)
  36. #define perf_arch_bpf_user_pt_regs(regs) &regs->user_regs
  37. /* Perf pt_regs extension for sample-data-entry indicators */
  38. struct perf_sf_sde_regs {
  39. unsigned char in_guest:1; /* guest sample */
  40. unsigned long reserved:63; /* reserved */
  41. };
  42. /* Perf PMU definitions for the counter facility */
  43. #define PERF_CPUM_CF_MAX_CTR 0xffffUL /* Max ctr for ECCTR */
  44. /* Perf PMU definitions for the sampling facility */
  45. #define PERF_CPUM_SF_MAX_CTR 2
  46. #define PERF_EVENT_CPUM_SF 0xB0000UL /* Event: Basic-sampling */
  47. #define PERF_EVENT_CPUM_SF_DIAG 0xBD000UL /* Event: Combined-sampling */
  48. #define PERF_EVENT_CPUM_CF_DIAG 0xBC000UL /* Event: Counter sets */
  49. #define PERF_CPUM_SF_BASIC_MODE 0x0001 /* Basic-sampling flag */
  50. #define PERF_CPUM_SF_DIAG_MODE 0x0002 /* Diagnostic-sampling flag */
  51. #define PERF_CPUM_SF_MODE_MASK (PERF_CPUM_SF_BASIC_MODE| \
  52. PERF_CPUM_SF_DIAG_MODE)
  53. #define PERF_CPUM_SF_FULL_BLOCKS 0x0004 /* Process full SDBs only */
  54. #define PERF_CPUM_SF_FREQ_MODE 0x0008 /* Sampling with frequency */
  55. #define REG_NONE 0
  56. #define REG_OVERFLOW 1
  57. #define OVERFLOW_REG(hwc) ((hwc)->extra_reg.config)
  58. #define SFB_ALLOC_REG(hwc) ((hwc)->extra_reg.alloc)
  59. #define TEAR_REG(hwc) ((hwc)->last_tag)
  60. #define SAMPL_RATE(hwc) ((hwc)->event_base)
  61. #define SAMPL_FLAGS(hwc) ((hwc)->config_base)
  62. #define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE)
  63. #define SDB_FULL_BLOCKS(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FULL_BLOCKS)
  64. #define SAMPLE_FREQ_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FREQ_MODE)
  65. #define perf_arch_fetch_caller_regs(regs, __ip) do { \
  66. (regs)->psw.addr = (__ip); \
  67. (regs)->gprs[15] = (unsigned long)__builtin_frame_address(0) - \
  68. offsetof(struct stack_frame, back_chain); \
  69. } while (0)
  70. #endif /* _ASM_S390_PERF_EVENT_H */