tools/testing/selftests/mm/hugepage-mmap.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/hugepage-mmap.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/hugepage-mmap.c- Extension
.c- Size
- 1696 bytes
- Lines
- 79
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source 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.
Dependency Surface
stdlib.hstdio.hunistd.hsys/mman.hfcntl.hkselftest.h
Detected Declarations
function filesystemfunction write_bytesfunction read_bytesfunction main
Annotated Snippet
if (*(addr + i) != (char)i) {
ksft_print_msg("Error: Mismatch at %lu\n", i);
return 1;
}
return 0;
}
int main(void)
{
void *addr;
int fd, ret;
ksft_print_header();
ksft_set_plan(1);
fd = memfd_create("hugepage-mmap", MFD_HUGETLB);
if (fd < 0)
ksft_exit_fail_msg("memfd_create() failed: %s\n", strerror(errno));
addr = mmap(NULL, LENGTH, PROTECTION, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED) {
close(fd);
ksft_exit_fail_msg("mmap(): %s\n", strerror(errno));
}
ksft_print_msg("Returned address is %p\n", addr);
check_bytes(addr);
write_bytes(addr);
ret = read_bytes(addr);
munmap(addr, LENGTH);
close(fd);
ksft_test_result(!ret, "Read same data\n");
ksft_exit(!ret);
}
Annotation
- Immediate include surface: `stdlib.h`, `stdio.h`, `unistd.h`, `sys/mman.h`, `fcntl.h`, `kselftest.h`.
- Detected declarations: `function filesystem`, `function write_bytes`, `function read_bytes`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source 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.