Why Is "perf_event mmap failed..." Displayed?
Symptom
This error is generally displayed in the standard output of JVM. When a user uses the Profiler function to collect CPU hotspot samples, both native (Linux kernel + JVM + C/C++) and Java stacks will be collected. To collect native stacks, the system will implement memory map (MMap) for the perf_event file descriptor (FD) of each Java thread. The Linux kernel limits the total memory of MMap related to perf_event (516 KB by default). When there are a large number of Java threads, the limit is triggered and the warning "perf_event mmap failed..." is printed in the Java standard output. This warning will not impact Java running or services. The only impact is that the native stacks cannot be viewed in the flame graph. Generally, when locating CPU hotspot problems, you only need to view the Java method stacks. Therefore, this warning can be ignored.
Solution
To solve this warning, perform the following steps:
- Run the following commands on the server:
echo 1028 > /proc/sys/kernel/perf_event_mlock_kb
The default threshold is 516. Gradually increase the value until the warning is not displayed. If possible, the value should meet the following requirement: 8 × N + 4 (where N is a natural number). For example, 516 = 512 + 4 or 1,028 = 1,024 + 4.
- Restart the Docker. The problem can then be solved.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot