[LTP] [PATCH v1 2/2] lib: moves test infrastructure states into a shared context structure
Petr Vorel
pvorel@suse.cz
Thu May 15 15:16:34 CEST 2025
Hi Li,
> This patch introduces a new struct context to consolidate various
> runtime state variables previously maintained as global variables
> in tst_test.c. The goal is to support better state sharing between
> parent and child processes particularly in scenarios that involve
> checkpointing or fork/exec patterns.
> To achieve this, a new struct ipc_region is defined, which encapsulates
> three components: a magic field for validation, a context structure for
> runtime metadata, and a results structure for test result counters.
> Optionally, a futex array is appended for test checkpoint synchronization.
> Test library IPC region (only one page size):
> +----------------------+
> | Magic Number |
> +----------------------+
> | struct context |
> +----------------------+
> | struct results |
> +----------------------+
> | futexes[], or N/A |
> +----------------------+
> The shared memory region is allocated with a single page using mmap()
> and is zero-initialized with memset() to ensure a clean initial state.
> The patch refactors setup_ipc() and tst_reinit() to map this shared
> region and properly initialize internal pointers to the `context`,
> `results`, and `futexes` regions.
> Overall, this refactor reduces global state pollution, centralizes the
> runtime state management, and enables safe and efficient state sharing
> across test lifecycle phases. It also sets the foundation for future
> improvements such as multi-threaded test coordination or enhanced IPC
> mechanisms.
Nice work, hopefully I haven't overlooked anything.
Of course not for the release (merged after).
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
More information about the ltp
mailing list