@@ -1125,52 +1125,64 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
1125
1125
return 0 ;
1126
1126
}
1127
1127
1128
- static inline u64 intel_hsw_weight ( struct pebs_record_skl * pebs )
1128
+ static inline u64 intel_get_tsx_weight ( u64 tsx_tuning )
1129
1129
{
1130
- if (pebs -> tsx_tuning ) {
1131
- union hsw_tsx_tuning tsx = { .value = pebs -> tsx_tuning };
1130
+ if (tsx_tuning ) {
1131
+ union hsw_tsx_tuning tsx = { .value = tsx_tuning };
1132
1132
return tsx .cycles_last_block ;
1133
1133
}
1134
1134
return 0 ;
1135
1135
}
1136
1136
1137
- static inline u64 intel_hsw_transaction ( struct pebs_record_skl * pebs )
1137
+ static inline u64 intel_get_tsx_transaction ( u64 tsx_tuning , u64 ax )
1138
1138
{
1139
- u64 txn = (pebs -> tsx_tuning & PEBS_HSW_TSX_FLAGS ) >> 32 ;
1139
+ u64 txn = (tsx_tuning & PEBS_HSW_TSX_FLAGS ) >> 32 ;
1140
1140
1141
1141
/* For RTM XABORTs also log the abort code from AX */
1142
- if ((txn & PERF_TXN_TRANSACTION ) && (pebs -> ax & 1 ))
1143
- txn |= ((pebs -> ax >> 24 ) & 0xff ) << PERF_TXN_ABORT_SHIFT ;
1142
+ if ((txn & PERF_TXN_TRANSACTION ) && (ax & 1 ))
1143
+ txn |= ((ax >> 24 ) & 0xff ) << PERF_TXN_ABORT_SHIFT ;
1144
1144
return txn ;
1145
1145
}
1146
1146
1147
+ #define PERF_X86_EVENT_PEBS_HSW_PREC \
1148
+ (PERF_X86_EVENT_PEBS_ST_HSW | \
1149
+ PERF_X86_EVENT_PEBS_LD_HSW | \
1150
+ PERF_X86_EVENT_PEBS_NA_HSW)
1151
+
1152
+ static u64 get_data_src (struct perf_event * event , u64 aux )
1153
+ {
1154
+ u64 val = PERF_MEM_NA ;
1155
+ int fl = event -> hw .flags ;
1156
+ bool fst = fl & (PERF_X86_EVENT_PEBS_ST | PERF_X86_EVENT_PEBS_HSW_PREC );
1157
+
1158
+ if (fl & PERF_X86_EVENT_PEBS_LDLAT )
1159
+ val = load_latency_data (aux );
1160
+ else if (fst && (fl & PERF_X86_EVENT_PEBS_HSW_PREC ))
1161
+ val = precise_datala_hsw (event , aux );
1162
+ else if (fst )
1163
+ val = precise_store_data (aux );
1164
+ return val ;
1165
+ }
1166
+
1147
1167
static void setup_pebs_sample_data (struct perf_event * event ,
1148
1168
struct pt_regs * iregs , void * __pebs ,
1149
1169
struct perf_sample_data * data ,
1150
1170
struct pt_regs * regs )
1151
1171
{
1152
- #define PERF_X86_EVENT_PEBS_HSW_PREC \
1153
- (PERF_X86_EVENT_PEBS_ST_HSW | \
1154
- PERF_X86_EVENT_PEBS_LD_HSW | \
1155
- PERF_X86_EVENT_PEBS_NA_HSW)
1156
1172
/*
1157
1173
* We cast to the biggest pebs_record but are careful not to
1158
1174
* unconditionally access the 'extra' entries.
1159
1175
*/
1160
1176
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
1161
1177
struct pebs_record_skl * pebs = __pebs ;
1162
1178
u64 sample_type ;
1163
- int fll , fst , dsrc ;
1164
- int fl = event -> hw .flags ;
1179
+ int fll ;
1165
1180
1166
1181
if (pebs == NULL )
1167
1182
return ;
1168
1183
1169
1184
sample_type = event -> attr .sample_type ;
1170
- dsrc = sample_type & PERF_SAMPLE_DATA_SRC ;
1171
-
1172
- fll = fl & PERF_X86_EVENT_PEBS_LDLAT ;
1173
- fst = fl & (PERF_X86_EVENT_PEBS_ST | PERF_X86_EVENT_PEBS_HSW_PREC );
1185
+ fll = event -> hw .flags & PERF_X86_EVENT_PEBS_LDLAT ;
1174
1186
1175
1187
perf_sample_data_init (data , 0 , event -> hw .last_period );
1176
1188
@@ -1185,16 +1197,8 @@ static void setup_pebs_sample_data(struct perf_event *event,
1185
1197
/*
1186
1198
* data.data_src encodes the data source
1187
1199
*/
1188
- if (dsrc ) {
1189
- u64 val = PERF_MEM_NA ;
1190
- if (fll )
1191
- val = load_latency_data (pebs -> dse );
1192
- else if (fst && (fl & PERF_X86_EVENT_PEBS_HSW_PREC ))
1193
- val = precise_datala_hsw (event , pebs -> dse );
1194
- else if (fst )
1195
- val = precise_store_data (pebs -> dse );
1196
- data -> data_src .val = val ;
1197
- }
1200
+ if (sample_type & PERF_SAMPLE_DATA_SRC )
1201
+ data -> data_src .val = get_data_src (event , pebs -> dse );
1198
1202
1199
1203
/*
1200
1204
* We must however always use iregs for the unwinder to stay sane; the
@@ -1281,10 +1285,11 @@ static void setup_pebs_sample_data(struct perf_event *event,
1281
1285
if (x86_pmu .intel_cap .pebs_format >= 2 ) {
1282
1286
/* Only set the TSX weight when no memory weight. */
1283
1287
if ((sample_type & PERF_SAMPLE_WEIGHT ) && !fll )
1284
- data -> weight = intel_hsw_weight (pebs );
1288
+ data -> weight = intel_get_tsx_weight (pebs -> tsx_tuning );
1285
1289
1286
1290
if (sample_type & PERF_SAMPLE_TRANSACTION )
1287
- data -> txn = intel_hsw_transaction (pebs );
1291
+ data -> txn = intel_get_tsx_transaction (pebs -> tsx_tuning ,
1292
+ pebs -> ax );
1288
1293
}
1289
1294
1290
1295
/*
0 commit comments