Re: [PATCH V5 1/6] perf, x86: use the PEBS auto reload mechanism when possible
From: Peter Zijlstra
Date: Mon Mar 30 2015 - 08:06:25 EST
On Mon, Feb 23, 2015 at 09:25:51AM -0500, Kan Liang wrote:
> +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
> @@ -673,6 +673,8 @@ void intel_pmu_pebs_enable(struct perf_event *event)
> struct hw_perf_event *hwc = &event->hw;
>
> hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
> + if (!event->attr.freq)
> + hwc->flags |= PERF_X86_EVENT_AUTO_RELOAD;
>
> cpuc->pebs_enabled |= 1ULL << hwc->idx;
Why not in x86_pmu_event_init()? This is not something that will change,
ever, right?
> @@ -680,6 +682,12 @@ void intel_pmu_pebs_enable(struct perf_event *event)
> cpuc->pebs_enabled |= 1ULL << (hwc->idx + 32);
> else if (event->hw.flags & PERF_X86_EVENT_PEBS_ST)
> cpuc->pebs_enabled |= 1ULL << 63;
> +
> + /* Use auto-reload if possible to save a MSR write in the PMI */
> + if (hwc->flags & PERF_X86_EVENT_AUTO_RELOAD) {
> + ds->pebs_event_reset[hwc->idx] =
> + (u64)-hwc->sample_period & x86_pmu.cntval_mask;
> + }
> }
>
> void intel_pmu_pebs_disable(struct perf_event *event)
> @@ -698,6 +706,7 @@ void intel_pmu_pebs_disable(struct perf_event *event)
> wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
>
> hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
> + hwc->flags &= ~PERF_X86_EVENT_AUTO_RELOAD;
Equally, we should not ever have to clear this. You cannot change
attributes after the event is created, if that flag ever gets set, it
stays valid.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/