[PATCH 14/32] perf/x86/intel/cqm: add preallocation of anodes

2016-04-28 Thread David Carrillo-Cisneros
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 
Signed-off-by: David Carrillo-Cisneros 
---
 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 904f2d3..98a919f 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -194,6 +194,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 = _data(cpu);
u16 pkg_id = topology_physical_package_id(cpu);
@@ -257,6 +258,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



[PATCH 14/32] perf/x86/intel/cqm: add preallocation of anodes

2016-04-28 Thread David Carrillo-Cisneros
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 
Signed-off-by: David Carrillo-Cisneros 
---
 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 904f2d3..98a919f 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -194,6 +194,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 = _data(cpu);
u16 pkg_id = topology_physical_package_id(cpu);
@@ -257,6 +258,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