[Skiboot] [PATCH 05/22] external/trace: Fall back to read()
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Fri Jun 25 16:19:20 AEST 2021
From: Oliver O'Halloran <oohall at gmail.com>
Not all kernels support mmap() on an OPAL exported memory range. Fall
back to allocating a buffer and using the normal file IO system calls
to read the contents of the trace buffer in those cases.
This does mean we can't use "follow" mode since we can't monitor the
raw trace data effectively, but otherwise it works fine.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
external/trace/dump_trace.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/external/trace/dump_trace.c b/external/trace/dump_trace.c
index aba684b5b..5a832c791 100644
--- a/external/trace/dump_trace.c
+++ b/external/trace/dump_trace.c
@@ -261,6 +261,7 @@ int main(int argc, char *argv[])
{
struct trace_reader *trs;
struct trace_info *ti;
+ bool no_mmap = false;
struct stat sb;
int fd, opt, i;
@@ -296,13 +297,26 @@ int main(int argc, char *argv[])
err(1, "Stating %s", argv[1]);
ti = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (ti == MAP_FAILED)
- err(1, "Mmaping %s", argv[i]);
+ if (ti == MAP_FAILED) {
+ no_mmap = true;
+
+ ti = ezalloc(sb.st_size);
+ if (!ti)
+ err(1, "allocating memory for %s", argv[i]);
+
+ if (read(fd, ti, sb.st_size) == -1)
+ err(1, "reading from %s", argv[i]);
+ }
trs[i].tb = &ti->tb;
list_head_init(&trs[i].traces);
}
+ if (no_mmap) {
+ fprintf(stderr, "disabling follow mode: can't mmap() OPAL export files\n");
+ follow = 0;
+ }
+
do {
load_traces(trs, argc);
display_traces(trs, argc);
--
2.31.1
More information about the Skiboot
mailing list