[llvm-exegesis][NFCI] Counter::Counter(): more useful msg on event open error

Summary:
I'm slowly looking into a new X86 scheduler model,
for AMD Bulldozer CPU, model 2 (bdver2, Piledriver).

And naturally, i have hit that assert :)
I happened to know what it meant, and how to fix it,
but that is not too common knowledge.

Reviewers: courbet, RKSimon

Reviewed By: courbet

Subscribers: tschuett, llvm-commits, craig.topper

Differential Revision: https://reviews.llvm.org/D47572

llvm-svn: 333632
This commit is contained in:
Roman Lebedev 2018-05-31 07:08:26 +00:00
parent c0ecd06428
commit 71d4afb90a
1 changed files with 6 additions and 3 deletions

View File

@ -96,9 +96,12 @@ Counter::Counter(const PerfEvent &Event) {
const uint32_t Flags = 0;
perf_event_attr AttrCopy = *Event.attribute();
FileDescriptor = perf_event_open(&AttrCopy, Pid, Cpu, GroupFd, Flags);
assert(FileDescriptor != -1 &&
"Unable to open event, make sure your kernel allows user space perf "
"monitoring.");
if (FileDescriptor == -1) {
llvm::errs() << "Unable to open event, make sure your kernel allows user "
"space perf monitoring.\nYou may want to try:\n$ sudo sh "
"-c 'echo -1 > /proc/sys/kernel/perf_event_paranoid'\n";
}
assert(FileDescriptor != -1 && "Unable to open event");
}
Counter::~Counter() { close(FileDescriptor); }