powerpc/perf: PMU functions for Core IMC and hotplugging
Subsystems (2)
PATCH v10 7/10 powerpc/perf: PMU functions for Core IMC and hotplugging
Code to add PMU function to initialize a core IMC event. It also adds cpumask initialization function for core IMC PMU. For initialization, memory is allocated per core where the data for core IMC counters will be accumulated. The base address for this page is sent to OPAL via an OPAL call which initializes various SCOMs related to Core IMC initialization. Upon any errors, the pages are free'ed and core IMC counters are disabled using the same OPAL call.
For CPU hotplugging, a cpumask is initialized which contains an online CPU from each core. If a cpu goes offline, we check whether that cpu belongs to the core imc cpumask, if yes, then, we migrate the PMU context to any other online cpu (if available) in that core. If a cpu comes back online, then this cpu will be added to the core imc cpumask only if there was no other cpu from that core in the previous cpumask.
To register the hotplug functions for core_imc, a new state CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE is added to the list of existing states.
Patch also adds OPAL device shutdown callback. Needed to disable the IMC core engine to handle kexec.
--- arch/powerpc/include/asm/imc-pmu.h | 1 + arch/powerpc/include/asm/opal-api.h | 1 + arch/powerpc/perf/imc-pmu.c | 265 +++++++++++++++++++++++++++++- arch/powerpc/platforms/powernv/opal-imc.c | 7 + include/linux/cpuhotplug.h | 1 + 5 files changed, 269 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/imc-pmu.h +1 -0
@@ -99,5 +99,6 @@ struct imc_pmu {extern struct imc_pmu *per_nest_pmu_arr[IMC_MAX_PMUS ];extern struct imc_pmu *core_imc_pmu; +extern int imc_control (unsigned long type,bool operation);extern int __init init_imc_pmu (struct imc_events *events,int idx,struct imc_pmu *pmu_ptr);#endif /* PPC_POWERNV_IMC_PMU_DEF_H */
arch/powerpc/include/asm/opal-api.h +1 -0
@@ -1018,6 +1018,7 @@ enum {/* Argument to OPAL_IMC_COUNTERS_* */ enum {OPAL_IMC_COUNTERS_NEST =1 , +OPAL_IMC_COUNTERS_CORE =2 , };#endif /* __ASSEMBLY__ */
arch/powerpc/perf/imc-pmu.c +259 -6
327 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-imc.c +7 -0
@@ -531,6 +531,12 @@ static int opal_imc_counters_probe(struct platform_device *pdev)return 0 ; } +static void opal_imc_counters_shutdown (struct platform_device *pdev) +{ +/* Disable the IMC Core functions */ +imc_control (OPAL_IMC_COUNTERS_CORE , false); +} +static const struct of_device_id opal_imc_match[] = { { .compatible =IMC_DTB_COMPAT }, {},
@@ -542,6 +548,7 @@ static struct platform_driver opal_imc_driver = { .of_match_table = opal_imc_match, }, .probe = opal_imc_counters_probe, + .shutdown = opal_imc_counters_shutdown, };MODULE_DEVICE_TABLE (of, opal_imc_match);
include/linux/cpuhotplug.h +1 -0
@@ -140,6 +140,7 @@ enum cpuhp_state {CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE ,CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE ,CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE , +CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE ,CPUHP_AP_WORKQUEUE_ONLINE ,CPUHP_AP_RCUTREE_ONLINE , CPUHP_AP_ONLINE_DYN,
Signature · 1 line
2.7.4