Commit a9a931e2 authored by Kan Liang's avatar Kan Liang Committed by Peter Zijlstra
Browse files

perf: Use sample_flags for branch stack



Use the new sample_flags to indicate whether the branch stack is filled
by the PMU driver.

Remove the br_stack from the perf_sample_data_init() to minimize the number
of cache lines touched.

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220901130959.1285717-4-kan.liang@linux.intel.com
parent 47a3aeb3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2297,6 +2297,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
			cpuhw = this_cpu_ptr(&cpu_hw_events);
			power_pmu_bhrb_read(event, cpuhw);
			data.br_stack = &cpuhw->bhrb_stack;
			data.sample_flags |= PERF_SAMPLE_BRANCH_STACK;
		}

		if (event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
+3 −1
Original line number Diff line number Diff line
@@ -929,8 +929,10 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
		if (!x86_perf_event_set_period(event))
			continue;

		if (has_branch_stack(event))
		if (has_branch_stack(event)) {
			data.br_stack = &cpuc->lbr_stack;
			data.sample_flags |= PERF_SAMPLE_BRANCH_STACK;
		}

		if (perf_event_overflow(event, &data, regs))
			x86_pmu_stop(event, 0);
+3 −1
Original line number Diff line number Diff line
@@ -1714,8 +1714,10 @@ int x86_pmu_handle_irq(struct pt_regs *regs)

		perf_sample_data_init(&data, 0, event->hw.last_period);

		if (has_branch_stack(event))
		if (has_branch_stack(event)) {
			data.br_stack = &cpuc->lbr_stack;
			data.sample_flags |= PERF_SAMPLE_BRANCH_STACK;
		}

		if (perf_event_overflow(event, &data, regs))
			x86_pmu_stop(event, 0);
+3 −1
Original line number Diff line number Diff line
@@ -2995,8 +2995,10 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)

		perf_sample_data_init(&data, 0, event->hw.last_period);

		if (has_branch_stack(event))
		if (has_branch_stack(event)) {
			data.br_stack = &cpuc->lbr_stack;
			data.sample_flags |= PERF_SAMPLE_BRANCH_STACK;
		}

		if (perf_event_overflow(event, &data, regs))
			x86_pmu_stop(event, 0);
+4 −1
Original line number Diff line number Diff line
@@ -1640,8 +1640,10 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,
		data->sample_flags |= PERF_SAMPLE_TIME;
	}

	if (has_branch_stack(event))
	if (has_branch_stack(event)) {
		data->br_stack = &cpuc->lbr_stack;
		data->sample_flags |= PERF_SAMPLE_BRANCH_STACK;
	}
}

static void adaptive_pebs_save_regs(struct pt_regs *regs,
@@ -1791,6 +1793,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
		if (has_branch_stack(event)) {
			intel_pmu_store_pebs_lbrs(lbr);
			data->br_stack = &cpuc->lbr_stack;
			data->sample_flags |= PERF_SAMPLE_BRANCH_STACK;
		}
	}

Loading