tools/testing/selftests/mm/on-fault-limit.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/on-fault-limit.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/on-fault-limit.c- Extension
.c- Size
- 934 bytes
- Lines
- 43
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/mman.hstdio.hunistd.hstring.hsys/time.hsys/resource.hkselftest.h
Detected Declarations
function test_limitfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <sys/mman.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "kselftest.h"
static void test_limit(void)
{
struct rlimit lims;
void *map;
if (getrlimit(RLIMIT_MEMLOCK, &lims))
ksft_exit_fail_msg("getrlimit: %s\n", strerror(errno));
if (mlockall(MCL_ONFAULT | MCL_FUTURE))
ksft_exit_fail_msg("mlockall: %s\n", strerror(errno));
map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
ksft_test_result(map == MAP_FAILED, "The map failed respecting mlock limits\n");
if (map != MAP_FAILED)
munmap(map, 2 * lims.rlim_max);
munlockall();
}
int main(int argc, char **argv)
{
ksft_print_header();
ksft_set_plan(1);
if (!getuid())
ksft_test_result_skip("The test must be run from a normal user\n");
else
test_limit();
ksft_finished();
}
Annotation
- Immediate include surface: `sys/mman.h`, `stdio.h`, `unistd.h`, `string.h`, `sys/time.h`, `sys/resource.h`, `kselftest.h`.
- Detected declarations: `function test_limit`, `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.