mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Natarajan, Janakarajan" <Janakarajan.Natarajan@amd.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH 2/3] perf/x86/amd/uncore: Dynamically allocate uncore counters
Date: Fri, 13 Jan 2017 09:58:58 +0100	[thread overview]
Message-ID: <20170113085858.GA3159@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <b5b6ccdb-a036-cede-5d65-4a454224e7d0@amd.com>

On Thu, Jan 12, 2017 at 06:48:40PM -0600, Natarajan, Janakarajan wrote:
> 
> On 1/12/2017 3:20 AM, Peter Zijlstra wrote:
> >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 <Janakarajan.Natarajan@amd.com>
> >>---
> >>  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?
> My reasoning behind using dynamic allocation was to prevent memory from
> being allocated when not needed on a per cpu basis. If memory isn't a
> consideration, I can send a v2 without the dynamic memory allocation.

Generally a sensible thing to consider, but here we're talking about 16
bytes bytes or so and are adding quite a bit of logic just to save that
on older hardware.

Also, doing that allocation comes at the cost of having to do an extra
pointer dereference every time you use these things.

I'd just keep static sized array and bump the max to 6 and not worry too
much.

(fwiw, the generic x86 cpu pmu does static arrays of 64 entries, even
through there's not a single PMU to actually have that many counters
on).

  reply	other threads:[~2017-01-13  8:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 16:02 [PATCH 0/3] perf/x86/amd/uncore: Update AMD uncore driver Janakarajan Natarajan
2017-01-11 16:02 ` [PATCH 1/3] perf/x86/amd/uncore: Update AMD uncore to rename L2 to LLC Janakarajan Natarajan
2017-01-11 16:02 ` [PATCH 2/3] perf/x86/amd/uncore: Dynamically allocate uncore counters Janakarajan Natarajan
2017-01-12  9:20   ` Peter Zijlstra
2017-01-13  0:48     ` Natarajan, Janakarajan
2017-01-13  8:58       ` Peter Zijlstra [this message]
2017-01-12 13:12   ` [PATCH] perf/x86/amd/uncore: fix ifnullfree.cocci warnings kbuild test robot
2017-01-12 13:12   ` [PATCH 2/3] perf/x86/amd/uncore: Dynamically allocate uncore counters kbuild test robot
2017-01-11 16:02 ` [PATCH 3/3] perf/x86/amd/uncore: Update sysfs attributes for Family17h processors Janakarajan Natarajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170113085858.GA3159@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Janakarajan.Natarajan@amd.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=suravee.suthikulpanit@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome