From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752862AbbC3MGW (ORCPT ); Mon, 30 Mar 2015 08:06:22 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:48208 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752680AbbC3MGU (ORCPT ); Mon, 30 Mar 2015 08:06:20 -0400 Date: Mon, 30 Mar 2015 14:06:07 +0200 From: Peter Zijlstra To: Kan Liang Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, acme@infradead.org, eranian@google.com, andi@firstfloor.org Subject: Re: [PATCH V5 1/6] perf, x86: use the PEBS auto reload mechanism when possible Message-ID: <20150330120607.GU23123@twins.programming.kicks-ass.net> References: <1424701556-28270-1-git-send-email-kan.liang@intel.com> <1424701556-28270-2-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424701556-28270-2-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.