Re: [PATCH] Add support for disabling Intel PT trace in ftrace
From: Alexander Shishkin
Date: Wed Nov 23 2016 - 02:42:10 EST
Andi Kleen <andi@xxxxxxxxxxxxxx> writes:
> +/*
> + * Disable the PT trace for debugging purposes.
> + */
> +void pt_disable(void)
> +{
> + u64 val;
> +
> + if (!boot_cpu_has(X86_FEATURE_INTEL_PT))
> + return;
> +
> + rdmsrl_safe(MSR_IA32_RTIT_CTL, &val);
> + val &= ~RTIT_CTL_TRACEEN;
> + wrmsrl_safe(MSR_IA32_RTIT_CTL, val);
> +}
> +EXPORT_SYMBOL(pt_disable);
This will create unexplainable gaps in the trace, at least we should
output RECORD_AUX when this happens, maybe add a flag for "had to stop
the trace for reasons external to perf".
Also, I can't tell if this is called from an atomic context.
But I'd suggest something more generic like perf_pmu_off($pmu):
- we already have the code to stop the output;
- this won't be a driver-specific api then;
- this will be reflected in the event hw state;
- it will also go through the driver's callbacks, so its internal
states will actually match the reality;
- will work equally well for intel_bts or the ARM/Coresight tracers.
Regards,
--
Alex