tools/testing/selftests/mm/uffd-unit-tests.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/uffd-unit-tests.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/mm/uffd-unit-tests.c- Extension
.c- Size
- 49658 bytes
- Lines
- 1814
- 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
uffd-common.h../../../../mm/gup_test.h
Detected Declarations
struct mem_typestruct uffd_test_argsfunction uffd_test_reportfunction uffd_test_passfunction uffd_test_skipfunction test_uffd_apifunction uffd_feature_supportedfunction pagemap_openfunction unpin_pagesfunction unpin_pagesfunction pagemap_test_forkfunction uffd_wp_unpopulated_testfunction uffd_wp_fork_test_commonfunction zappingfunction uffd_wp_fork_testfunction uffd_wp_fork_with_event_testfunction uffd_wp_fork_pin_test_commonfunction uffd_wp_fork_pin_testfunction uffd_wp_fork_pin_with_event_testfunction check_memory_contentsfunction uffd_minor_test_commonfunction uffd_minor_testfunction uffd_minor_wp_testfunction uffd_minor_collapse_testfunction sighndlfunction memoryfunction uffd_sigbus_test_commonfunction uffd_sigbus_testfunction uffd_sigbus_wp_testfunction uffd_events_test_commonfunction uffd_events_testfunction uffd_events_wp_testfunction retry_uffdio_zeropagefunction do_uffdio_zeropagefunction uffd_register_detect_zeropagefunction uffd_zeropage_testfunction uffd_register_poisonfunction do_uffdio_poisonfunction uffd_poison_handle_faultfunction uffd_poison_testfunction uffd_move_handle_fault_commonfunction uffd_move_handle_faultfunction uffd_move_pmd_handle_faultfunction uffd_move_test_commonfunction uffd_move_testfunction uffd_move_pmd_testfunction uffd_move_pmd_split_testfunction uffdio_verify_results
Annotated Snippet
struct mem_type {
const char *name;
unsigned int mem_flag;
uffd_test_ops_t *mem_ops;
bool shared;
};
typedef struct mem_type mem_type_t;
mem_type_t mem_types[] = {
{
.name = "anon",
.mem_flag = MEM_ANON,
.mem_ops = &anon_uffd_test_ops,
.shared = false,
},
{
.name = "shmem",
.mem_flag = MEM_SHMEM,
.mem_ops = &shmem_uffd_test_ops,
.shared = true,
},
{
.name = "shmem-private",
.mem_flag = MEM_SHMEM_PRIVATE,
.mem_ops = &shmem_uffd_test_ops,
.shared = false,
},
{
.name = "hugetlb",
.mem_flag = MEM_HUGETLB,
.mem_ops = &hugetlb_uffd_test_ops,
.shared = true,
},
{
.name = "hugetlb-private",
.mem_flag = MEM_HUGETLB_PRIVATE,
.mem_ops = &hugetlb_uffd_test_ops,
.shared = false,
},
};
/* Arguments to be passed over to each uffd unit test */
struct uffd_test_args {
mem_type_t *mem_type;
};
typedef struct uffd_test_args uffd_test_args_t;
/* Returns: UFFD_TEST_* */
typedef void (*uffd_test_fn)(uffd_global_test_opts_t *, uffd_test_args_t *);
typedef struct {
const char *name;
uffd_test_fn uffd_fn;
unsigned int mem_targets;
uint64_t uffd_feature_required;
uffd_test_case_ops_t *test_case_ops;
} uffd_test_case_t;
static void uffd_test_report(void)
{
printf("Userfaults unit tests: pass=%u, skip=%u, fail=%u (total=%u)\n",
ksft_get_pass_cnt(),
ksft_get_xskip_cnt(),
ksft_get_fail_cnt(),
ksft_test_num());
}
static void uffd_test_pass(void)
{
printf("done\n");
ksft_inc_pass_cnt();
}
#define uffd_test_start(...) do { \
printf("Testing "); \
printf(__VA_ARGS__); \
printf("... "); \
fflush(stdout); \
} while (0)
#define uffd_test_fail(...) do { \
printf("failed [reason: "); \
printf(__VA_ARGS__); \
printf("]\n"); \
ksft_inc_fail_cnt(); \
} while (0)
static void uffd_test_skip(const char *message)
{
printf("skipped [reason: %s]\n", message);
Annotation
- Immediate include surface: `uffd-common.h`, `../../../../mm/gup_test.h`.
- Detected declarations: `struct mem_type`, `struct uffd_test_args`, `function uffd_test_report`, `function uffd_test_pass`, `function uffd_test_skip`, `function test_uffd_api`, `function uffd_feature_supported`, `function pagemap_open`, `function unpin_pages`, `function unpin_pages`.
- 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.