[PATCH v2 14/32] perf/x86/intel/cqm: add preallocation of anodes
From: David Carrillo-Cisneros
Date: Wed May 11 2016 - 19:07:09 EST
Pre-allocate enough anodes to be able to at least hold one set of RMIDs
per package before running out of anodes.
Reviewed-by: Stephane Eranian <eranian@xxxxxxxxxx>
Signed-off-by: David Carrillo-Cisneros <davidcc@xxxxxxxxxx>
---
arch/x86/events/intel/cqm.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 523abc6..0771154 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -175,6 +175,7 @@ static int anode_pool__alloc_one(u16 pkg_id);
/* Init cqm pkg_data for @cpu 's package. */
static int pkg_data_init_cpu(int cpu)
{
+ int i, nr_anodes;
struct pkg_data *pkg_data;
struct cpuinfo_x86 *c = &cpu_data(cpu);
u16 pkg_id = topology_physical_package_id(cpu);
@@ -238,6 +239,15 @@ static int pkg_data_init_cpu(int cpu)
pkg_data->timed_update_cpu = cpu;
cqm_pkgs_data[pkg_id] = pkg_data;
+
+ /* Pre-allocate pool with one anode more than minimum needed to contain
+ * all the RMIDs in the package.
+ */
+ nr_anodes = (pkg_data->max_rmid + NR_RMIDS_PER_NODE) /
+ NR_RMIDS_PER_NODE + 1;
+
+ for (i = 0; i < nr_anodes; i++)
+ anode_pool__alloc_one(pkg_id);
return 0;
}
--
2.8.0.rc3.226.g39d4020