[Skiboot] [PATCH 06/15] core/trace: Change trace buffer size

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


For mmaping it makes sense for the trace buffer to fit on a page. This
is slightly complicated by the space taken up by the header at the
beginning of the trace and by the different sized elements that need to
be accommodated in the buffer. This is taken into account so that it
will fit on a 64K page.
---
 core/test/run-trace.c | 2 +-
 core/trace.c          | 2 --
 include/trace.h       | 4 +++-
 include/trace_types.h | 2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/core/test/run-trace.c b/core/test/run-trace.c
index e53ab30ddf69..1455394da0e6 100644
--- a/core/test/run-trace.c
+++ b/core/test/run-trace.c
@@ -133,7 +133,7 @@ static struct cpu_thread *this_cpu(void)
 }
 
 #include <sys/mman.h>
-#define PER_CHILD_TRACES ((RUNNING_ON_VALGRIND) ? (1024*16) : (1024*1024))
+#define PER_CHILD_TRACES TBUF_SZ
 
 static void write_trace_entries(int id)
 {
diff --git a/core/trace.c b/core/trace.c
index 8e231b32eaa4..5580eb13a8bd 100644
--- a/core/trace.c
+++ b/core/trace.c
@@ -29,8 +29,6 @@
 
 #define DEBUG_TRACES
 
-#define MAX_SIZE (sizeof(union trace) + 7)
-
 /* Smaller trace buffer for early booting */
 static struct {
 	struct trace_info trace_info;
diff --git a/include/trace.h b/include/trace.h
index 2b65e9075591..68afa28355d8 100644
--- a/include/trace.h
+++ b/include/trace.h
@@ -16,12 +16,12 @@
 
 #ifndef __TRACE_H
 #define __TRACE_H
+#include <skiboot.h>
 #include <ccan/short_types/short_types.h>
 #include <stddef.h>
 #include <lock.h>
 #include <trace_types.h>
 
-#define TBUF_SZ (1024 * 1024)
 
 struct cpu_thread;
 
@@ -35,6 +35,8 @@ struct trace_info {
 	struct tracebuf tb;
 };
 
+#define TBUF_SZ ALIGN_DOWN((0x10000 - sizeof(struct trace_info) - MAX_SIZE), 0x10)
+
 /* Allocate trace buffers once we know memory topology */
 void init_trace_buffers(void);
 
diff --git a/include/trace_types.h b/include/trace_types.h
index d14c78d2eed6..9364186aedbe 100644
--- a/include/trace_types.h
+++ b/include/trace_types.h
@@ -129,4 +129,6 @@ union trace {
 	struct trace_uart uart;
 };
 
+#define MAX_SIZE (sizeof(union trace) + 7)
+
 #endif /* __TRACE_TYPES_H */
-- 
2.20.1



More information about the Skiboot mailing list