[Skiboot] [PATCH 07/15] core/trace: Add cpu number to debug descriptor

Jordan Niethe jniethe5 at gmail.com
Mon Mar 25 11:14:17 AEDT 2019


The names given to the trace buffers when exported to sysfs should give
an indication of what cpu they are associated with. Add the cpu number
to the debug descriptor to make it easy to access.
---
 core/test/run-trace.c      | 2 +-
 core/trace.c               | 7 ++++---
 include/debug_descriptor.h | 1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/core/test/run-trace.c b/core/test/run-trace.c
index 1455394da0e6..971b967a5719 100644
--- a/core/test/run-trace.c
+++ b/core/test/run-trace.c
@@ -274,8 +274,8 @@ int main(void)
 		fake_cpus[i].is_secondary = (i & 0x1);
 		fake_cpus[i].primary = &fake_cpus[i & ~0x1];
 	}
-	init_trace_buffers();
 	my_fake_cpu = &fake_cpus[0];
+	init_trace_buffers();
 
 	for (i = 0; i < CPUS; i++) {
 		assert(trace_empty(&fake_cpus[i].trace->tb));
diff --git a/core/trace.c b/core/trace.c
index 5580eb13a8bd..b33a5bcf2318 100644
--- a/core/trace.c
+++ b/core/trace.c
@@ -179,7 +179,7 @@ static void trace_add_dt_props(void)
 	dt_add_property_u64(opal_node, "ibm,opal-trace-mask", tmask);
 }
 
-static void trace_add_desc(struct trace_info *t, uint64_t size)
+static void trace_add_desc(struct trace_info *t, uint64_t size, uint16_t cpu)
 {
 	unsigned int i = debug_descriptor.num_traces;
 
@@ -192,6 +192,7 @@ static void trace_add_desc(struct trace_info *t, uint64_t size)
 	debug_descriptor.trace_phys[i] = (uint64_t)t;
 	debug_descriptor.trace_tce[i] = 0; /* populated later */
 	debug_descriptor.trace_size[i] = size;
+	debug_descriptor.trace_cpu[i] = cpu;
 }
 
 /* Allocate trace buffers once we know memory topology */
@@ -202,7 +203,7 @@ void init_trace_buffers(void)
 	uint64_t size;
 
 	/* Boot the boot trace in the debug descriptor */
-	trace_add_desc(any, sizeof(boot_tracebuf));
+	trace_add_desc(any, sizeof(boot_tracebuf), this_cpu()->pir);
 
 	/* Allocate a trace buffer for each primary cpu. */
 	for_each_cpu(t) {
@@ -217,7 +218,7 @@ void init_trace_buffers(void)
 			memset(t->trace, 0, size);
 			init_lock(&t->trace->lock);
 			t->trace->tb.max_size = cpu_to_be32(MAX_SIZE);
-			trace_add_desc(any, size);
+			trace_add_desc(any, size, t->pir);
 		} else
 			prerror("TRACE: cpu 0x%x allocation failed\n", t->pir);
 	}
diff --git a/include/debug_descriptor.h b/include/debug_descriptor.h
index 619f49374385..162408e0ce9b 100644
--- a/include/debug_descriptor.h
+++ b/include/debug_descriptor.h
@@ -44,6 +44,7 @@ struct debug_descriptor {
 	u64	trace_phys[DEBUG_DESC_MAX_TRACES];
 	u32	trace_size[DEBUG_DESC_MAX_TRACES];
 	u32	trace_tce[DEBUG_DESC_MAX_TRACES];
+	u16	trace_cpu[DEBUG_DESC_MAX_TRACES];
 };
 extern struct debug_descriptor debug_descriptor;
 
-- 
2.20.1



More information about the Skiboot mailing list