This patch switches from moving the performance counter file descriptor to the child process to socket calls rather than using the pidfd_getfd system call which was introduced in kernel 5.6. This significantly expands the range of kernel versions that are supported.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | ||
---|---|---|
205 | I think this is technically UB in C++ (it violates strict aliasing). I'd be more comfortable with memcpy(CMSG_DATA(ControlMessage)), FD, sizeof(FD));, which does the same thing while having defined semantics. | |
232 | I'm not sure you cant just read 4 bytes from the message unconditionally, you need to check that they are indeed available by checking cmsg_len. struct cmsghdr { socklen_t cmsg_len; /* data byte count, including header */ ... }; | |
233 | Ditto: int FD; mempcy(&FD, RawData, sizeof(FD)); |
Reminder that please make sure a reviewed commit has Differential Revision:. If you use arc diff 'HEAD^' to upload a differential, you'll get this automatically.
I typically run arc amend before pushing to get Reviewed By:
@MaskRay Did you mean to post that on another patch? This one hasn't landed yet. There are also a couple minor patches that I committed without review that added preprocessor directives/very minor fixes related to kernel versioning to fix some build configurations that broke.
@courbet This should be ready for another round of review when you have time. Thanks!
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | ||
---|---|---|
205 | Thanks for the suggestion! I definitely wasn't particularly happy with that level of casting, not sure why a memcpy didn't come up to me. That is definitely a lot cleaner and avoids the UB (and compiler warning). |
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | ||
---|---|---|
224 | Should be ssize_t ? The BytesRead < 0 check below is currently always false since size_t is unsigned. I noticed this when I compiled with gcc which warned ../tools/llvm-exegesis/lib/BenchmarkRunner.cpp:226:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] 226 | if (BytesRead < 0) | ~~~~~~~~~~^~~ |
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | ||
---|---|---|
224 | Yep. Thanks for pointing this out! Not sure how I missed it. recvmsg definitely returns ssize_t. Fixed in 34e3bc0b92d7fdc59477c93d187546a2566fbc22. |
I think this is technically UB in C++ (it violates strict aliasing). I'd be more comfortable with memcpy(CMSG_DATA(ControlMessage)), FD, sizeof(FD));, which does the same thing while having defined semantics.