From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751033AbdALJUs (ORCPT ); Thu, 12 Jan 2017 04:20:48 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:44938 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdALJUr (ORCPT ); Thu, 12 Jan 2017 04:20:47 -0500 Date: Thu, 12 Jan 2017 10:20:37 +0100 From: Peter Zijlstra To: Janakarajan Natarajan Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Suravee Suthikulpanit Subject: Re: [PATCH 2/3] perf/x86/amd/uncore: Dynamically allocate uncore counters Message-ID: <20170112092037.GB3051@twins.programming.kicks-ass.net> References: <11f5b2f7a63c0123cd2f9ba9cb4693c6feca1205.1484148262.git.Janakarajan.Natarajan@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11f5b2f7a63c0123cd2f9ba9cb4693c6feca1205.1484148262.git.Janakarajan.Natarajan@amd.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 11, 2017 at 10:02:17AM -0600, Janakarajan Natarajan wrote: > This patch updates the AMD uncore driver to support AMD Family17h > processors. In Family17h, there are two extra last level cache counters. > The counters are, therefore, allocated dynamically based on the family. > > The cpu hotplug up callback function is refactored to better manage > failure conditions. > > Signed-off-by: Janakarajan Natarajan > --- > arch/x86/events/amd/uncore.c | 141 +++++++++++++++++++++++++++++++------------ > 1 file changed, 104 insertions(+), 37 deletions(-) > > diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c > index 24c8537..7ab92f7 100644 > --- a/arch/x86/events/amd/uncore.c > +++ b/arch/x86/events/amd/uncore.c > @@ -22,13 +22,16 @@ > > #define NUM_COUNTERS_NB 4 > #define NUM_COUNTERS_L2 4 > -#define MAX_COUNTERS NUM_COUNTERS_NB > +#define NUM_COUNTERS_L3 6 > > #define RDPMC_BASE_NB 6 > #define RDPMC_BASE_LLC 10 > > #define COUNTER_SHIFT 16 > > +static int num_counters_llc; > +static int num_counters_nb; > + > static HLIST_HEAD(uncore_unused_list); > > struct amd_uncore { > @@ -40,7 +43,7 @@ struct amd_uncore { > u32 msr_base; > cpumask_t *active_mask; > struct pmu *pmu; > - struct perf_event *events[MAX_COUNTERS]; > + struct perf_event **events; > struct hlist_node node; > }; Why bother with the dynamic allocation crud? Why not simply set MAX_COUNTERS to 6 and be happy?