samples/kmemleak/kmemleak-test.c
Source file repositories/reference/linux-study-clean/samples/kmemleak/kmemleak-test.c
File Facts
- System
- Linux kernel
- Corpus path
samples/kmemleak/kmemleak-test.c- Extension
.c- Size
- 2818 bytes
- Lines
- 103
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/vmalloc.hlinux/list.hlinux/percpu.hlinux/fdtable.hlinux/kmemleak.h
Detected Declarations
struct test_nodefunction kmemleak_test_initfunction for_each_possible_cpufunction kmemleak_test_exitmodule init kmemleak_test_init
Annotated Snippet
module_init(kmemleak_test_init);
static void __exit kmemleak_test_exit(void)
{
struct test_node *elem, *tmp;
/*
* Remove the list elements without actually freeing the
* memory.
*/
list_for_each_entry_safe(elem, tmp, &test_list, list)
list_del(&elem->list);
}
module_exit(kmemleak_test_exit);
MODULE_DESCRIPTION("Sample module to leak memory for kmemleak testing");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/list.h`, `linux/percpu.h`, `linux/fdtable.h`.
- Detected declarations: `struct test_node`, `function kmemleak_test_init`, `function for_each_possible_cpu`, `function kmemleak_test_exit`, `module init kmemleak_test_init`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.