Skip to content

Commit 7e75fc3

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
s390/cpum_sf: Add raw data sampling to support the diagnostic-sampling function
Also support the diagnostic-sampling function in addition to the basic-sampling function. Diagnostic-sampling data entries contain hardware model specific sampling data and additional programs are required to analyze the data. To deliver diagnostic-sampling, as well, as basis-sampling data entries to user space, introduce support for sampling "raw data". If this particular perf sampling type (PERF_SAMPLE_RAW) is used, sampling data entries are copied to user space. External programs can then analyze these data. Signed-off-by: Hendrik Brueckner <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent dd127b3 commit 7e75fc3

File tree

5 files changed

+377
-96
lines changed

5 files changed

+377
-96
lines changed

arch/s390/include/asm/cpu_mf.h

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ struct cpumf_ctr_info {
5959
/* QUERY SAMPLING INFORMATION block */
6060
struct hws_qsi_info_block { /* Bit(s) */
6161
unsigned int b0_13:14; /* 0-13: zeros */
62-
unsigned int as:1; /* 14: sampling authorisation control*/
63-
unsigned int b15_21:7; /* 15-21: zeros */
64-
unsigned int es:1; /* 22: sampling enable control */
65-
unsigned int b23_29:7; /* 23-29: zeros */
66-
unsigned int cs:1; /* 30: sampling activation control */
67-
unsigned int:1; /* 31: reserved */
68-
unsigned int bsdes:16; /* 4-5: size of basic sampling entry */
62+
unsigned int as:1; /* 14: basic-sampling authorization */
63+
unsigned int ad:1; /* 15: diag-sampling authorization */
64+
unsigned int b16_21:6; /* 16-21: zeros */
65+
unsigned int es:1; /* 22: basic-sampling enable control */
66+
unsigned int ed:1; /* 23: diag-sampling enable control */
67+
unsigned int b24_29:6; /* 24-29: zeros */
68+
unsigned int cs:1; /* 30: basic-sampling activation control */
69+
unsigned int cd:1; /* 31: diag-sampling activation control */
70+
unsigned int bsdes:16; /* 4-5: size of basic sampling entry */
6971
unsigned int dsdes:16; /* 6-7: size of diagnostic sampling entry */
7072
unsigned long min_sampl_rate; /* 8-15: minimum sampling interval */
7173
unsigned long max_sampl_rate; /* 16-23: maximum sampling interval*/
@@ -82,10 +84,11 @@ struct hws_lsctl_request_block {
8284
unsigned int s:1; /* 0: maximum buffer indicator */
8385
unsigned int h:1; /* 1: part. level reserved for VM use*/
8486
unsigned long long b2_53:52;/* 2-53: zeros */
85-
unsigned int es:1; /* 54: sampling enable control */
86-
unsigned int b55_61:7; /* 55-61: - zeros */
87-
unsigned int cs:1; /* 62: sampling activation control */
88-
unsigned int b63:1; /* 63: zero */
87+
unsigned int es:1; /* 54: basic-sampling enable control */
88+
unsigned int ed:1; /* 55: diag-sampling enable control */
89+
unsigned int b56_61:6; /* 56-61: - zeros */
90+
unsigned int cs:1; /* 62: basic-sampling activation control */
91+
unsigned int cd:1; /* 63: diag-sampling activation control */
8992
unsigned long interval; /* 8-15: sampling interval */
9093
unsigned long tear; /* 16-23: TEAR contents */
9194
unsigned long dear; /* 24-31: DEAR contents */
@@ -96,8 +99,7 @@ struct hws_lsctl_request_block {
9699
unsigned long rsvrd4; /* reserved */
97100
} __packed;
98101

99-
100-
struct hws_data_entry {
102+
struct hws_basic_entry {
101103
unsigned int def:16; /* 0-15 Data Entry Format */
102104
unsigned int R:4; /* 16-19 reserved */
103105
unsigned int U:4; /* 20-23 Number of unique instruct. */
@@ -114,6 +116,18 @@ struct hws_data_entry {
114116
unsigned long long hpp; /* Host Program Parameter */
115117
} __packed;
116118

119+
struct hws_diag_entry {
120+
unsigned int def:16; /* 0-15 Data Entry Format */
121+
unsigned int R:14; /* 16-19 and 20-30 reserved */
122+
unsigned int I:1; /* 31 entry valid or invalid */
123+
u8 data[]; /* Machine-dependent sample data */
124+
} __packed;
125+
126+
struct hws_combined_entry {
127+
struct hws_basic_entry basic; /* Basic-sampling data entry */
128+
struct hws_diag_entry diag; /* Diagnostic-sampling data entry */
129+
} __packed;
130+
117131
struct hws_trailer_entry {
118132
union {
119133
struct {

arch/s390/include/asm/perf_event.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,39 @@ struct perf_sf_sde_regs {
5252
#define PERF_CPUM_CF_MAX_CTR 256
5353

5454
/* Perf PMU definitions for the sampling facility */
55-
#define PERF_CPUM_SF_MAX_CTR 1
56-
#define PERF_EVENT_CPUM_SF 0xB0000UL /* Raw event ID */
55+
#define PERF_CPUM_SF_MAX_CTR 2
56+
#define PERF_EVENT_CPUM_SF 0xB0000UL /* Event: Basic-sampling */
57+
#define PERF_EVENT_CPUM_SF_DIAG 0xBD000UL /* Event: Combined-sampling */
58+
#define PERF_CPUM_SF_BASIC_MODE 0x0001 /* Basic-sampling flag */
59+
#define PERF_CPUM_SF_DIAG_MODE 0x0002 /* Diagnostic-sampling flag */
60+
#define PERF_CPUM_SF_MODE_MASK (PERF_CPUM_SF_BASIC_MODE| \
61+
PERF_CPUM_SF_DIAG_MODE)
5762

5863
#define REG_NONE 0
5964
#define REG_OVERFLOW 1
6065
#define OVERFLOW_REG(hwc) ((hwc)->extra_reg.config)
6166
#define SFB_ALLOC_REG(hwc) ((hwc)->extra_reg.alloc)
67+
#define RAWSAMPLE_REG(hwc) ((hwc)->config)
6268
#define TEAR_REG(hwc) ((hwc)->last_tag)
6369
#define SAMPL_RATE(hwc) ((hwc)->event_base)
70+
#define SAMPL_FLAGS(hwc) ((hwc)->config_base)
71+
#define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE)
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;
6488

6589
/* Perf hardware reserve and release functions */
6690
int perf_reserve_sampling(void);

0 commit comments

Comments
 (0)