Go to file
Xunlei Pang 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>
2016-11-27 12:09:10 +08:00
dracut.conf.d add --no-reproducible to turn off reproducible mode 2015-11-13 11:53:36 +01:00
install dracut-install: preserve extended attributes when copying files 2016-10-25 22:05:55 +02:00
modules.d 99base: add memtrace-ko.sh to debug kernel module large memory consumption 2016-11-27 12:09:10 +08:00
skipcpio skipcpio/skipcpio.c: linux kernel only accepts "070701" signature 2015-07-07 13:44:13 +02:00
test testsuite: add "-cpu host" to kvm call 2016-11-14 16:21:06 +01:00
.dir-locals.el dir-locals: Avoid use of setq which triggers Emacs warning 2015-09-17 11:33:40 -04:00
.gitignore .gitignore: ignore more files 2013-04-16 13:38:16 +02:00
.kateconfig add kate and emacs per directory config files 2014-08-29 13:38:47 +02:00
.kateproject kate config 2016-04-15 10:27:48 +02:00
.mailmap AUTHORS and .mailmap update 2015-01-08 13:26:52 +01:00
50-dracut.install 50-dracut.install: use /bin/bash shebang 2016-11-04 13:09:28 -04:00
51-dracut-rescue-postinst.sh use cp --reflink=auto 2015-05-13 12:02:10 +02:00
51-dracut-rescue.install rescue: use proper path for 0-rescue.conf 2016-10-19 12:22:54 +09:00
AUTHORS AUTHORS: update 2015-11-25 14:22:28 +01:00
COPYING COPYING: updated to recent version of http://www.gnu.org/licenses/gpl-2.0.txt 2012-08-01 15:53:25 +02:00
HACKING removed trailing whitespaces 2011-05-10 11:56:09 +02:00
Makefile Makefile: fixed DESTDIR in rpm target 2016-11-07 17:52:09 +01:00
NEWS NEWS: update for 045 2016-11-07 11:01:36 +01:00
PKGBUILD PKGFILE: prevent out of tree builds 2015-11-08 12:57:33 +01:00
README README: update 2016-11-03 14:54:45 +01:00
README.generic removed trailing whitespaces 2011-05-10 11:56:09 +02:00
README.kernel
README.md README.md: change centosci badge 2016-11-14 13:51:59 +01:00
README.modules consistently lowercase "dracut" 2012-10-10 14:15:11 +02:00
README.testsuite README.testsuite: add dmraid 2016-11-10 10:56:06 +01:00
TODO TODO: remove some items 2016-11-03 15:05:36 +01:00
configure configure: don't hardcode pkg-config 2016-05-04 10:18:54 +02:00
dracut-bash-completion.sh dracut.sh: add support for creating a UEFI boot executable 2015-03-20 14:31:23 +01:00
dracut-catimages.8.asc replace xml documentation with asciidoc 2012-03-14 15:48:33 +01:00
dracut-catimages.sh remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
dracut-functions.sh dracut-functions.sh: catch all lvm slaves 2016-08-19 15:49:33 +02:00
dracut-init.sh dracut-init.sh: set default firmware path, if not specified 2016-06-07 14:27:03 +02:00
dracut-initramfs-restore.sh dracut-initramfs-restore: make mount error nonfatal 2015-07-28 15:04:56 +02:00
dracut-logger.sh dracut.sh: only create one TMPDIR 2015-11-25 14:21:33 +01:00
dracut.8.asc dracut.8: document INITRD_COMPRESS environment variable 2016-11-02 13:49:17 +01:00
dracut.asc documentation: line wrap 2014-01-13 09:51:04 +01:00
dracut.bootup.7.asc documentation: line wrap 2014-01-13 09:51:04 +01:00
dracut.cmdline.7.asc dracut.cmdline.7.asc: document rd.shell=0 for rd.emergency 2016-08-19 15:49:33 +02:00
dracut.conf dracut.conf: remove example parameters 2015-07-09 15:36:25 +02:00
dracut.conf.5.asc dracut.conf.5.asc: remove duplicate i18n_install_all option 2016-07-20 18:24:39 +09:00
dracut.css Doc: cleanup, extend and split and reuse 2013-10-08 15:13:12 +02:00
dracut.logrotate dracut.logrotate: remove "yearly" 2011-07-20 17:21:02 +02:00
dracut.modules.7.asc doc: fix typo 2015-06-02 12:05:21 +02:00
dracut.png dracut.png: Optimize with zopflipng -m 2016-07-07 13:54:47 +03:00
dracut.sh dracut.sh: create the initramfs non-world readable also if early cpio is used 2016-11-07 10:41:38 +01:00
dracut.spec dracut.spec: add systemd-udev requirement 2016-11-11 16:04:09 +01:00
dracut.svg
dracut.usage.asc man page: changed grub.conf to grub2.cfg 2015-11-11 15:47:46 +01:00
git2spec.pl Makefile,git2spec.pl: use "git describe" 2013-04-12 15:27:27 +02:00
lsinitrd-bash-completion.sh remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
lsinitrd.1.asc lsinitrd: add "--unpack" to lsinitrd 2016-03-17 14:45:24 +01:00
lsinitrd.sh lsinitrd.sh: fixed unpack and skipcpio search 2016-04-11 15:24:01 +02:00
mkinitrd-dracut.sh mkinitrd-dracut.sh: removed trailing space in comment 2013-10-07 17:25:58 +02:00
mkinitrd-suse.8.asc mkinitrd-suse: Update to sles12 SUSE state 2014-12-16 13:29:35 +01:00
mkinitrd-suse.sh Use the uncompressed kernel file on arm and aarch to detect kernel version 2015-07-07 13:44:24 +02:00
mkinitrd.8.asc documentation: line wrap 2014-01-13 09:51:04 +01:00
profile.py profile.py: do not count negative timestamp differences 2012-06-29 12:41:25 +02:00

README.md

dracut - master branch

dracut is an initramfs infrastructure.

CentOS CI: Build Status