tools/testing/selftests/rseq/param_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/rseq/param_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/rseq/param_test.c- Extension
.c- Size
- 39706 bytes
- Lines
- 1668
- 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
assert.hlinux/membarrier.hpthread.hsched.hstdatomic.hstdint.hstdio.hstdlib.hstring.hsyscall.hunistd.hpoll.hsys/types.hsignal.herrno.hstddef.hstdbool.hrseq.h
Detected Declarations
struct percpu_lock_entrystruct percpu_lockstruct test_data_entrystruct spinlock_test_datastruct spinlock_thread_test_datastruct inc_test_datastruct inc_thread_test_datastruct percpu_list_nodestruct percpu_list_entrystruct percpu_liststruct percpu_buffer_nodestruct percpu_buffer_entrystruct percpu_bufferstruct percpu_memcpy_buffer_nodestruct percpu_memcpy_buffer_entrystruct percpu_memcpy_bufferstruct test_membarrier_thread_argsfunction rseq_gettidfunction sys_membarrierfunction get_current_cpu_idfunction rseq_validate_cpu_idfunction rseq_use_cpu_indexfunction rseq_membarrier_expeditedfunction get_current_cpu_idfunction rseq_validate_cpu_idfunction rseq_use_cpu_indexfunction rseq_membarrier_expeditedfunction rseq_this_cpu_lockfunction rseq_percpu_unlockfunction test_percpu_spinlockfunction test_percpu_incfunction this_cpu_list_pushfunction test_percpu_listfunction this_cpu_buffer_pushfunction test_percpu_bufferfunction this_cpu_memcpy_buffer_pushfunction this_cpu_memcpy_buffer_popfunction __percpu_memcpy_buffer_popfunction test_percpu_memcpy_bufferfunction test_signal_interrupt_handlerfunction set_signal_handlerfunction test_membarrier_init_percpu_listfunction test_membarrier_free_percpu_listfunction test_membarrierfunction test_membarrierfunction show_usagefunction main
Annotated Snippet
struct percpu_lock_entry {
intptr_t v;
} __attribute__((aligned(128)));
struct percpu_lock {
struct percpu_lock_entry c[CPU_SETSIZE];
};
struct test_data_entry {
intptr_t count;
} __attribute__((aligned(128)));
struct spinlock_test_data {
struct percpu_lock lock;
struct test_data_entry c[CPU_SETSIZE];
};
struct spinlock_thread_test_data {
struct spinlock_test_data *data;
long long reps;
int reg;
};
struct inc_test_data {
struct test_data_entry c[CPU_SETSIZE];
};
struct inc_thread_test_data {
struct inc_test_data *data;
long long reps;
int reg;
};
struct percpu_list_node {
intptr_t data;
struct percpu_list_node *next;
};
struct percpu_list_entry {
struct percpu_list_node *head;
} __attribute__((aligned(128)));
struct percpu_list {
struct percpu_list_entry c[CPU_SETSIZE];
};
#define BUFFER_ITEM_PER_CPU 100
struct percpu_buffer_node {
intptr_t data;
};
struct percpu_buffer_entry {
intptr_t offset;
intptr_t buflen;
struct percpu_buffer_node **array;
} __attribute__((aligned(128)));
struct percpu_buffer {
struct percpu_buffer_entry c[CPU_SETSIZE];
};
#define MEMCPY_BUFFER_ITEM_PER_CPU 100
struct percpu_memcpy_buffer_node {
intptr_t data1;
uint64_t data2;
};
struct percpu_memcpy_buffer_entry {
intptr_t offset;
intptr_t buflen;
struct percpu_memcpy_buffer_node *array;
} __attribute__((aligned(128)));
struct percpu_memcpy_buffer {
struct percpu_memcpy_buffer_entry c[CPU_SETSIZE];
};
/* A simple percpu spinlock. Grabs lock on current cpu. */
static int rseq_this_cpu_lock(struct percpu_lock *lock)
{
int cpu;
for (;;) {
int ret;
cpu = get_current_cpu_id();
if (cpu < 0) {
fprintf(stderr, "pid: %d: tid: %d, cpu: %d: cid: %d\n",
Annotation
- Immediate include surface: `assert.h`, `linux/membarrier.h`, `pthread.h`, `sched.h`, `stdatomic.h`, `stdint.h`, `stdio.h`, `stdlib.h`.
- Detected declarations: `struct percpu_lock_entry`, `struct percpu_lock`, `struct test_data_entry`, `struct spinlock_test_data`, `struct spinlock_thread_test_data`, `struct inc_test_data`, `struct inc_thread_test_data`, `struct percpu_list_node`, `struct percpu_list_entry`, `struct percpu_list`.
- 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.