diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 16:09:51 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 16:09:51 -0400 |
| commit | b3fec0fe35a4ff048484f1408385a27695d4273b (patch) | |
| tree | 088c23f098421ea681d9976a83aad73d15be1027 | |
| parent | e1f5b94fd0c93c3e27ede88b7ab652d086dc960f (diff) | |
| parent | 722f2a6c87f34ee0fd0130a8cf45f81e0705594a (diff) | |
Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard/kmemcheck
* 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard/kmemcheck: (39 commits)
signal: fix __send_signal() false positive kmemcheck warning
fs: fix do_mount_root() false positive kmemcheck warning
fs: introduce __getname_gfp()
trace: annotate bitfields in struct ring_buffer_event
net: annotate struct sock bitfield
c2port: annotate bitfield for kmemcheck
net: annotate inet_timewait_sock bitfields
ieee1394/csr1212: fix false positive kmemcheck report
ieee1394: annotate bitfield
net: annotate bitfields in struct inet_sock
net: use kmemcheck bitfields API for skbuff
kmemcheck: introduce bitfield API
kmemcheck: add opcode self-testing at boot
x86: unify pte_hidden
x86: make _PAGE_HIDDEN conditional
kmemcheck: make kconfig accessible for other architectures
kmemcheck: enable in the x86 Kconfig
kmemcheck: add hooks for the page allocator
kmemcheck: add hooks for page- and sg-dma-mappings
kmemcheck: don't track page tables
...
71 files changed, 2899 insertions, 128 deletions
diff --git a/Documentation/kmemcheck.txt b/Documentation/kmemcheck.txt new file mode 100644 index 000000000000..363044609dad --- /dev/null +++ b/Documentation/kmemcheck.txt | |||
| @@ -0,0 +1,773 @@ | |||
| 1 | GETTING STARTED WITH KMEMCHECK | ||
| 2 | ============================== | ||
| 3 | |||
| 4 | Vegard Nossum <vegardno@ifi.uio.no> | ||
| 5 | |||
| 6 | |||
| 7 | Contents | ||
| 8 | ======== | ||
| 9 | 0. Introduction | ||
| 10 | 1. Downloading | ||
| 11 | 2. Configuring and compiling | ||
| 12 | 3. How to use | ||
| 13 | 3.1. Booting | ||
| 14 | 3.2. Run-time enable/disable | ||
| 15 | 3.3. Debugging | ||
| 16 | 3.4. Annotating false positives | ||
| 17 | 4. Reporting errors | ||
| 18 | 5. Technical description | ||
| 19 | |||
| 20 | |||
| 21 | 0. Introduction | ||
| 22 | =============== | ||
| 23 | |||
| 24 | kmemcheck is a debugging feature for the Linux Kernel. More specifically, it | ||
| 25 | is a dynamic checker that detects and warns about some uses of uninitialized | ||
| 26 | memory. | ||
| 27 | |||
| 28 | Userspace programmers might be familiar with Valgrind's memcheck. The main | ||
| 29 | difference between memcheck and kmemcheck is that memcheck works for userspace | ||
| 30 | programs only, and kmemcheck works for the kernel only. The implementations | ||
| 31 | are of course vastly different. Because of this, kmemcheck is not as accurate | ||
| 32 | as memcheck, but it turns out to be good enough in practice to discover real | ||
| 33 | programmer errors that the compiler is not able to find through static | ||
| 34 | analysis. | ||
| 35 | |||
| 36 | Enabling kmemcheck on a kernel will probably slow it down to the extent that | ||
| 37 | the machine will not be usable for normal workloads such as e.g. an | ||
| 38 | interactive desktop. kmemcheck will also cause the kernel to use about twice | ||
| 39 | as much memory as normal. For this reason, kmemcheck is strictly a debugging | ||
| 40 | feature. | ||
| 41 | |||
| 42 | |||
| 43 | 1. Downloading | ||
| 44 | ============== | ||
| 45 | |||
| 46 | kmemcheck can only be downloaded using git. If you want to write patches | ||
| 47 | against the current code, you should use the kmemcheck development branch of | ||
| 48 | the tip tree. It is also possible to use the linux-next tree, which also | ||
| 49 | includes the latest version of kmemcheck. | ||
| 50 | |||
| 51 | Assuming that you've already cloned the linux-2.6.git repository, all you | ||
| 52 | have to do is add the -tip tree as a remote, like this: | ||
| 53 | |||
| 54 | $ git remote add tip git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git | ||
| 55 | |||
| 56 | To actually download the tree, fetch the remote: | ||
| 57 | |||
| 58 | $ git fetch tip | ||
| 59 | |||
| 60 | And to check out a new local branch with the kmemcheck code: | ||
| 61 | |||
| 62 | $ git checkout -b kmemcheck tip/kmemcheck | ||
| 63 | |||
| 64 | General instructions for the -tip tree can be found here: | ||
| 65 | http://people.redhat.com/mingo/tip.git/readme.txt | ||
| 66 | |||
| 67 | |||
| 68 | 2. Configuring and compiling | ||
| 69 | ============================ | ||
| 70 | |||
| 71 | kmemcheck only works for the x86 (both 32- and 64-bit) platform. A number of | ||
| 72 | configuration variables must have specific settings in order for the kmemcheck | ||
| 73 | menu to even appear in "menuconfig". These are: | ||
| 74 | |||
| 75 | o CONFIG_CC_OPTIMIZE_FOR_SIZE=n | ||
| 76 | |||
| 77 | This option is located under "General setup" / "Optimize for size". | ||
| 78 | |||
| 79 | Without this, gcc will use certain optimizations that usually lead to | ||
| 80 | false positive warnings from kmemcheck. An example of this is a 16-bit | ||
| 81 | field in a struct, where gcc may load 32 bits, then discard the upper | ||
