mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-02 16:44:59 +00:00
perf/x86/rapl: Move the pmu allocation out of CPU hotplug
There are extra codes in the CPU hotplug function to allocate rapl pmus. The generic PMU hotplug support is hard to be applied. As long as the rapl pmus can be allocated upfront for each die/socket, the code doesn't need to be implemented in the CPU hotplug function. Move the code to the init_rapl_pmus(), and allocate a PMU for each possible die/socket. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Oliver Sang <oliver.sang@intel.com> Link: https://lore.kernel.org/r/20241010142604.770192-1-kan.liang@linux.intel.com
This commit is contained in:
parent
4d756095d3
commit
9b99d65c0b
@ -602,19 +602,8 @@ static int rapl_cpu_online(unsigned int cpu)
|
|||||||
struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu);
|
struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu);
|
||||||
int target;
|
int target;
|
||||||
|
|
||||||
if (!pmu) {
|
if (!pmu)
|
||||||
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
|
return -ENOMEM;
|
||||||
if (!pmu)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
raw_spin_lock_init(&pmu->lock);
|
|
||||||
INIT_LIST_HEAD(&pmu->active_list);
|
|
||||||
pmu->pmu = &rapl_pmus->pmu;
|
|
||||||
pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
|
|
||||||
rapl_hrtimer_init(pmu);
|
|
||||||
|
|
||||||
rapl_pmus->pmus[rapl_pmu_idx] = pmu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if there is an online cpu in the package which collects rapl
|
* Check if there is an online cpu in the package which collects rapl
|
||||||
@ -707,6 +696,32 @@ static const struct attribute_group *rapl_attr_update[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int __init init_rapl_pmu(void)
|
||||||
|
{
|
||||||
|
struct rapl_pmu *pmu;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
for (idx = 0; idx < rapl_pmus->nr_rapl_pmu; idx++) {
|
||||||
|
pmu = kzalloc(sizeof(*pmu), GFP_KERNEL);
|
||||||
|
if (!pmu)
|
||||||
|
goto free;
|
||||||
|
|
||||||
|
raw_spin_lock_init(&pmu->lock);
|
||||||
|
INIT_LIST_HEAD(&pmu->active_list);
|
||||||
|
pmu->pmu = &rapl_pmus->pmu;
|
||||||
|
pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
|
||||||
|
rapl_hrtimer_init(pmu);
|
||||||
|
|
||||||
|
rapl_pmus->pmus[idx] = pmu;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
free:
|
||||||
|
for (; idx > 0; idx--)
|
||||||
|
kfree(rapl_pmus->pmus[idx - 1]);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
static int __init init_rapl_pmus(void)
|
static int __init init_rapl_pmus(void)
|
||||||
{
|
{
|
||||||
int nr_rapl_pmu = topology_max_packages();
|
int nr_rapl_pmu = topology_max_packages();
|
||||||
@ -730,7 +745,8 @@ static int __init init_rapl_pmus(void)
|
|||||||
rapl_pmus->pmu.read = rapl_pmu_event_read;
|
rapl_pmus->pmu.read = rapl_pmu_event_read;
|
||||||
rapl_pmus->pmu.module = THIS_MODULE;
|
rapl_pmus->pmu.module = THIS_MODULE;
|
||||||
rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE;
|
rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE;
|
||||||
return 0;
|
|
||||||
|
return init_rapl_pmu();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rapl_model model_snb = {
|
static struct rapl_model model_snb = {
|
||||||
|
Loading…
Reference in New Issue
Block a user