Skip to contentSkip to conversation

powerpc/perf: IMC pmu cpumask and cpuhotplug support

PATCH In review Madhavan Srinivasan 1 participant 1 message Jun 8, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v10 5/10 powerpc/perf: IMC pmu cpumask and cpuhotplug support

From: Anju T Sudhakar <[email protected]>

Adds cpumask attribute to be used by each IMC pmu. Only one cpu (any online CPU) from each chip for nest PMUs is designated to read counters.

On CPU hotplug, dying CPU is checked to see whether it is one of the designated cpus, if yes, next online cpu from the same chip (for nest units) is designated as new cpu to read counters. For this purpose, we introduce a new state : CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE.

---
 arch/powerpc/include/asm/opal-api.h            |  14 +-
 arch/powerpc/include/asm/opal.h                |   4 +
 arch/powerpc/perf/imc-pmu.c                    | 211 ++++++++++++++++++++++++-
 arch/powerpc/platforms/powernv/opal-wrappers.S |   3 +
 include/linux/cpuhotplug.h                     |   1 +
 5 files changed, 229 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/opal-api.h +11 -3
index aa150f03a2d7..ebe9d6bd3f06 100644
@@ -190,7 +190,10 @@
 #define OPAL_NPU_INIT_CONTEXT			146
 #define OPAL_NPU_DESTROY_CONTEXT		147
 #define OPAL_NPU_MAP_LPAR			148
-#define OPAL_LAST				148
+#define OPAL_IMC_COUNTERS_INIT			149
+#define OPAL_IMC_COUNTERS_START			150
+#define OPAL_IMC_COUNTERS_STOP			151
+#define OPAL_LAST				151
 
 /* Device tree flags */
 
@@ -1005,8 +1008,13 @@ enum {
 
 /* In-Memory Collection Counters Type */
 enum {
-	IMC_COUNTER_PER_CHIP            = 0x10,
-	IMC_COUNTER_PER_SOCKET          = 0x20,
+	IMC_COUNTER_PER_CHIP		= 0x10,
+	IMC_COUNTER_PER_SOCKET		= 0x20,
+};
+
+/* Argument to OPAL_IMC_COUNTERS_*  */
+enum {
+	OPAL_IMC_COUNTERS_NEST = 1,
 };
 
 #endif /* __ASSEMBLY__ */
arch/powerpc/include/asm/opal.h +4 -0
index 588fb1c23af9..cdf78b6a9245 100644
@@ -268,6 +268,10 @@ int64_t opal_xive_free_irq(uint32_t girq);
 int64_t opal_xive_sync(uint32_t type, uint32_t id);
 int64_t opal_xive_dump(uint32_t type, uint32_t id);
 
+int64_t opal_imc_counters_init(uint32_t type, uint64_t address, uint64_t cpu);
+int64_t opal_imc_counters_start(uint32_t type);
+int64_t opal_imc_counters_stop(uint32_t type);
+
 /* Internal functions */
 extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
 				   int depth, void *data);
arch/powerpc/perf/imc-pmu.c +210 -1

249 lines not on this page · raw message

arch/powerpc/platforms/powernv/opal-wrappers.S +3 -0
index f620572f891f..1828b24fbb53 100644
@@ -310,3 +310,6 @@ OPAL_CALL(opal_xive_dump,			OPAL_XIVE_DUMP);
 OPAL_CALL(opal_npu_init_context,		OPAL_NPU_INIT_CONTEXT);
 OPAL_CALL(opal_npu_destroy_context,		OPAL_NPU_DESTROY_CONTEXT);
 OPAL_CALL(opal_npu_map_lpar,			OPAL_NPU_MAP_LPAR);
+OPAL_CALL(opal_imc_counters_init,              OPAL_IMC_COUNTERS_INIT);
+OPAL_CALL(opal_imc_counters_start,             OPAL_IMC_COUNTERS_START);
+OPAL_CALL(opal_imc_counters_stop,              OPAL_IMC_COUNTERS_STOP);
include/linux/cpuhotplug.h +1 -0
index 0f2a80377520..dca7f2b07f93 100644
@@ -139,6 +139,7 @@ enum cpuhp_state {
 	CPUHP_AP_PERF_ARM_L2X0_ONLINE,
 	CPUHP_AP_PERF_ARM_QCOM_L2_ONLINE,
 	CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE,
+	CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE,
 	CPUHP_AP_WORKQUEUE_ONLINE,
 	CPUHP_AP_RCUTREE_ONLINE,
 	CPUHP_AP_ONLINE_DYN,
Signature · 1 line
2.7.4