Re: [PATCH v2 03/13] perf/x86/amd: add AMD Fam19h Branch Sampling support

From: Peter Zijlstra
Date: Fri Nov 12 2021 - 11:25:15 EST


On Thu, Nov 11, 2021 at 12:44:05AM -0800, Stephane Eranian wrote:
> @@ -989,6 +1165,23 @@ static int __init amd_core_pmu_init(void)
> x86_pmu.flags |= PMU_FL_PAIR;
> }
>
> + if (boot_cpu_data.x86 >= 0x19) {
> + /*
> + * On AMD, invoking pmu_disable_all() is very expensive and the function is
> + * invoked on context-switch in via sched_task_in(), so enable only when necessary
> + */

Well, it only gets called when brs is in use, so afaict the above
comment is a bit misleading. Still no point in installing that function
when there it no point for it.

> + if (!amd_brs_init()) {
> + x86_pmu.get_event_constraints = amd_get_event_constraints_f19h;
> + x86_pmu.sched_task = amd_pmu_sched_task;
> + /*
> + * The put_event_constraints callback is shared with
> + * Fam17h, set above
> + */
> + }
> + }
> +
> + x86_pmu.attr_update = amd_attr_update;
> +
> pr_cont("core perfctr, ");
> return 0;
> }