blob: f897ec73dc8c9c02943a5c76254140bc951a6024 [file] [log] [blame]
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001/*
2 * Performance event support - s390 specific definitions.
3 *
Hendrik Bruecknerc7168322013-12-11 12:44:40 +01004 * Copyright IBM Corp. 2009, 2013
Hendrik Brueckner212188a2012-03-23 11:13:06 +01005 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Ingo Molnarcdd6c482009-09-21 12:02:48 +02007 */
8
Hendrik Bruecknerc7168322013-12-11 12:44:40 +01009#ifndef _ASM_S390_PERF_EVENT_H
10#define _ASM_S390_PERF_EVENT_H
11
Hendrik Bruecknerc7168322013-12-11 12:44:40 +010012#include <linux/perf_event.h>
13#include <linux/device.h>
Hendrik Brueckner212188a2012-03-23 11:13:06 +010014#include <asm/cpu_mf.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020015
Hendrik Brueckner212188a2012-03-23 11:13:06 +010016/* Per-CPU flags for PMU states */
17#define PMU_F_RESERVED 0x1000
18#define PMU_F_ENABLED 0x2000
Hendrik Brueckner8c069ff2013-12-12 16:32:47 +010019#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 Graalfsb764bb12013-06-12 13:54:56 +020023
Hendrik Bruecknerc7168322013-12-11 12:44:40 +010024/* Perf defintions for PMU event attributes in sysfs */
25extern __init const struct attribute_group **cpumf_cf_event_group(void);
26extern 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 Graalfsb764bb12013-06-12 13:54:56 +020036
37/* Perf callbacks */
38struct pt_regs;
39extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
40extern unsigned long perf_misc_flags(struct pt_regs *regs);
41#define perf_misc_flags(regs) perf_misc_flags(regs)
42
Hendrik Brueckner443e8022013-12-12 17:54:57 +010043/* Perf pt_regs extension for sample-data-entry indicators */
44struct perf_sf_sde_regs {
45 unsigned char in_guest:1; /* guest sample */
46 unsigned long reserved:63; /* reserved */
47};
48
Hendrik Brueckner8c069ff2013-12-12 16:32:47 +010049/* 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 Brueckner7e75fc32013-12-13 11:42:44 +010053#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 Bruecknerd7528862013-12-13 12:45:01 +010060#define PERF_CPUM_SF_FULL_BLOCKS 0x0004 /* Process full SDBs only */
Hendrik Brueckner8c069ff2013-12-12 16:32:47 +010061
Hendrik Brueckner69f239e2013-12-12 17:03:48 +010062#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 Brueckner7e75fc32013-12-13 11:42:44 +010066#define RAWSAMPLE_REG(hwc) ((hwc)->config)
Hendrik Brueckner8c069ff2013-12-12 16:32:47 +010067#define TEAR_REG(hwc) ((hwc)->last_tag)
68#define SAMPL_RATE(hwc) ((hwc)->event_base)
Hendrik Brueckner7e75fc32013-12-13 11:42:44 +010069#define SAMPL_FLAGS(hwc) ((hwc)->config_base)
70#define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE)
Hendrik Bruecknerd7528862013-12-13 12:45:01 +010071#define SDB_FULL_BLOCKS(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FULL_BLOCKS)
Hendrik Brueckner7e75fc32013-12-13 11:42:44 +010072
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 */
77struct 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 Brueckner8c069ff2013-12-12 16:32:47 +010088
Hendrik Bruecknere28bb792013-12-12 16:52:48 +010089/* Perf hardware reserve and release functions */
Sebastian Otta215c8f2015-06-25 14:52:13 +020090#ifdef CONFIG_PERF_EVENTS
Hendrik Bruecknere28bb792013-12-12 16:52:48 +010091int perf_reserve_sampling(void);
92void perf_release_sampling(void);
Sebastian Otta215c8f2015-06-25 14:52:13 +020093#else /* CONFIG_PERF_EVENTS */
94static inline int perf_reserve_sampling(void)
95{
96 return 0;
97}
98static inline void perf_release_sampling(void) {}
99#endif /* CONFIG_PERF_EVENTS */
Hendrik Bruecknere28bb792013-12-12 16:52:48 +0100100
Hendrik Bruecknerc7168322013-12-11 12:44:40 +0100101#endif /* _ASM_S390_PERF_EVENT_H */