On 7/3/2020 3:50 PM, Peter Zijlstra wrote:
On Fri, Jul 03, 2020 at 05:49:19AM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:+static void intel_pmu_store_lbr(struct cpu_hw_events *cpuc,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct lbr_entry *entries)
+{
+ÂÂÂ struct perf_branch_entry *e;
+ÂÂÂ struct lbr_entry *lbr;
+ÂÂÂ u64 from, to, info;
+ÂÂÂ int i;
+
+ÂÂÂ for (i = 0; i < x86_pmu.lbr_nr; i++) {
+ÂÂÂÂÂÂÂ lbr = entries ? &entries[i] : NULL;
+ÂÂÂÂÂÂÂ e = &cpuc->lbr_entries[i];
+
+ÂÂÂÂÂÂÂ from = rdlbr_from(i, lbr);
+ÂÂÂÂÂÂÂ /*
+ÂÂÂÂÂÂÂÂ * Read LBR entries until invalid entry (0s) is detected.
+ÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂÂ if (!from)
+ÂÂÂÂÂÂÂÂÂÂÂ break;
+
+ÂÂÂÂÂÂÂ to = rdlbr_to(i, lbr);
+ÂÂÂÂÂÂÂ info = rdlbr_info(i, lbr);
+
+ÂÂÂÂÂÂÂ e->fromÂÂÂÂÂÂÂ = from;
+ÂÂÂÂÂÂÂ e->toÂÂÂÂÂÂÂ = to;
+ÂÂÂÂÂÂÂ e->mispredÂÂÂ = !!(info & LBR_INFO_MISPRED);
+ÂÂÂÂÂÂÂ e->predictedÂÂÂ = !(info & LBR_INFO_MISPRED);
+ÂÂÂÂÂÂÂ e->in_txÂÂÂ = !!(info & LBR_INFO_IN_TX);
+ÂÂÂÂÂÂÂ e->abortÂÂÂ = !!(info & LBR_INFO_ABORT);
+ÂÂÂÂÂÂÂ e->cyclesÂÂÂ = info & LBR_INFO_CYCLES;
+ÂÂÂÂÂÂÂ e->typeÂÂÂÂÂÂÂ = 0;
+ÂÂÂÂÂÂÂ e->reservedÂÂÂ = 0;
+ÂÂÂ }
+
+ÂÂÂ cpuc->lbr_stack.nr = i;
+}
If I'm not mistaken, this correctly deals with LBR_FORMAT_INFO, so can't
we also use the intel_pmu_arch_lbr_read() function for that case?