lib/test_context-analysis.c
Source file repositories/reference/linux-study-clean/lib/test_context-analysis.c
File Facts
- System
- Linux kernel
- Corpus path
lib/test_context-analysis.c- Extension
.c- Size
- 14898 bytes
- Lines
- 634
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- 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
linux/bit_spinlock.hlinux/build_bug.hlinux/local_lock.hlinux/mutex.hlinux/percpu.hlinux/rcupdate.hlinux/rwsem.hlinux/seqlock.hlinux/spinlock.hlinux/srcu.hlinux/ww_mutex.h
Detected Declarations
struct test_mutex_datastruct test_seqlock_datastruct test_rwsem_datastruct test_bit_spinlock_datastruct test_rcu_datastruct test_srcu_datastruct test_local_lock_datastruct test_local_trylock_datastruct test_ww_mutex_datafunction test_common_helpersfunction test_raw_spinlock_trylock_extrafunction test_spinlock_trylock_extrafunction test_write_trylock_extrafunction test_mutex_initfunction test_mutex_lockfunction test_mutex_trylockfunction test_mutex_assertfunction test_mutex_guardfunction test_mutex_cond_guardfunction test_mutex_multiguardfunction test_seqlock_initfunction test_seqlock_readerfunction test_seqlock_writerfunction test_seqlock_scopedfunction test_rwsem_initfunction test_rwsem_readerfunction test_rwsem_writerfunction test_rwsem_assertfunction test_rwsem_guardfunction test_rwsem_cond_guardfunction test_bit_spin_lockfunction test_rcu_guarded_readerfunction test_rcu_guardfunction test_rcu_guarded_updaterfunction wants_rcu_heldfunction test_rcu_lock_reentrantfunction test_rcu_assert_variantsfunction test_srcufunction test_srcu_guardfunction test_local_lock_initfunction test_local_lockfunction test_local_lock_guardfunction test_local_trylock_initfunction test_local_trylockfunction test_ww_mutex_lock_noctxfunction test_ww_mutex_lock_ctxfunction test_per_cpu
Annotated Snippet
struct test_mutex_data {
struct mutex mtx;
int counter __guarded_by(&mtx);
struct mutex mtx2;
int anyread __guarded_by(&mtx, &mtx2);
int *anyptr __pt_guarded_by(&mtx, &mtx2);
};
static void __used test_mutex_init(struct test_mutex_data *d)
{
guard(mutex_init)(&d->mtx);
d->counter = 0;
}
static void __used test_mutex_lock(struct test_mutex_data *d)
{
mutex_lock(&d->mtx);
d->counter++;
mutex_unlock(&d->mtx);
mutex_lock_io(&d->mtx);
d->counter++;
mutex_unlock(&d->mtx);
}
static void __used test_mutex_trylock(struct test_mutex_data *d, atomic_t *a)
{
if (!mutex_lock_interruptible(&d->mtx)) {
d->counter++;
mutex_unlock(&d->mtx);
}
if (!mutex_lock_killable(&d->mtx)) {
d->counter++;
mutex_unlock(&d->mtx);
}
if (mutex_trylock(&d->mtx)) {
d->counter++;
mutex_unlock(&d->mtx);
}
if (atomic_dec_and_mutex_lock(a, &d->mtx)) {
d->counter++;
mutex_unlock(&d->mtx);
}
}
static void __used test_mutex_assert(struct test_mutex_data *d)
{
lockdep_assert_held(&d->mtx);
d->counter++;
}
static void __used test_mutex_guard(struct test_mutex_data *d)
{
guard(mutex)(&d->mtx);
d->counter++;
}
static void __used test_mutex_cond_guard(struct test_mutex_data *d)
{
scoped_cond_guard(mutex_try, return, &d->mtx) {
d->counter++;
}
scoped_cond_guard(mutex_intr, return, &d->mtx) {
d->counter++;
}
}
static void __used test_mutex_multiguard(struct test_mutex_data *d)
{
mutex_lock(&d->mtx);
(void)d->anyread;
(void)*d->anyptr;
mutex_unlock(&d->mtx);
mutex_lock(&d->mtx2);
(void)d->anyread;
(void)*d->anyptr;
mutex_unlock(&d->mtx2);
mutex_lock(&d->mtx);
mutex_lock(&d->mtx2);
d->anyread++;
(*d->anyptr)++;
mutex_unlock(&d->mtx2);
mutex_unlock(&d->mtx);
}
struct test_seqlock_data {
seqlock_t sl;
int counter __guarded_by(&sl);
Annotation
- Immediate include surface: `linux/bit_spinlock.h`, `linux/build_bug.h`, `linux/local_lock.h`, `linux/mutex.h`, `linux/percpu.h`, `linux/rcupdate.h`, `linux/rwsem.h`, `linux/seqlock.h`.
- Detected declarations: `struct test_mutex_data`, `struct test_seqlock_data`, `struct test_rwsem_data`, `struct test_bit_spinlock_data`, `struct test_rcu_data`, `struct test_srcu_data`, `struct test_local_lock_data`, `struct test_local_trylock_data`, `struct test_ww_mutex_data`, `function test_common_helpers`.
- Atlas domain: Kernel Services / lib.
- 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.