Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Performance event support - s390 specific definitions. |
| 3 | * |
Hendrik Brueckner | c716832 | 2013-12-11 12:44:40 +0100 | [diff] [blame] | 4 | * Copyright IBM Corp. 2009, 2013 |
Hendrik Brueckner | 212188a | 2012-03-23 11:13:06 +0100 | [diff] [blame] | 5 | * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 6 | * Hendrik Brueckner <brueckner@linux.vnet.ibm.com> |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
Hendrik Brueckner | c716832 | 2013-12-11 12:44:40 +0100 | [diff] [blame] | 9 | #ifndef _ASM_S390_PERF_EVENT_H |
| 10 | #define _ASM_S390_PERF_EVENT_H |
| 11 | |
Hendrik Brueckner | c716832 | 2013-12-11 12:44:40 +0100 | [diff] [blame] | 12 | #include <linux/perf_event.h> |
| 13 | #include <linux/device.h> |
Hendrik Brueckner | 212188a | 2012-03-23 11:13:06 +0100 | [diff] [blame] | 14 | #include <asm/cpu_mf.h> |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 15 | |
Hendrik Brueckner | 212188a | 2012-03-23 11:13:06 +0100 | [diff] [blame] | 16 | /* Per-CPU flags for PMU states */ |
| 17 | #define PMU_F_RESERVED 0x1000 |
| 18 | #define PMU_F_ENABLED 0x2000 |
Hendrik Brueckner | 8c069ff | 2013-12-12 16:32:47 +0100 | [diff] [blame] | 19 | #define PMU_F_IN_USE 0x4000 |
| 20 | #define PMU_F_ERR_IBE 0x0100 |
| 21 | #define PMU_F_ERR_LSDA 0x0200 |
| 22 | #define PMU_F_ERR_MASK (PMU_F_ERR_IBE|PMU_F_ERR_LSDA) |
Heinz Graalfs | b764bb1 | 2013-06-12 13:54:56 +0200 | [diff] [blame] | 23 | |
Hendrik Brueckner | c716832 | 2013-12-11 12:44:40 +0100 | [diff] [blame] | 24 | /* Perf defintions for PMU event attributes in sysfs */ |
| 25 | extern __init const struct attribute_group **cpumf_cf_event_group(void); |
| 26 | extern ssize_t cpumf_events_sysfs_show(struct device *dev, |
| 27 | struct device_attribute *attr, |
| 28 | char *page); |
| 29 | #define EVENT_VAR(_cat, _name) event_attr_##_cat##_##_name |
| 30 | #define EVENT_PTR(_cat, _name) (&EVENT_VAR(_cat, _name).attr.attr) |
| 31 | |
| 32 | #define CPUMF_EVENT_ATTR(cat, name, id) \ |
| 33 | PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show) |
| 34 | #define CPUMF_EVENT_PTR(cat, name) EVENT_PTR(cat, name) |
| 35 | |
Heinz Graalfs | b764bb1 | 2013-06-12 13:54:56 +0200 | [diff] [blame] | 36 | |
| 37 | /* Perf callbacks */ |
| 38 | struct pt_regs; |
| 39 | extern unsigned long perf_instruction_pointer(struct pt_regs *regs); |
| 40 | extern unsigned long perf_misc_flags(struct pt_regs *regs); |
| 41 | #define perf_misc_flags(regs) perf_misc_flags(regs) |
| 42 | |
Hendrik Brueckner | 443e802 | 2013-12-12 17:54:57 +0100 | [diff] [blame] | 43 | /* Perf pt_regs extension for sample-data-entry indicators */ |
| 44 | struct perf_sf_sde_regs { |
| 45 | unsigned char in_guest:1; /* guest sample */ |
| 46 | unsigned long reserved:63; /* reserved */ |
| 47 | }; |
| 48 | |
Hendrik Brueckner | 8c069ff | 2013-12-12 16:32:47 +0100 | [diff] [blame] | 49 | /* Perf PMU definitions for the counter facility */ |
| 50 | #define PERF_CPUM_CF_MAX_CTR 256 |
| 51 | |
| 52 | /* Perf PMU definitions for the sampling facility */ |
Hendrik Brueckner | 7e75fc3 | 2013-12-13 11:42:44 +0100 | [diff] [blame] | 53 | #define PERF_CPUM_SF_MAX_CTR 2 |
| 54 | #define PERF_EVENT_CPUM_SF 0xB0000UL /* Event: Basic-sampling */ |
| 55 | #define PERF_EVENT_CPUM_SF_DIAG 0xBD000UL /* Event: Combined-sampling */ |
| 56 | #define PERF_CPUM_SF_BASIC_MODE 0x0001 /* Basic-sampling flag */ |
| 57 | #define PERF_CPUM_SF_DIAG_MODE 0x0002 /* Diagnostic-sampling flag */ |
| 58 | #define PERF_CPUM_SF_MODE_MASK (PERF_CPUM_SF_BASIC_MODE| \ |
| 59 | PERF_CPUM_SF_DIAG_MODE) |
Hendrik Brueckner | d752886 | 2013-12-13 12:45:01 +0100 | [diff] [blame] | 60 | #define PERF_CPUM_SF_FULL_BLOCKS 0x0004 /* Process full SDBs only */ |
Hendrik Brueckner | 8c069ff | 2013-12-12 16:32:47 +0100 | [diff] [blame] | 61 | |
Hendrik Brueckner | 69f239e | 2013-12-12 17:03:48 +0100 | [diff] [blame] | 62 | #define REG_NONE 0 |
| 63 | #define REG_OVERFLOW 1 |
| 64 | #define OVERFLOW_REG(hwc) ((hwc)->extra_reg.config) |
| 65 | #define SFB_ALLOC_REG(hwc) ((hwc)->extra_reg.alloc) |
Hendrik Brueckner | 7e75fc3 | 2013-12-13 11:42:44 +0100 | [diff] [blame] | 66 | #define RAWSAMPLE_REG(hwc) ((hwc)->config) |
Hendrik Brueckner | 8c069ff | 2013-12-12 16:32:47 +0100 | [diff] [blame] | 67 | #define TEAR_REG(hwc) ((hwc)->last_tag) |
| 68 | #define SAMPL_RATE(hwc) ((hwc)->event_base) |
Hendrik Brueckner | 7e75fc3 | 2013-12-13 11:42:44 +0100 | [diff] [blame] | 69 | #define SAMPL_FLAGS(hwc) ((hwc)->config_base) |
| 70 | #define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE) |
Hendrik Brueckner | d752886 | 2013-12-13 12:45:01 +0100 | [diff] [blame] | 71 | #define SDB_FULL_BLOCKS(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FULL_BLOCKS) |
Hendrik Brueckner | 7e75fc3 | 2013-12-13 11:42:44 +0100 | [diff] [blame] | 72 | |
| 73 | /* Structure for sampling data entries to be passed as perf raw sample data |
| 74 | * to user space. Note that raw sample data must be aligned and, thus, might |
| 75 | * be padded with zeros. |
| 76 | */ |
| 77 | struct sf_raw_sample { |
| 78 | #define SF_RAW_SAMPLE_BASIC PERF_CPUM_SF_BASIC_MODE |
| 79 | #define SF_RAW_SAMPLE_DIAG PERF_CPUM_SF_DIAG_MODE |
| 80 | u64 format; |
| 81 | u32 size; /* Size of sf_raw_sample */ |
| 82 | u16 bsdes; /* Basic-sampling data entry size */ |
| 83 | u16 dsdes; /* Diagnostic-sampling data entry size */ |
| 84 | struct hws_basic_entry basic; /* Basic-sampling data entry */ |
| 85 | struct hws_diag_entry diag; /* Diagnostic-sampling data entry */ |
| 86 | u8 padding[]; /* Padding to next multiple of 8 */ |
| 87 | } __packed; |
Hendrik Brueckner | 8c069ff | 2013-12-12 16:32:47 +0100 | [diff] [blame] | 88 | |
Hendrik Brueckner | e28bb79 | 2013-12-12 16:52:48 +0100 | [diff] [blame] | 89 | /* Perf hardware reserve and release functions */ |
Sebastian Ott | a215c8f | 2015-06-25 14:52:13 +0200 | [diff] [blame] | 90 | #ifdef CONFIG_PERF_EVENTS |
Hendrik Brueckner | e28bb79 | 2013-12-12 16:52:48 +0100 | [diff] [blame] | 91 | int perf_reserve_sampling(void); |
| 92 | void perf_release_sampling(void); |
Sebastian Ott | a215c8f | 2015-06-25 14:52:13 +0200 | [diff] [blame] | 93 | #else /* CONFIG_PERF_EVENTS */ |
| 94 | static inline int perf_reserve_sampling(void) |
| 95 | { |
| 96 | return 0; |
| 97 | } |
| 98 | static inline void perf_release_sampling(void) {} |
| 99 | #endif /* CONFIG_PERF_EVENTS */ |
Hendrik Brueckner | e28bb79 | 2013-12-12 16:52:48 +0100 | [diff] [blame] | 100 | |
Hendrik Brueckner | c716832 | 2013-12-11 12:44:40 +0100 | [diff] [blame] | 101 | #endif /* _ASM_S390_PERF_EVENT_H */ |