From 52505ca380baf99220e2fdc63e26f5b15b018569 Mon Sep 17 00:00:00 2001 From: Charlie Curtsinger Date: Tue, 8 Oct 2019 09:56:51 -0500 Subject: [PATCH] Clearer error message for perf mmap failure --- libcoz/perf.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcoz/perf.cpp b/libcoz/perf.cpp index 9a0c94e..e6e747f 100644 --- a/libcoz/perf.cpp +++ b/libcoz/perf.cpp @@ -76,7 +76,9 @@ perf_event::perf_event(struct perf_event_attr& pe, pid_t pid, int cpu) : // If sampling, map the perf event file if(pe.sample_type != 0 && pe.sample_period != 0) { void* ring_buffer = mmap(NULL, MmapSize, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, 0); - REQUIRE(ring_buffer != MAP_FAILED) << "Failed to mmap perf event file"; + REQUIRE(ring_buffer != MAP_FAILED) << "Mapping perf_event ring buffer failed. " + << "Make sure the current user has permission to invoke the perf tool, and that " + << "the program being profiled does not use an excessive number of threads (>1000).\n"; _mapping = reinterpret_cast(ring_buffer); }