From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754261AbcB2LNb (ORCPT ); Mon, 29 Feb 2016 06:13:31 -0500 Received: from torg.zytor.com ([198.137.202.12]:54074 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752126AbcB2LNa (ORCPT ); Mon, 29 Feb 2016 06:13:30 -0500 Date: Mon, 29 Feb 2016 03:12:27 -0800 From: tip-bot for Thomas Gleixner Message-ID: Cc: harish.chegondi@intel.com, kan.liang@intel.com, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, acme@redhat.com, jacob.jun.pan@linux.intel.com, bp@alien8.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, eranian@google.com, andi.kleen@intel.com, vincent.weaver@maine.edu, jolsa@redhat.com Reply-To: harish.chegondi@intel.com, kan.liang@intel.com, hpa@zytor.com, tglx@linutronix.de, jacob.jun.pan@linux.intel.com, bp@alien8.de, mingo@kernel.org, peterz@infradead.org, acme@redhat.com, eranian@google.com, andi.kleen@intel.com, torvalds@linux-foundation.org, vincent.weaver@maine.edu, jolsa@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: <20160222221012.748151799@linutronix.de> References: <20160222221012.748151799@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/intel/rapl: Utilize event->pmu_private Git-Commit-ID: 8a6d2f8f73caa8b8eb596a9e2d2e0b15d64751a4 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8a6d2f8f73caa8b8eb596a9e2d2e0b15d64751a4 Gitweb: http://git.kernel.org/tip/8a6d2f8f73caa8b8eb596a9e2d2e0b15d64751a4 Author: Thomas Gleixner AuthorDate: Mon, 22 Feb 2016 22:19:25 +0000 Committer: Ingo Molnar CommitDate: Mon, 29 Feb 2016 09:35:25 +0100 perf/x86/intel/rapl: Utilize event->pmu_private Store the PMU pointer in event->pmu_private and use it instead of the per CPU data. Preparatory step to get rid of the per CPU allocations. The usage sites are the perf fast path, so we keep that even after the conversion to per package storage as a CPU to package lookup involves 3 loads versus 1 with the pmu_private pointer. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Harish Chegondi Cc: Jacob Pan Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vince Weaver Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20160222221012.748151799@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/events/intel/rapl.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index 2934999..753d90c 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c @@ -122,6 +122,7 @@ static struct perf_pmu_events_attr event_attr_##v = { \ struct rapl_pmu { raw_spinlock_t lock; int n_active; + int cpu; struct list_head active_list; struct pmu *pmu; ktime_t timer_interval; @@ -203,7 +204,7 @@ static void rapl_start_hrtimer(struct rapl_pmu *pmu) static enum hrtimer_restart rapl_hrtimer_handle(struct hrtimer *hrtimer) { - struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); + struct rapl_pmu *pmu = container_of(hrtimer, struct rapl_pmu, hrtimer); struct perf_event *event; unsigned long flags; @@ -249,7 +250,7 @@ static void __rapl_pmu_event_start(struct rapl_pmu *pmu, static void rapl_pmu_event_start(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); + struct rapl_pmu *pmu = event->pmu_private; unsigned long flags; raw_spin_lock_irqsave(&pmu->lock, flags); @@ -259,7 +260,7 @@ static void rapl_pmu_event_start(struct perf_event *event, int mode) static void rapl_pmu_event_stop(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); + struct rapl_pmu *pmu = event->pmu_private; struct hw_perf_event *hwc = &event->hw; unsigned long flags; @@ -293,7 +294,7 @@ static void rapl_pmu_event_stop(struct perf_event *event, int mode) static int rapl_pmu_event_add(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); + struct rapl_pmu *pmu = event->pmu_private; struct hw_perf_event *hwc = &event->hw; unsigned long flags; @@ -316,6 +317,7 @@ static void rapl_pmu_event_del(struct perf_event *event, int flags) static int rapl_pmu_event_init(struct perf_event *event) { + struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); u64 cfg = event->attr.config & RAPL_EVENT_MASK; int bit, msr, ret = 0; @@ -327,6 +329,9 @@ static int rapl_pmu_event_init(struct perf_event *event) if (event->attr.config & ~RAPL_EVENT_MASK) return -EINVAL; + if (event->cpu < 0) + return -EINVAL; + /* * check event is known (determines counter) */ @@ -365,6 +370,8 @@ static int rapl_pmu_event_init(struct perf_event *event) return -EINVAL; /* must be done before validate_group */ + event->cpu = pmu->cpu; + event->pmu_private = pmu; event->hw.event_base = msr; event->hw.config = cfg; event->hw.idx = bit; @@ -572,6 +579,7 @@ static int rapl_cpu_prepare(int cpu) INIT_LIST_HEAD(&pmu->active_list); pmu->pmu = &rapl_pmu_class; + pmu->cpu = cpu; pmu->timer_interval = ms_to_ktime(rapl_timer_ms);