Kernel memory leak detector (updated)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest11 patches 25 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/11 | kmemleak: Add the base supportinclude/ init/ mm/ | +1075 | 10 replies | |
| 2/11 | kmemleak: Add documentation on the memory leak detectorDocumentation/ | +125 | 0 replies | |
| 3/11 | kmemleak: Add the memory allocation/freeing hooksmm/ mm/ mm/ +2 more | +48 | 7 replies | |
| 4/11 | kmemleak: Add modules supportkernel/ | +50 | 1 reply | |
| 5/11 | kmemleak: Add support for i386arch/ | +1 | 1 reply | |
| 6/11 | kmemleak: Add support for ARMarch/ | +2 | 0 replies | |
| 7/11 | kmemleak: Remove some of the kmemleak false positivesdrivers/ include/ | +10 | 1 reply | |
| 8/11 | kmemleak: Enable the building of the memory leak detectorlib/ mm/ | +24 | 0 replies | |
| 9/11 | kmemleak: Keep the __init functions after initializationinclude/ lib/ | +18 | 0 replies | |
| 10/11 | kmemleak: Simple testing module for kmemleaklib/ mm/ mm/ | +114 | 1 reply | |
| 11/11 | kmemleak: Add the corresponding MAINTAINERS entryMAINTAINERS | +6 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 2.6.28-rc5 00/11] Kernel memory leak detector (updated)
The kmemleak (visible) activity has been pretty quite for the past year. I've actually been working on implementing some of the comments received, adding support for slob and slub allocators and trying it on various kernel versions. I found myself spending significant amount of time on identifying false positives caused by pointer aliasing. Because of that, I decided to track incoming pointers to any location inside an allocated block rather than just the aliases, leading to cleaner code and without many annotations for false positives.
Kmemleak can also be found in a branh on this git tree:
git://linux-arm.org/linux-2.6.git kmemleak
The main changes (for those who remember the original features):
- it now uses a priority search tree to make it easier for looking up intervals rather than just fixed values (the initial implementation was with radix tree and changed to hash array because of kmem_cache_alloc calls in the former)
- internal memory allocator to avoid recursive calls into kmemleak. This is a simple lock-free, per-cpu allocator using pages. The number of pages allocated is bounded, though there could be (very unlikely) situations on SMP systems where page occupation isn't optimal
- support for all three memory allocators - slab, slob and slub
- finer-grained locking - there is no global lock held during memory scanning
- more information reported for leaked objects - current task's command line and pid, jiffies and the stack trace
Things still to be done:
- kernel thread to scan and report leaked objects periodically (currently done only when reading the /sys/kernel/debug/memleak file)
- run-time and boot-time configuration like task stacks scanning, disabling kmemleak, enabling/disabling the automatic scanning
An improvement in scanning time and false negatives would be to only scan locations containing outgoing pointers. I did some tests (not finished yet) to automatically ignore, in subsequent scans, areas of memory that were found not to contain pointer-like values (or NULL) during a first scan.
Thanks for your comments.
Catalin Marinas (11):
kmemleak: Add the corresponding MAINTAINERS entry
kmemleak: Simple testing module for kmemleak
kmemleak: Keep the __init functions after initialization
kmemleak: Enable the building of the memory leak detector
kmemleak: Remove some of the kmemleak false positives
kmemleak: Add support for ARM
kmemleak: Add support for i386
kmemleak: Add modules support
kmemleak: Add the memory allocation/freeing hooks
kmemleak: Add documentation on the memory leak detector
kmemleak: Add the base support
Documentation/kmemleak.txt | 125 +++++ MAINTAINERS | 6 arch/arm/kernel/vmlinux.lds.S | 2 arch/x86/kernel/vmlinux_32.lds.S | 1 drivers/char/vt.c | 5 include/linux/init.h | 6 include/linux/memleak.h | 60 ++ include/linux/percpu.h | 5 init/main.c | 4 kernel/module.c | 50 ++ lib/Kconfig.debug | 46 ++ mm/Makefile | 2 mm/memleak-test.c | 102 ++++ mm/memleak.c | 1012 ++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 3 mm/slab.c | 9 mm/slob.c | 15 - mm/slub.c | 3 mm/vmalloc.c | 25 + 19 files changed, 1473 insertions(+), 8 deletions(-) create mode 100644 Documentation/kmemleak.txt create mode 100644 include/linux/memleak.h create mode 100644 mm/memleak-test.c create mode 100644 mm/memleak.c
Signature · 1 line
Catalin