Created on
‎09-20-2023
10:36 AM
Edited on
‎10-02-2024
03:49 AM
By
Anthony_E
Description | This article describes how to perform CPU profiling. |
Scope | FortiGate v7.0 and above, |
Solution |
The idea of CPU profiling is to single out a singular CPU core and see what processes this core is calling. This can give insight into what the core is busy with.
Check the CPU usage with the command 'get sys performance status'.
CPU states: 0% user 99% system 0% nice 1% idle 0% iowait 0% irq 0% softirq
get sys stat diagnose sys top 5 20 99999 <----- This shows us what processes are most active and can give a lead on processes that might be responsible.
get sys stat diagnose sys mpstat 5 99999 <----- This shows the usage similar to what 'get sys performance status' shows just over time.
Especially on larger machines with more CPU cores, this lets check if only one or more CPU cores are affected and if the issue is moving from one core to another, or if the issue is static to one or more cores.
Note that the commands 'get sys stat' and 'get sys perf stat' are essential here to be included. They contain the current time (for example 'System time: Tue Sep 24 10:28:33 2024') and the current uptime (for example 'Uptime: 77 days, 15 hours, 2 minutes'). This is required to correlate the 'top' and the 'mpstat' commands as the top commands only contain the uptime but no absolute time.
Otherwise, it is not possible to match a high CPU spike in user space as seen in the top command with the output of mpstat or other debugs.
fnsysctl date diagnose sys profile report
0xffffffc000487130: 51 rijndaelDecrypt+0x5f0/0xc70
There are cases where the CPU usage is spiky. In these instances, collecting logs by manually selecting a CPU core is simply too slow. Here, the command diagnose sys profile report can be used. It will profile all of the CPU cores for a very short period. The disadvantage when compared to the manual selection is that the functions will be added together into a singular table.
diagnose sys profile report CPU Kernel Percentages: 0: 52% (52 of 100). Will profile. 1: 51% (51 of 100). Will profile. Kernel=0xffffffff80200190-0xffffffff80625dbd, module-gap=0x1f9da243 Profile buffer: profile step=4, sz=13046916-3261729, last-addr=0xffffffffa084b857 warning: functions cannot be profiled properly, early_idt_handlers-_einittext 0xffffffff80208408: 50 mwait_idle+0x58/0x80 0xffffffffa004ec37: 28 __ipsec_tunnel_flush_sa+0x5a7/0x6f0 0xffffffff802650b8: 22 local_bh_enable+0x28/0xa0
Related document: |