Tree:
3d875f77f3
master
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
033-502
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
RHEL-7.1
RHEL-7.2
${ noResults }
1 Commits (3d875f77f3d1c5e4161794ca59025bc6bcd77eaa)
Author | SHA1 | Message | Date |
---|---|---|---|
![]() |
34986d538a |
99base: add memtrace-ko.sh to debug kernel module large memory consumption
The current method for memory debug is to use "rd.memdebug=[0-3]", it is not enough for debugging kernel modules. For example, when we want to find out which kernel module consumes a large amount of memory, "rd.memdebug=[0-3]" won't help too much. A better way is needed to achieve this requirement, this is useful for kdump OOM debugging. The principle of this patch is to use kernel trace to track slab and buddy allocation calls during kernel module loading(module_init), thus we can analyze all the trace data and get the total memory consumption. As for large slab allocation, it will probably fall into buddy allocation, thus tracing "mm_page_alloc" alone should be enough for the purpose(this saves quite some trace buffer memory, also large free is quite unlikey during module loading, we neglect those memory free events). The trace events include memory calls under "tracing/events/": kmem/mm_page_alloc We also inpect the following events to detect the module loading: module/module_load module/module_put Since we use filters to trace events, the final trace data size won't be too big. Users can adjust the trace buffer size via "trace_buf_size" kernel boot command line as needed. We can get the module name and task pid from "module_load" event which also mark the beginning of the loading, and module_put called by the same task pid implies the end of the loading. So the memory events recorded in between by the same task pid are consumed by this module during loading(i.e. modprobe or module_init()). With these information, we can record the rough total memory(the larger, the more precise the result will be) consumption involved by each kernel module loading. Thus we introduce this shell script to find out which kernel module consumes a large amount of memory during loading. Use "rd.memdebug=4" as the tigger. After applying this patch and specifying "rd.memdebug=4", during booting it will print out something extra like below: 0 pages consumed by "pata_acpi" 0 pages consumed by "ata_generic" 1 pages consumed by "drm" 0 pages consumed by "ttm" 0 pages consumed by "drm_kms_helper" 835 pages consumed by "qxl" 0 pages consumed by "mii" 6 pages consumed by "8139cp" 0 pages consumed by "virtio" 0 pages consumed by "virtio_ring" 9 pages consumed by "virtio_pci" 1 pages consumed by "8139too" 0 pages consumed by "serio_raw" 0 pages consumed by "crc32c_intel" 199 pages consumed by "virtio_console" 0 pages consumed by "libcrc32c" 9 pages consumed by "xfs" From the print, we see clearly that "qxl" consumed the most memory. This file will be installed as a separate executable named "tracekomem" in the following patch. Signed-off-by: Xunlei Pang <xlpang@redhat.com> |
8 years ago |