116 lines
3.2 KiB
Diff
116 lines
3.2 KiB
Diff
From 395cf3513aaf79c95c611ce97ba451eaf6470c44 Mon Sep 17 00:00:00 2001
|
|
From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
|
Date: Fri, 15 Nov 2024 06:08:02 +0000
|
|
Subject: perf/x86/rapl: Add arguments to the init and cleanup functions
|
|
|
|
Prepare for the addition of RAPL core energy counter support.
|
|
|
|
Add arguments to the init and cleanup functions, which will help in
|
|
initialization and cleaning up of two separate PMUs.
|
|
|
|
No functional change.
|
|
|
|
Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
|
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
|
|
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
|
|
Tested-by: Zhang Rui <rui.zhang@intel.com>
|
|
---
|
|
arch/x86/events/rapl.c | 28 ++++++++++++++++------------
|
|
1 file changed, 16 insertions(+), 12 deletions(-)
|
|
|
|
--- a/arch/x86/events/rapl.c
|
|
+++ b/arch/x86/events/rapl.c
|
|
@@ -602,7 +602,7 @@ static void __init rapl_advertise(void)
|
|
}
|
|
}
|
|
|
|
-static void cleanup_rapl_pmus(void)
|
|
+static void cleanup_rapl_pmus(struct rapl_pmus *rapl_pmus)
|
|
{
|
|
int i;
|
|
|
|
@@ -620,7 +620,7 @@ static const struct attribute_group *rap
|
|
NULL,
|
|
};
|
|
|
|
-static int __init init_rapl_pmu(void)
|
|
+static int __init init_rapl_pmu(struct rapl_pmus *rapl_pmus)
|
|
{
|
|
struct rapl_pmu *rapl_pmu;
|
|
int idx;
|
|
@@ -646,20 +646,20 @@ free:
|
|
return -ENOMEM;
|
|
}
|
|
|
|
-static int __init init_rapl_pmus(void)
|
|
+static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr, int rapl_pmu_scope)
|
|
{
|
|
int nr_rapl_pmu = topology_max_packages();
|
|
- int rapl_pmu_scope = PERF_PMU_SCOPE_PKG;
|
|
+ struct rapl_pmus *rapl_pmus;
|
|
|
|
- if (!rapl_pmu_is_pkg_scope()) {
|
|
- nr_rapl_pmu *= topology_max_dies_per_package();
|
|
- rapl_pmu_scope = PERF_PMU_SCOPE_DIE;
|
|
- }
|
|
+ if (rapl_pmu_scope == PERF_PMU_SCOPE_DIE)
|
|
+ nr_rapl_pmu *= topology_max_dies_per_package();
|
|
|
|
rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, nr_rapl_pmu), GFP_KERNEL);
|
|
if (!rapl_pmus)
|
|
return -ENOMEM;
|
|
|
|
+ *rapl_pmus_ptr = rapl_pmus;
|
|
+
|
|
rapl_pmus->nr_rapl_pmu = nr_rapl_pmu;
|
|
rapl_pmus->pmu.attr_groups = rapl_attr_groups;
|
|
rapl_pmus->pmu.attr_update = rapl_attr_update;
|
|
@@ -674,7 +674,7 @@ static int __init init_rapl_pmus(void)
|
|
rapl_pmus->pmu.module = THIS_MODULE;
|
|
rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE;
|
|
|
|
- return init_rapl_pmu();
|
|
+ return init_rapl_pmu(rapl_pmus);
|
|
}
|
|
|
|
static struct rapl_model model_snb = {
|
|
@@ -798,8 +798,12 @@ MODULE_DEVICE_TABLE(x86cpu, rapl_model_m
|
|
static int __init rapl_pmu_init(void)
|
|
{
|
|
const struct x86_cpu_id *id;
|
|
+ int rapl_pmu_scope = PERF_PMU_SCOPE_DIE;
|
|
int ret;
|
|
|
|
+ if (rapl_pmu_is_pkg_scope())
|
|
+ rapl_pmu_scope = PERF_PMU_SCOPE_PKG;
|
|
+
|
|
id = x86_match_cpu(rapl_model_match);
|
|
if (!id)
|
|
return -ENODEV;
|
|
@@ -815,7 +819,7 @@ static int __init rapl_pmu_init(void)
|
|
if (ret)
|
|
return ret;
|
|
|
|
- ret = init_rapl_pmus();
|
|
+ ret = init_rapl_pmus(&rapl_pmus, rapl_pmu_scope);
|
|
if (ret)
|
|
return ret;
|
|
|
|
@@ -828,7 +832,7 @@ static int __init rapl_pmu_init(void)
|
|
|
|
out:
|
|
pr_warn("Initialization failed (%d), disabled\n", ret);
|
|
- cleanup_rapl_pmus();
|
|
+ cleanup_rapl_pmus(rapl_pmus);
|
|
return ret;
|
|
}
|
|
module_init(rapl_pmu_init);
|
|
@@ -836,6 +840,6 @@ module_init(rapl_pmu_init);
|
|
static void __exit intel_rapl_exit(void)
|
|
{
|
|
perf_pmu_unregister(&rapl_pmus->pmu);
|
|
- cleanup_rapl_pmus();
|
|
+ cleanup_rapl_pmus(rapl_pmus);
|
|
}
|
|
module_exit(intel_rapl_exit);
|