mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
perf/x86/intel: Make cpuc allocations consistent
commit d01b1f96a8 upstream
The cpuc data structure allocation is different between fake and real
cpuc's; use the same code to init/free both.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7053a6faf0
commit
f99f7dae78
@@ -1970,7 +1970,7 @@ static int x86_pmu_commit_txn(struct pmu *pmu)
|
|||||||
*/
|
*/
|
||||||
static void free_fake_cpuc(struct cpu_hw_events *cpuc)
|
static void free_fake_cpuc(struct cpu_hw_events *cpuc)
|
||||||
{
|
{
|
||||||
kfree(cpuc->shared_regs);
|
intel_cpuc_finish(cpuc);
|
||||||
kfree(cpuc);
|
kfree(cpuc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1982,14 +1982,11 @@ static struct cpu_hw_events *allocate_fake_cpuc(void)
|
|||||||
cpuc = kzalloc(sizeof(*cpuc), GFP_KERNEL);
|
cpuc = kzalloc(sizeof(*cpuc), GFP_KERNEL);
|
||||||
if (!cpuc)
|
if (!cpuc)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
/* only needed, if we have extra_regs */
|
|
||||||
if (x86_pmu.extra_regs) {
|
|
||||||
cpuc->shared_regs = allocate_shared_regs(cpu);
|
|
||||||
if (!cpuc->shared_regs)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
cpuc->is_fake = 1;
|
cpuc->is_fake = 1;
|
||||||
|
|
||||||
|
if (intel_cpuc_prepare(cpuc, cpu))
|
||||||
|
goto error;
|
||||||
|
|
||||||
return cpuc;
|
return cpuc;
|
||||||
error:
|
error:
|
||||||
free_fake_cpuc(cpuc);
|
free_fake_cpuc(cpuc);
|
||||||
|
|||||||
@@ -3282,7 +3282,7 @@ ssize_t intel_event_sysfs_show(char *page, u64 config)
|
|||||||
return x86_event_sysfs_show(page, config, event);
|
return x86_event_sysfs_show(page, config, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct intel_shared_regs *allocate_shared_regs(int cpu)
|
static struct intel_shared_regs *allocate_shared_regs(int cpu)
|
||||||
{
|
{
|
||||||
struct intel_shared_regs *regs;
|
struct intel_shared_regs *regs;
|
||||||
int i;
|
int i;
|
||||||
@@ -3314,10 +3314,9 @@ static struct intel_excl_cntrs *allocate_excl_cntrs(int cpu)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int intel_pmu_cpu_prepare(int cpu)
|
|
||||||
{
|
|
||||||
struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
|
|
||||||
|
|
||||||
|
int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu)
|
||||||
|
{
|
||||||
if (x86_pmu.extra_regs || x86_pmu.lbr_sel_map) {
|
if (x86_pmu.extra_regs || x86_pmu.lbr_sel_map) {
|
||||||
cpuc->shared_regs = allocate_shared_regs(cpu);
|
cpuc->shared_regs = allocate_shared_regs(cpu);
|
||||||
if (!cpuc->shared_regs)
|
if (!cpuc->shared_regs)
|
||||||
@@ -3327,7 +3326,7 @@ static int intel_pmu_cpu_prepare(int cpu)
|
|||||||
if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
|
if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
|
||||||
size_t sz = X86_PMC_IDX_MAX * sizeof(struct event_constraint);
|
size_t sz = X86_PMC_IDX_MAX * sizeof(struct event_constraint);
|
||||||
|
|
||||||
cpuc->constraint_list = kzalloc(sz, GFP_KERNEL);
|
cpuc->constraint_list = kzalloc_node(sz, GFP_KERNEL, cpu_to_node(cpu));
|
||||||
if (!cpuc->constraint_list)
|
if (!cpuc->constraint_list)
|
||||||
goto err_shared_regs;
|
goto err_shared_regs;
|
||||||
|
|
||||||
@@ -3352,6 +3351,11 @@ err:
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int intel_pmu_cpu_prepare(int cpu)
|
||||||
|
{
|
||||||
|
return intel_cpuc_prepare(&per_cpu(cpu_hw_events, cpu), cpu);
|
||||||
|
}
|
||||||
|
|
||||||
static void flip_smm_bit(void *data)
|
static void flip_smm_bit(void *data)
|
||||||
{
|
{
|
||||||
unsigned long set = *(unsigned long *)data;
|
unsigned long set = *(unsigned long *)data;
|
||||||
@@ -3423,9 +3427,8 @@ static void intel_pmu_cpu_starting(int cpu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_excl_cntrs(int cpu)
|
static void free_excl_cntrs(struct cpu_hw_events *cpuc)
|
||||||
{
|
{
|
||||||
struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
|
|
||||||
struct intel_excl_cntrs *c;
|
struct intel_excl_cntrs *c;
|
||||||
|
|
||||||
c = cpuc->excl_cntrs;
|
c = cpuc->excl_cntrs;
|
||||||
@@ -3443,9 +3446,8 @@ static void intel_pmu_cpu_dying(int cpu)
|
|||||||
fini_debug_store_on_cpu(cpu);
|
fini_debug_store_on_cpu(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_pmu_cpu_dead(int cpu)
|
void intel_cpuc_finish(struct cpu_hw_events *cpuc)
|
||||||
{
|
{
|
||||||
struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
|
|
||||||
struct intel_shared_regs *pc;
|
struct intel_shared_regs *pc;
|
||||||
|
|
||||||
pc = cpuc->shared_regs;
|
pc = cpuc->shared_regs;
|
||||||
@@ -3455,7 +3457,12 @@ static void intel_pmu_cpu_dead(int cpu)
|
|||||||
cpuc->shared_regs = NULL;
|
cpuc->shared_regs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free_excl_cntrs(cpu);
|
free_excl_cntrs(cpuc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void intel_pmu_cpu_dead(int cpu)
|
||||||
|
{
|
||||||
|
intel_cpuc_finish(&per_cpu(cpu_hw_events, cpu));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_pmu_sched_task(struct perf_event_context *ctx,
|
static void intel_pmu_sched_task(struct perf_event_context *ctx,
|
||||||
@@ -4515,7 +4522,7 @@ static __init int fixup_ht_bug(void)
|
|||||||
hardlockup_detector_perf_restart();
|
hardlockup_detector_perf_restart();
|
||||||
|
|
||||||
for_each_online_cpu(c)
|
for_each_online_cpu(c)
|
||||||
free_excl_cntrs(c);
|
free_excl_cntrs(&per_cpu(cpu_hw_events, c));
|
||||||
|
|
||||||
cpus_read_unlock();
|
cpus_read_unlock();
|
||||||
pr_info("PMU erratum BJ122, BV98, HSD29 workaround disabled, HT off\n");
|
pr_info("PMU erratum BJ122, BV98, HSD29 workaround disabled, HT off\n");
|
||||||
|
|||||||
@@ -887,7 +887,8 @@ struct event_constraint *
|
|||||||
x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
|
x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
|
||||||
struct perf_event *event);
|
struct perf_event *event);
|
||||||
|
|
||||||
struct intel_shared_regs *allocate_shared_regs(int cpu);
|
extern int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu);
|
||||||
|
extern void intel_cpuc_finish(struct cpu_hw_events *cpuc);
|
||||||
|
|
||||||
int intel_pmu_init(void);
|
int intel_pmu_init(void);
|
||||||
|
|
||||||
@@ -1023,9 +1024,13 @@ static inline int intel_pmu_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct intel_shared_regs *allocate_shared_regs(int cpu)
|
static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc)
|
||||||
{
|
{
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int is_ht_workaround_enabled(void)
|
static inline int is_ht_workaround_enabled(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user