2024-12-10 00:17:37 +03:00
|
|
|
From 395cf3513aaf79c95c611ce97ba451eaf6470c44 Mon Sep 17 00:00:00 2001
|
2024-10-29 05:12:06 +03:00
|
|
|
From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
2024-12-10 00:17:37 +03:00
|
|
|
Date: Fri, 15 Nov 2024 06:08:02 +0000
|
|
|
|
Subject: perf/x86/rapl: Add arguments to the init and cleanup functions
|
2024-10-29 05:12:06 +03:00
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
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.
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
No functional change.
|
|
|
|
|
|
|
|
Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
2024-12-10 00:17:37 +03:00
|
|
|
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>
|
2024-10-29 05:12:06 +03:00
|
|
|
---
|
2024-12-10 00:17:37 +03:00
|
|
|
arch/x86/events/rapl.c | 28 ++++++++++++++++------------
|
|
|
|
1 file changed, 16 insertions(+), 12 deletions(-)
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
--- a/arch/x86/events/rapl.c
|
|
|
|
+++ b/arch/x86/events/rapl.c
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -602,7 +602,7 @@ static void __init rapl_advertise(void)
|
2024-10-29 05:12:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-static void cleanup_rapl_pmus(void)
|
|
|
|
+static void cleanup_rapl_pmus(struct rapl_pmus *rapl_pmus)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -620,7 +620,7 @@ static const struct attribute_group *rap
|
2024-10-29 05:12:06 +03:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
-static int __init init_rapl_pmu(void)
|
|
|
|
+static int __init init_rapl_pmu(struct rapl_pmus *rapl_pmus)
|
2024-10-29 05:12:06 +03:00
|
|
|
{
|
|
|
|
struct rapl_pmu *rapl_pmu;
|
2024-12-10 00:17:37 +03:00
|
|
|
int idx;
|
|
|
|
@@ -646,20 +646,20 @@ free:
|
|
|
|
return -ENOMEM;
|
2024-10-29 05:12:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
-static int __init init_rapl_pmus(void)
|
|
|
|
+static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr, int rapl_pmu_scope)
|
|
|
|
{
|
2024-12-10 00:17:37 +03:00
|
|
|
int nr_rapl_pmu = topology_max_packages();
|
|
|
|
- int rapl_pmu_scope = PERF_PMU_SCOPE_PKG;
|
2024-10-29 05:12:06 +03:00
|
|
|
+ struct rapl_pmus *rapl_pmus;
|
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
- if (!rapl_pmu_is_pkg_scope()) {
|
|
|
|
- nr_rapl_pmu *= topology_max_dies_per_package();
|
|
|
|
- rapl_pmu_scope = PERF_PMU_SCOPE_DIE;
|
2024-10-29 05:12:06 +03:00
|
|
|
- }
|
2024-12-10 00:17:37 +03:00
|
|
|
+ if (rapl_pmu_scope == PERF_PMU_SCOPE_DIE)
|
|
|
|
+ nr_rapl_pmu *= topology_max_dies_per_package();
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
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;
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -674,7 +674,7 @@ static int __init init_rapl_pmus(void)
|
2024-10-29 05:12:06 +03:00
|
|
|
rapl_pmus->pmu.module = THIS_MODULE;
|
|
|
|
rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE;
|
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
- return init_rapl_pmu();
|
|
|
|
+ return init_rapl_pmu(rapl_pmus);
|
2024-10-29 05:12:06 +03:00
|
|
|
}
|
2024-12-10 00:17:37 +03:00
|
|
|
|
|
|
|
static struct rapl_model model_snb = {
|
|
|
|
@@ -798,8 +798,12 @@ MODULE_DEVICE_TABLE(x86cpu, rapl_model_m
|
2024-10-29 05:12:06 +03:00
|
|
|
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;
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -815,7 +819,7 @@ static int __init rapl_pmu_init(void)
|
2024-10-29 05:12:06 +03:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
- ret = init_rapl_pmus();
|
|
|
|
+ ret = init_rapl_pmus(&rapl_pmus, rapl_pmu_scope);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -828,7 +832,7 @@ static int __init rapl_pmu_init(void)
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
out:
|
|
|
|
pr_warn("Initialization failed (%d), disabled\n", ret);
|
|
|
|
- cleanup_rapl_pmus();
|
|
|
|
+ cleanup_rapl_pmus(rapl_pmus);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
module_init(rapl_pmu_init);
|
2024-12-10 00:17:37 +03:00
|
|
|
@@ -836,6 +840,6 @@ module_init(rapl_pmu_init);
|
2024-10-29 05:12:06 +03:00
|
|
|
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);
|