tools/testing/selftests/proc/proc-maps-race.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/proc/proc-maps-race.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/proc/proc-maps-race.c- Extension
.c- Size
- 29109 bytes
- Lines
- 976
- 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
kselftest_harness.herrno.hfcntl.hpthread.hstdbool.hstdio.hstdlib.hstring.hunistd.hlinux/fs.hsys/ioctl.hsys/mman.hsys/stat.hsys/types.hsys/wait.h
Detected Declarations
struct page_contentstruct line_contentstruct vma_modifier_infostruct vma_modifier_infoenum test_stateenum maps_filefunction read_pagefunction parse_vma_linefunction locate_containing_pagefunction read_two_pagesfunction copy_linefunction copy_first_linefunction copy_last_linefunction copy_first_entryfunction copy_last_entryfunction read_boundary_linesfunction wait_for_statefunction signal_statefunction stop_vma_modifierfunction print_first_linesfunction print_last_linesfunction print_boundariesfunction print_boundaries_onfunction report_test_startfunction start_test_loopfunction end_test_iterationfunction end_test_loopfunction capture_mod_patternfunction query_addr_atfunction split_vmafunction merge_vmafunction check_split_resultfunction shrink_vmafunction expand_vmafunction check_shrink_resultfunction remap_vmafunction patch_vmafunction check_remap_result
Annotated Snippet
struct page_content {
char *data;
ssize_t size;
};
#define LINE_MAX_SIZE 256
struct line_content {
char text[LINE_MAX_SIZE];
unsigned long start_addr;
unsigned long end_addr;
};
enum test_state {
INIT,
CHILD_READY,
PARENT_READY,
SETUP_READY,
SETUP_MODIFY_MAPS,
SETUP_MAPS_MODIFIED,
SETUP_RESTORE_MAPS,
SETUP_MAPS_RESTORED,
TEST_READY,
TEST_DONE,
};
enum maps_file {
MAPS,
SMAPS,
};
struct vma_modifier_info;
FIXTURE(proc_maps_race)
{
struct vma_modifier_info *mod_info;
struct page_content page1;
struct page_content page2;
struct line_content last_line;
struct line_content first_line;
unsigned long duration_sec;
enum maps_file maps_file;
int shared_mem_size;
int skip_pages;
int page_size;
int vma_count;
bool verbose;
int maps_fd;
pid_t pid;
};
FIXTURE_VARIANT(proc_maps_race)
{
const enum maps_file maps_file;
};
FIXTURE_VARIANT_ADD(proc_maps_race, maps) {
.maps_file = MAPS,
};
FIXTURE_VARIANT_ADD(proc_maps_race, smaps) {
.maps_file = SMAPS,
};
typedef bool (*vma_modifier_op)(FIXTURE_DATA(proc_maps_race) *self);
typedef bool (*vma_mod_result_check_op)(struct line_content *mod_last_line,
struct line_content *mod_first_line,
struct line_content *restored_last_line,
struct line_content *restored_first_line);
struct vma_modifier_info {
int vma_count;
void *addr;
int prot;
void *next_addr;
vma_modifier_op vma_modify;
vma_modifier_op vma_restore;
vma_mod_result_check_op vma_mod_check;
pthread_mutex_t sync_lock;
pthread_cond_t sync_cond;
enum test_state curr_state;
bool exit;
void *child_mapped_addr[];
};
static bool read_page(FIXTURE_DATA(proc_maps_race) *self,
struct page_content *page)
{
ssize_t bytes_read;
Annotation
- Immediate include surface: `kselftest_harness.h`, `errno.h`, `fcntl.h`, `pthread.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `struct page_content`, `struct line_content`, `struct vma_modifier_info`, `struct vma_modifier_info`, `enum test_state`, `enum maps_file`, `function read_page`, `function parse_vma_line`, `function locate_containing_page`, `function read_two_pages`.
- 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.