Pull perf updates from Thomas Gleixner: "Core: - Allow ftrace to instrument parts of the perf core code - Add a new mem_hops field to perf_mem_data_src which allows to represent intra-node/package or inter-node/off-package details to prepare for next generation systems which have more hieararchy within the node/pacakge level. Tools: - Update for the new mem_hops field in perf_mem_data_src Arch: - A set of constraints fixes for the Intel uncore PMU - The usual set of small fixes and improvements for x86 and PPC" * tag 'perf-core-2021-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Fix ICL/SPR INST_RETIRED.PREC_DIST encodings powerpc/perf: Fix data source encodings for L2.1 and L3.1 accesses tools/perf: Add mem_hops field in perf_mem_data_src structure perf: Add mem_hops field in perf_mem_data_src structure perf: Add comment about current state of PERF_MEM_LVL_* namespace and remove an extra line perf/core: Allow ftrace for functions in kernel/event/core.c perf/x86: Add new event for AUX output counter index perf/x86: Add compiler barrier after updating BTS perf/x86/intel/uncore: Fix Intel SPR M3UPI event constraints perf/x86/intel/uncore: Fix Intel SPR M2PCIE event constraints perf/x86/intel/uncore: Fix Intel SPR IIO event constraints perf/x86/intel/uncore: Fix Intel SPR CHA event constraints perf/x86/intel/uncore: Fix Intel ICX IIO event constraints perf/x86/intel/uncore: Fix invalid unit check perf/x86/intel/uncore: Support extra IMC channel on Ice Lake server
Unified · Split
| @@ -238,11 +238,27 @@ static inline u64 isa207_find_source(u64 idx, u32 sub_idx) · 237 unmodified lines | ||
| 238 | 238 | ret |= P(SNOOP, HIT); |
| 239 | 239 | break; |
| 240 | 240 | case 5: |
| 241 | − ret = PH(LVL, REM_CCE1); | |
| 242 | − if ((sub_idx == 0) || (sub_idx == 2) || (sub_idx == 4)) | |
| 243 | − ret |= P(SNOOP, HIT); | |
| 244 | − else if ((sub_idx == 1) || (sub_idx == 3) || (sub_idx == 5)) | |
| 245 | − ret |= P(SNOOP, HITM); | |
| 241 | + if (cpu_has_feature(CPU_FTR_ARCH_31)) { | |
| 242 | + ret = REM | P(HOPS, 0); | |
| 243 | + | |
| 244 | + if (sub_idx == 0 || sub_idx == 4) | |
| 245 | + ret |= PH(LVL, L2) | LEVEL(L2) | P(SNOOP, HIT); | |
| 246 | + else if (sub_idx == 1 || sub_idx == 5) | |
| 247 | + ret |= PH(LVL, L2) | LEVEL(L2) | P(SNOOP, HITM); | |
| 248 | + else if (sub_idx == 2 || sub_idx == 6) | |
| 249 | + ret |= PH(LVL, L3) | LEVEL(L3) | P(SNOOP, HIT); | |
| 250 | + else if (sub_idx == 3 || sub_idx == 7) | |
| 251 | + ret |= PH(LVL, L3) | LEVEL(L3) | P(SNOOP, HITM); | |
| 252 | + } else { | |
| 253 | + if (sub_idx == 0) | |
| 254 | + ret = PH(LVL, L2) | LEVEL(L2) | REM | P(SNOOP, HIT) | P(HOPS, 0); | |
| 255 | + else if (sub_idx == 1) | |
| 256 | + ret = PH(LVL, L2) | LEVEL(L2) | REM | P(SNOOP, HITM) | P(HOPS, 0); | |
| 257 | + else if (sub_idx == 2 || sub_idx == 4) | |
| 258 | + ret = PH(LVL, L3) | LEVEL(L3) | REM | P(SNOOP, HIT) | P(HOPS, 0); | |
| 259 | + else if (sub_idx == 3 || sub_idx == 5) | |
| 260 | + ret = PH(LVL, L3) | LEVEL(L3) | REM | P(SNOOP, HITM) | P(HOPS, 0); | |
| 261 | + } | |
| 246 | 262 | break; |
| 247 | 263 | case 6: |
| 248 | 264 | ret = PH(LVL, REM_CCE2); |
| @@ -273,6 +273,8 @@ · 272 unmodified lines | ||
| 273 | 273 | #define P(a, b) PERF_MEM_S(a, b) |
| 274 | 274 | #define PH(a, b) (P(LVL, HIT) | P(a, b)) |
| 275 | 275 | #define PM(a, b) (P(LVL, MISS) | P(a, b)) |
| 276 | +#define LEVEL(x) P(LVLNUM, x) | |
| 277 | +#define REM P(REMOTE, REMOTE) | |
| 276 | 278 | |
| 277 | 279 | int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp, u64 event_config1); |
| 278 | 280 | int isa207_compute_mmcr(u64 event[], int n_ev, |
| @@ -66,6 +66,8 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_enable_all, *x86_pmu.enable_all); · 65 unmodified lines | ||
| 66 | 66 | DEFINE_STATIC_CALL_NULL(x86_pmu_enable, *x86_pmu.enable); |
| 67 | 67 | DEFINE_STATIC_CALL_NULL(x86_pmu_disable, *x86_pmu.disable); |
| 68 | 68 | |
| 69 | +DEFINE_STATIC_CALL_NULL(x86_pmu_assign, *x86_pmu.assign); | |
| 70 | + | |
| 69 | 71 | DEFINE_STATIC_CALL_NULL(x86_pmu_add, *x86_pmu.add); |
| 70 | 72 | DEFINE_STATIC_CALL_NULL(x86_pmu_del, *x86_pmu.del); |
| 71 | 73 | DEFINE_STATIC_CALL_NULL(x86_pmu_read, *x86_pmu.read); |
| @@ -1215,6 +1217,8 @@ static inline void x86_assign_hw_event(struct perf_event *event, · 1143 unmodified lines | ||
| 1215 | 1217 | hwc->last_cpu = smp_processor_id(); |
| 1216 | 1218 | hwc->last_tag = ++cpuc->tags[i]; |
| 1217 | 1219 | |
| 1220 | + static_call_cond(x86_pmu_assign)(event, idx); | |
| 1221 | + | |
| 1218 | 1222 | switch (hwc->idx) { |
| 1219 | 1223 | case INTEL_PMC_IDX_FIXED_BTS: |
| 1220 | 1224 | case INTEL_PMC_IDX_FIXED_VLBR: |
| @@ -2005,6 +2009,8 @@ static void x86_pmu_static_call_update(void) · 784 unmodified lines | ||
| 2005 | 2009 | static_call_update(x86_pmu_enable, x86_pmu.enable); |
| 2006 | 2010 | static_call_update(x86_pmu_disable, x86_pmu.disable); |
| 2007 | 2011 | |
| 2012 | + static_call_update(x86_pmu_assign, x86_pmu.assign); | |
| 2013 | + | |
| 2008 | 2014 | static_call_update(x86_pmu_add, x86_pmu.add); |
| 2009 | 2015 | static_call_update(x86_pmu_del, x86_pmu.del); |
| 2010 | 2016 | static_call_update(x86_pmu_read, x86_pmu.read); |
| @@ -209,6 +209,12 @@ static void bts_update(struct bts_ctx *bts) · 208 unmodified lines | ||
| 209 | 209 | } else { |
| 210 | 210 | local_set(&buf->data_size, head); |
| 211 | 211 | } |
| 212 | + | |
| 213 | + /* | |
| 214 | + * Since BTS is coherent, just add compiler barrier to ensure | |
| 215 | + * BTS updating is ordered against bts::handle::event. | |
| 216 | + */ | |
| 217 | + barrier(); | |
| 212 | 218 | } |
| 213 | 219 | |
| 214 | 220 | static int |
| @@ -243,7 +243,8 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = { · 242 unmodified lines | ||
| 243 | 243 | |
| 244 | 244 | static struct event_constraint intel_icl_event_constraints[] = { |
| 245 | 245 | FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ |
| 246 | − FIXED_EVENT_CONSTRAINT(0x01c0, 0), /* INST_RETIRED.PREC_DIST */ | |
| 246 | + FIXED_EVENT_CONSTRAINT(0x01c0, 0), /* old INST_RETIRED.PREC_DIST */ | |
| 247 | + FIXED_EVENT_CONSTRAINT(0x0100, 0), /* INST_RETIRED.PREC_DIST */ | |
| 247 | 248 | FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ |
| 248 | 249 | FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */ |
| 249 | 250 | FIXED_EVENT_CONSTRAINT(0x0400, 3), /* SLOTS */ |
| @@ -288,7 +289,7 @@ static struct extra_reg intel_spr_extra_regs[] __read_mostly = { · 38 unmodified lines | ||
| 288 | 289 | |
| 289 | 290 | static struct event_constraint intel_spr_event_constraints[] = { |
| 290 | 291 | FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ |
| 291 | − FIXED_EVENT_CONSTRAINT(0x01c0, 0), /* INST_RETIRED.PREC_DIST */ | |
| 292 | + FIXED_EVENT_CONSTRAINT(0x0100, 0), /* INST_RETIRED.PREC_DIST */ | |
| 292 | 293 | FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ |
| 293 | 294 | FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */ |
| 294 | 295 | FIXED_EVENT_CONSTRAINT(0x0400, 3), /* SLOTS */ |
| @@ -2403,6 +2404,12 @@ static void intel_pmu_disable_event(struct perf_event *event) · 2108 unmodified lines | ||
| 2403 | 2404 | intel_pmu_pebs_disable(event); |
| 2404 | 2405 | } |
| 2405 | 2406 | |
| 2407 | +static void intel_pmu_assign_event(struct perf_event *event, int idx) | |
| 2408 | +{ | |
| 2409 | + if (is_pebs_pt(event)) | |
| 2410 | + perf_report_aux_output_id(event, idx); | |
| 2411 | +} | |
| 2412 | + | |
| 2406 | 2413 | static void intel_pmu_del_event(struct perf_event *event) |
| 2407 | 2414 | { |
| 2408 | 2415 | if (needs_branch_stack(event)) |
| @@ -4495,8 +4502,16 @@ static int intel_pmu_check_period(struct perf_event *event, u64 value) · 2086 unmodified lines | ||
| 4495 | 4502 | return intel_pmu_has_bts_period(event, value) ? -EINVAL : 0; |
| 4496 | 4503 | } |
| 4497 | 4504 | |
| 4505 | +static void intel_aux_output_init(void) | |
| 4506 | +{ | |
| 4507 | + /* Refer also intel_pmu_aux_output_match() */ | |
| 4508 | + if (x86_pmu.intel_cap.pebs_output_pt_available) | |
| 4509 | + x86_pmu.assign = intel_pmu_assign_event; | |
| 4510 | +} | |
| 4511 | + | |
| 4498 | 4512 | static int intel_pmu_aux_output_match(struct perf_event *event) |
| 4499 | 4513 | { |
| 4514 | + /* intel_pmu_assign_event() is needed, refer intel_aux_output_init() */ | |
| 4500 | 4515 | if (!x86_pmu.intel_cap.pebs_output_pt_available) |
| 4501 | 4516 | return 0; |
| 4502 | 4517 | |
| @@ -6302,6 +6317,8 @@ __init int intel_pmu_init(void) · 1799 unmodified lines | ||
| 6302 | 6317 | if (is_hybrid()) |
| 6303 | 6318 | intel_pmu_check_hybrid_pmus((u64)fixed_mask); |
| 6304 | 6319 | |
| 6320 | + intel_aux_output_init(); | |
| 6321 | + | |
| 6305 | 6322 | return 0; |
| 6306 | 6323 | } |
| 6307 | 6324 | |
| @@ -923,7 +923,8 @@ struct event_constraint intel_skl_pebs_event_constraints[] = { · 922 unmodified lines | ||
| 923 | 923 | }; |
| 924 | 924 | |
| 925 | 925 | struct event_constraint intel_icl_pebs_event_constraints[] = { |
| 926 | − INTEL_FLAGS_UEVENT_CONSTRAINT(0x1c0, 0x100000000ULL), /* INST_RETIRED.PREC_DIST */ | |
| 926 | + INTEL_FLAGS_UEVENT_CONSTRAINT(0x01c0, 0x100000000ULL), /* old INST_RETIRED.PREC_DIST */ | |
| 927 | + INTEL_FLAGS_UEVENT_CONSTRAINT(0x0100, 0x100000000ULL), /* INST_RETIRED.PREC_DIST */ | |
| 927 | 928 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x800000000ULL), /* SLOTS */ |
| 928 | 929 | |
| 929 | 930 | INTEL_PLD_CONSTRAINT(0x1cd, 0xff), /* MEM_TRANS_RETIRED.LOAD_LATENCY */ |
| @@ -943,7 +944,7 @@ struct event_constraint intel_icl_pebs_event_constraints[] = { · 13 unmodified lines | ||
| 943 | 944 | }; |
| 944 | 945 | |
| 945 | 946 | struct event_constraint intel_spr_pebs_event_constraints[] = { |
| 946 | − INTEL_FLAGS_UEVENT_CONSTRAINT(0x1c0, 0x100000000ULL), | |
| 947 | + INTEL_FLAGS_UEVENT_CONSTRAINT(0x100, 0x100000000ULL), /* INST_RETIRED.PREC_DIST */ | |
| 947 | 948 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x800000000ULL), |
| 948 | 949 | |
| 949 | 950 | INTEL_FLAGS_EVENT_CONSTRAINT(0xc0, 0xfe), |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | #define uncore_discovery_invalid_unit(unit) \ |
| 33 | − (!unit.table1 || !unit.ctl || !unit.table3 || \ | |
| 33 | + (!unit.table1 || !unit.ctl || \ | |
| 34 | 34 | unit.table1 == -1ULL || unit.ctl == -1ULL || \ |
| 35 | 35 | unit.table3 == -1ULL) |
| 36 | 36 | |
| @@ -452,7 +452,7 @@ · 451 unmodified lines | ||
| 452 | 452 | #define ICX_M3UPI_PCI_PMON_BOX_CTL 0xa0 |
| 453 | 453 | |
| 454 | 454 | /* ICX IMC */ |
| 455 | −#define ICX_NUMBER_IMC_CHN 2 | |
| 455 | +#define ICX_NUMBER_IMC_CHN 3 | |
| 456 | 456 | #define ICX_IMC_MEM_STRIDE 0x4 |
| 457 | 457 | |
| 458 | 458 | /* SPR */ |
| @@ -5076,8 +5076,10 @@ static struct event_constraint icx_uncore_iio_constraints[] = { · 4617 unmodified lines | ||
| 5076 | 5076 | UNCORE_EVENT_CONSTRAINT(0x02, 0x3), |
| 5077 | 5077 | UNCORE_EVENT_CONSTRAINT(0x03, 0x3), |
| 5078 | 5078 | UNCORE_EVENT_CONSTRAINT(0x83, 0x3), |
| 5079 | + UNCORE_EVENT_CONSTRAINT(0x88, 0xc), | |
| 5079 | 5080 | UNCORE_EVENT_CONSTRAINT(0xc0, 0xc), |
| 5080 | 5081 | UNCORE_EVENT_CONSTRAINT(0xc5, 0xc), |
| 5082 | + UNCORE_EVENT_CONSTRAINT(0xd5, 0xc), | |
| 5081 | 5083 | EVENT_CONSTRAINT_END |
| 5082 | 5084 | }; |
| 5083 | 5085 | |
| @@ -5463,7 +5465,7 @@ static struct intel_uncore_ops icx_uncore_mmio_ops = { · 379 unmodified lines | ||
| 5463 | 5465 | static struct intel_uncore_type icx_uncore_imc = { |
| 5464 | 5466 | .name = "imc", |
| 5465 | 5467 | .num_counters = 4, |
| 5466 | − .num_boxes = 8, | |
| 5468 | + .num_boxes = 12, | |
| 5467 | 5469 | .perf_ctr_bits = 48, |
| 5468 | 5470 | .fixed_ctr_bits = 48, |
| 5469 | 5471 | .fixed_ctr = SNR_IMC_MMIO_PMON_FIXED_CTR, |
| @@ -5647,6 +5649,7 @@ static struct intel_uncore_type spr_uncore_chabox = { · 177 unmodified lines | ||
| 5647 | 5649 | .event_mask = SPR_CHA_PMON_EVENT_MASK, |
| 5648 | 5650 | .event_mask_ext = SPR_RAW_EVENT_MASK_EXT, |
| 5649 | 5651 | .num_shared_regs = 1, |
| 5652 | + .constraints = skx_uncore_chabox_constraints, | |
| 5650 | 5653 | .ops = &spr_uncore_chabox_ops, |
| 5651 | 5654 | .format_group = &spr_uncore_chabox_format_group, |
| 5652 | 5655 | .attr_update = uncore_alias_groups, |
| @@ -5658,6 +5661,7 @@ static struct intel_uncore_type spr_uncore_iio = { · 5 unmodified lines | ||
| 5658 | 5661 | .event_mask_ext = SNR_IIO_PMON_RAW_EVENT_MASK_EXT, |
| 5659 | 5662 | .format_group = &snr_uncore_iio_format_group, |
| 5660 | 5663 | .attr_update = uncore_alias_groups, |
| 5664 | + .constraints = icx_uncore_iio_constraints, | |
| 5661 | 5665 | }; |
| 5662 | 5666 | |
| 5663 | 5667 | static struct attribute *spr_uncore_raw_formats_attr[] = { |
| @@ -5686,9 +5690,16 @@ static struct intel_uncore_type spr_uncore_irp = { · 22 unmodified lines | ||
| 5686 | 5690 | |
| 5687 | 5691 | }; |
| 5688 | 5692 | |
| 5693 | +static struct event_constraint spr_uncore_m2pcie_constraints[] = { | |
| 5694 | + UNCORE_EVENT_CONSTRAINT(0x14, 0x3), | |
| 5695 | + UNCORE_EVENT_CONSTRAINT(0x2d, 0x3), | |
| 5696 | + EVENT_CONSTRAINT_END | |
| 5697 | +}; | |
| 5698 | + | |
| 5689 | 5699 | static struct intel_uncore_type spr_uncore_m2pcie = { |
| 5690 | 5700 | SPR_UNCORE_COMMON_FORMAT(), |
| 5691 | 5701 | .name = "m2pcie", |
| 5702 | + .constraints = spr_uncore_m2pcie_constraints, | |
| 5692 | 5703 | }; |
| 5693 | 5704 | |
| 5694 | 5705 | static struct intel_uncore_type spr_uncore_pcu = { |
| @@ -5765,6 +5776,7 @@ static struct intel_uncore_type spr_uncore_upi = { · 70 unmodified lines | ||
| 5765 | 5776 | static struct intel_uncore_type spr_uncore_m3upi = { |
| 5766 | 5777 | SPR_UNCORE_PCI_COMMON_FORMAT(), |
| 5767 | 5778 | .name = "m3upi", |
| 5779 | + .constraints = icx_uncore_m3upi_constraints, | |
| 5768 | 5780 | }; |
| 5769 | 5781 | |
| 5770 | 5782 | static struct intel_uncore_type spr_uncore_mdf = { |
| @@ -726,6 +726,7 @@ struct x86_pmu { · 725 unmodified lines | ||
| 726 | 726 | void (*enable_all)(int added); |
| 727 | 727 | void (*enable)(struct perf_event *); |
| 728 | 728 | void (*disable)(struct perf_event *); |
| 729 | + void (*assign)(struct perf_event *event, int idx); | |
| 729 | 730 | void (*add)(struct perf_event *); |
| 730 | 731 | void (*del)(struct perf_event *); |
| 731 | 732 | void (*read)(struct perf_event *event); |
| @@ -1400,6 +1400,7 @@ perf_event_addr_filters(struct perf_event *event) · 1399 unmodified lines | ||
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | extern void perf_event_addr_filters_sync(struct perf_event *event); |
| 1403 | +extern void perf_report_aux_output_id(struct perf_event *event, u64 hw_id); | |
| 1403 | 1404 | |
| 1404 | 1405 | extern int perf_output_begin(struct perf_output_handle *handle, |
| 1405 | 1406 | struct perf_sample_data *data, |
| @@ -1141,6 +1141,21 @@ enum perf_event_type { · 1140 unmodified lines | ||
| 1141 | 1141 | */ |
| 1142 | 1142 | PERF_RECORD_TEXT_POKE = 20, |
| 1143 | 1143 | |
| 1144 | + /* | |
| 1145 | + * Data written to the AUX area by hardware due to aux_output, may need | |
| 1146 | + * to be matched to the event by an architecture-specific hardware ID. | |
| 1147 | + * This records the hardware ID, but requires sample_id to provide the | |
| 1148 | + * event ID. e.g. Intel PT uses this record to disambiguate PEBS-via-PT | |
| 1149 | + * records from multiple events. | |
| 1150 | + * | |
| 1151 | + * struct { | |
| 1152 | + * struct perf_event_header header; | |
| 1153 | + * u64 hw_id; | |
| 1154 | + * struct sample_id sample_id; | |
| 1155 | + * }; | |
| 1156 | + */ | |
| 1157 | + PERF_RECORD_AUX_OUTPUT_HW_ID = 21, | |
| 1158 | + | |
| 1144 | 1159 | PERF_RECORD_MAX, /* non-ABI */ |
| 1145 | 1160 | }; |
| 1146 | 1161 | |
| @@ -1210,14 +1225,16 @@ union perf_mem_data_src { · 63 unmodified lines | ||
| 1210 | 1225 | mem_remote:1, /* remote */ |
| 1211 | 1226 | mem_snoopx:2, /* snoop mode, ext */ |
| 1212 | 1227 | mem_blk:3, /* access blocked */ |
| 1213 | − mem_rsvd:21; | |
| 1228 | + mem_hops:3, /* hop level */ | |
| 1229 | + mem_rsvd:18; | |
| 1214 | 1230 | }; |
| 1215 | 1231 | }; |
| 1216 | 1232 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 1217 | 1233 | union perf_mem_data_src { |
| 1218 | 1234 | __u64 val; |
| 1219 | 1235 | struct { |
| 1220 | − __u64 mem_rsvd:21, | |
| 1236 | + __u64 mem_rsvd:18, | |
| 1237 | + mem_hops:3, /* hop level */ | |
| 1221 | 1238 | mem_blk:3, /* access blocked */ |
| 1222 | 1239 | mem_snoopx:2, /* snoop mode, ext */ |
| 1223 | 1240 | mem_remote:1, /* remote */ |
| @@ -1241,7 +1258,13 @@ union perf_mem_data_src { · 17 unmodified lines | ||
| 1241 | 1258 | #define PERF_MEM_OP_EXEC 0x10 /* code (execution) */ |
| 1242 | 1259 | #define PERF_MEM_OP_SHIFT 0 |
| 1243 | 1260 | |
| 1244 | −/* memory hierarchy (memory level, hit or miss) */ | |
| 1261 | +/* | |
| 1262 | + * PERF_MEM_LVL_* namespace being depricated to some extent in the | |
| 1263 | + * favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. | |
| 1264 | + * Supporting this namespace inorder to not break defined ABIs. | |
| 1265 | + * | |
| 1266 | + * memory hierarchy (memory level, hit or miss) | |
| 1267 | + */ | |
| 1245 | 1268 | #define PERF_MEM_LVL_NA 0x01 /* not available */ |
| 1246 | 1269 | #define PERF_MEM_LVL_HIT 0x02 /* hit level */ |
| 1247 | 1270 | #define PERF_MEM_LVL_MISS 0x04 /* miss level */ |
| @@ -1307,6 +1330,11 @@ union perf_mem_data_src { · 59 unmodified lines | ||
| 1307 | 1330 | #define PERF_MEM_BLK_ADDR 0x04 /* address conflict */ |
| 1308 | 1331 | #define PERF_MEM_BLK_SHIFT 40 |
| 1309 | 1332 | |
| 1333 | +/* hop level */ | |
| 1334 | +#define PERF_MEM_HOPS_0 0x01 /* remote core, same node */ | |
| 1335 | +/* 2-7 available */ | |
| 1336 | +#define PERF_MEM_HOPS_SHIFT 43 | |
| 1337 | + | |
| 1310 | 1338 | #define PERF_MEM_S(a, s) \ |
| 1311 | 1339 | (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT) |
| 1312 | 1340 | |
| @@ -1,10 +1,5 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | −ifdef CONFIG_FUNCTION_TRACER | |
| 3 | −CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE) | |
| 4 | −endif | |
| 5 | − | |
| 6 | 2 | obj-y := core.o ring_buffer.o callchain.o |
| 7 | 3 | |
| 8 | 4 | obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o |
| 9 | 5 | obj-$(CONFIG_UPROBES) += uprobes.o |
| 10 | − | |
| @@ -9099,6 +9099,36 @@ static void perf_log_itrace_start(struct perf_event *event) · 9098 unmodified lines | ||
| 9099 | 9099 | perf_output_end(&handle); |
| 9100 | 9100 | } |
| 9101 | 9101 | |
| 9102 | +void perf_report_aux_output_id(struct perf_event *event, u64 hw_id) | |
| 9103 | +{ | |
| 9104 | + struct perf_output_handle handle; | |
| 9105 | + struct perf_sample_data sample; | |
| 9106 | + struct perf_aux_event { | |
| 9107 | + struct perf_event_header header; | |
| 9108 | + u64 hw_id; | |
| 9109 | + } rec; | |
| 9110 | + int ret; | |
| 9111 | + | |
| 9112 | + if (event->parent) | |
| 9113 | + event = event->parent; | |
| 9114 | + | |
| 9115 | + rec.header.type = PERF_RECORD_AUX_OUTPUT_HW_ID; | |
| 9116 | + rec.header.misc = 0; | |
| 9117 | + rec.header.size = sizeof(rec); | |
| 9118 | + rec.hw_id = hw_id; | |
| 9119 | + | |
| 9120 | + perf_event_header__init_id(&rec.header, &sample, event); | |
| 9121 | + ret = perf_output_begin(&handle, &sample, event, rec.header.size); | |
| 9122 | + | |
| 9123 | + if (ret) | |
| 9124 | + return; | |
| 9125 | + | |
| 9126 | + perf_output_put(&handle, rec); | |
| 9127 | + perf_event__output_id_sample(event, &handle, &sample); | |
| 9128 | + | |
| 9129 | + perf_output_end(&handle); | |
| 9130 | +} | |
| 9131 | + | |
| 9102 | 9132 | static int |
| 9103 | 9133 | __perf_event_account_interrupt(struct perf_event *event, int throttle) |
| 9104 | 9134 | { |
| @@ -1210,14 +1210,16 @@ union perf_mem_data_src { · 1209 unmodified lines | ||
| 1210 | 1210 | mem_remote:1, /* remote */ |
| 1211 | 1211 | mem_snoopx:2, /* snoop mode, ext */ |
| 1212 | 1212 | mem_blk:3, /* access blocked */ |
| 1213 | − mem_rsvd:21; | |
| 1213 | + mem_hops:3, /* hop level */ | |
| 1214 | + mem_rsvd:18; | |
| 1214 | 1215 | }; |
| 1215 | 1216 | }; |
| 1216 | 1217 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 1217 | 1218 | union perf_mem_data_src { |
| 1218 | 1219 | __u64 val; |
| 1219 | 1220 | struct { |
| 1220 | − __u64 mem_rsvd:21, | |
| 1221 | + __u64 mem_rsvd:18, | |
| 1222 | + mem_hops:3, /* hop level */ | |
| 1221 | 1223 | mem_blk:3, /* access blocked */ |
| 1222 | 1224 | mem_snoopx:2, /* snoop mode, ext */ |
| 1223 | 1225 | mem_remote:1, /* remote */ |
| @@ -1241,7 +1243,13 @@ union perf_mem_data_src { · 17 unmodified lines | ||
| 1241 | 1243 | #define PERF_MEM_OP_EXEC 0x10 /* code (execution) */ |
| 1242 | 1244 | #define PERF_MEM_OP_SHIFT 0 |
| 1243 | 1245 | |
| 1244 | −/* memory hierarchy (memory level, hit or miss) */ | |
| 1246 | +/* | |
| 1247 | + * PERF_MEM_LVL_* namespace being depricated to some extent in the | |
| 1248 | + * favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. | |
| 1249 | + * Supporting this namespace inorder to not break defined ABIs. | |
| 1250 | + * | |
| 1251 | + * memory hierarchy (memory level, hit or miss) | |
| 1252 | + */ | |
| 1245 | 1253 | #define PERF_MEM_LVL_NA 0x01 /* not available */ |
| 1246 | 1254 | #define PERF_MEM_LVL_HIT 0x02 /* hit level */ |
| 1247 | 1255 | #define PERF_MEM_LVL_MISS 0x04 /* miss level */ |
| @@ -1307,6 +1315,11 @@ union perf_mem_data_src { · 59 unmodified lines | ||
| 1307 | 1315 | #define PERF_MEM_BLK_ADDR 0x04 /* address conflict */ |
| 1308 | 1316 | #define PERF_MEM_BLK_SHIFT 40 |
| 1309 | 1317 | |
| 1318 | +/* hop level */ | |
| 1319 | +#define PERF_MEM_HOPS_0 0x01 /* remote core, same node */ | |
| 1320 | +/* 2-7 available */ | |
| 1321 | +#define PERF_MEM_HOPS_SHIFT 43 | |
| 1322 | + | |
| 1310 | 1323 | #define PERF_MEM_S(a, s) \ |
| 1311 | 1324 | (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT) |
| 1312 | 1325 | |
| @@ -301,6 +301,16 @@ static const char * const mem_lvlnum[] = { · 300 unmodified lines | ||
| 301 | 301 | [PERF_MEM_LVLNUM_NA] = "N/A", |
| 302 | 302 | }; |
| 303 | 303 | |
| 304 | +static const char * const mem_hops[] = { | |
| 305 | + "N/A", | |
| 306 | + /* | |
| 307 | + * While printing, 'Remote' will be added to represent | |
| 308 | + * 'Remote core, same node' accesses as remote field need | |
| 309 | + * to be set with mem_hops field. | |
| 310 | + */ | |
| 311 | + "core, same node", | |
| 312 | +}; | |
| 313 | + | |
| 304 | 314 | int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) |
| 305 | 315 | { |
| 306 | 316 | size_t i, l = 0; |
| @@ -320,12 +330,14 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) · 13 unmodified lines | ||
| 320 | 330 | /* already taken care of */ |
| 321 | 331 | m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS); |
| 322 | 332 | |
| 323 | − | |
| 324 | 333 | if (mem_info && mem_info->data_src.mem_remote) { |
| 325 | 334 | strcat(out, "Remote "); |
| 326 | 335 | l += 7; |
| 327 | 336 | } |
| 328 | 337 | |
| 338 | + if (mem_info && mem_info->data_src.mem_hops) | |
| 339 | + l += scnprintf(out + l, sz - l, "%s ", mem_hops[mem_info->data_src.mem_hops]); | |
| 340 | + | |
| 329 | 341 | printed = 0; |
| 330 | 342 | for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) { |
| 331 | 343 | if (!(m & 0x1)) |
| @@ -472,8 +484,12 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi) · 140 unmodified lines | ||
| 472 | 484 | /* |
| 473 | 485 | * Skylake might report unknown remote level via this |
| 474 | 486 | * bit, consider it when evaluating remote HITMs. |
| 487 | + * | |
| 488 | + * Incase of power, remote field can also be used to denote cache | |
| 489 | + * accesses from the another core of same node. Hence, setting | |
| 490 | + * mrem only when HOPS is zero along with set remote field. | |
| 475 | 491 | */ |
| 476 | − bool mrem = data_src->mem_remote; | |
| 492 | + bool mrem = (data_src->mem_remote && !data_src->mem_hops); | |
| 477 | 493 | int err = 0; |
| 478 | 494 | |
| 479 | 495 | #define HITM_INC(__f) \ |