Linux -- profile -- general Linux technology-Linux programming and kernel information. The following is a detailed description. Kernel version 2.6.18-RC7
Profile is only a tool for kernel debugging performance, which can be opened through Instrumentation Support> profile in menuconfig.
1. How to Use profile:
First confirm that the kernel supports profile, and then add the following parameters when the kernel starts: profile = 1 or other parameters. The new kernel supports profile = schedule 1.
2. After the kernel is started, the/proc/profile file will be created, which can be read through readprofile,
For example, readprofile-m/proc/kallsyms | sort-nr> ~ /Cur_profile.log,
Or readprofile-r-m/proc/kallsyms | sort-nr,
Or readprofile-r & sleep 1 & readprofile-m/proc/kallsyms | sort-nr> ~ /Cur_profile.log
3. What can be obtained by reading/proc/profile?
Configure profile =? Based on startup? Different, the obtained content is different:
If it is configured as profile =? The number of function executions can be obtained, which is useful for debugging function performance.
If it is set to profile = schedule? The number of times each function calls schedule. It is useful for debugging schedule.
Profile implementation:
Create a/proc/profile interface in the kernel and use profile_init () to allocate the memory for storing profile information at system startup. Each Command has a counter.
If profile =? Count the number of times each command is executed. Call profile_tick (CPU_PROFILING, regs) during the clock interruption and add the eip Count value of the current command regs-> 1. This statistics is a bit inaccurate, because a jiffies may execute many functions, but only the function that happens when the clock is interrupted. However, if there are too many sampling points, this information can still explain the problem.
If profile = schedule? Count the number of times each command calls schedule (), and call profile_hit (SCHED_PROFILING, _ builtin_return_address (0) in schedule ));
In fact, there are only a few commands that actually call schedule, but the information can obtain the precise information of the scheduling point.
Profile_hit () is used to add 1 to the Count value of the current command.
Profile_tick () is to add 1 to the Count value of the response command when every clock tick
Time_hook is generally used by other profile tools, such as oprofile, to add processing functions each time an interruption occurs.
Profile information actually includes all statistics of the task. Therefore, you can use profile_event_register () to mount your own callback function when the task exits or the user space memory is released to collect statistics.
Profile statistics vary with smp and up, that is, the profile_hit implementation is different. The smp implementation has a PerCPU cache, which can avoid the issue of inefficient statistics of multiple CPUs on profile. For more information, see the source code kernel/profile. c and the implementation of driver/oprofile.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service