tools/testing/selftests/mm/gup_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/gup_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/gup_test.c- Extension
.c- Size
- 6028 bytes
- Lines
- 261
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.herrno.hstdio.hstdlib.hunistd.hdirent.hsys/ioctl.hsys/mman.hsys/stat.hsys/types.hpthread.hassert.hmm/gup_test.hkselftest.hvm_util.h
Detected Declarations
function main
Annotated Snippet
switch (opt) {
case 'a':
cmd = PIN_FAST_BENCHMARK;
break;
case 'b':
cmd = PIN_BASIC_TEST;
break;
case 'L':
cmd = PIN_LONGTERM_BENCHMARK;
break;
case 'c':
cmd = DUMP_USER_PAGES_TEST;
/*
* Dump page 0 (index 1). May be overridden later, by
* user's non-option arguments.
*
* .which_pages is zero-based, so that zero can mean "do
* nothing".
*/
gup.which_pages[0] = 1;
break;
case 'p':
/* works only with DUMP_USER_PAGES_TEST */
gup.test_flags |= GUP_TEST_FLAG_DUMP_PAGES_USE_PIN;
break;
case 'F':
/* strtol, so you can pass flags in hex form */
gup.gup_flags = strtol(optarg, 0, 0);
break;
case 'j':
nthreads = atoi(optarg);
break;
case 'm':
size = atoi(optarg) * MB;
break;
case 'r':
repeats = atoi(optarg);
break;
case 'n':
nr_pages = atoi(optarg);
if (nr_pages < 0)
nr_pages = size / psize();
break;
case 't':
thp = 1;
break;
case 'T':
thp = 0;
break;
case 'U':
cmd = GUP_BASIC_TEST;
break;
case 'u':
cmd = GUP_FAST_BENCHMARK;
break;
case 'w':
write = 1;
break;
case 'W':
write = 0;
break;
case 'f':
file = optarg;
break;
case 'S':
flags &= ~MAP_PRIVATE;
flags |= MAP_SHARED;
break;
case 'H':
flags |= (MAP_HUGETLB | MAP_ANONYMOUS);
break;
default:
ksft_exit_fail_msg("Wrong argument\n");
}
}
if (optind < argc) {
int extra_arg_count = 0;
/*
* For example:
*
* ./gup_test -c 0 1 0x1001
*
* ...to dump pages 0, 1, and 4097
*/
while ((optind < argc) &&
(extra_arg_count < GUP_TEST_MAX_PAGES_TO_DUMP)) {
/*
* Do the 1-based indexing here, so that the user can
Annotation
- Immediate include surface: `fcntl.h`, `errno.h`, `stdio.h`, `stdlib.h`, `unistd.h`, `dirent.h`, `sys/ioctl.h`, `sys/mman.h`.
- Detected declarations: `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.