include/linux/lockref.h
Source file repositories/reference/linux-study-clean/include/linux/lockref.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/lockref.h- Extension
.h- Size
- 1727 bytes
- Lines
- 64
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/spinlock.hgenerated/bounds.h
Detected Declarations
struct lockreffunction lockref_initfunction __lockref_is_dead
Annotated Snippet
struct lockref {
union {
#if USE_CMPXCHG_LOCKREF
aligned_u64 lock_count;
#endif
struct {
spinlock_t lock;
int count;
};
};
};
/**
* lockref_init - Initialize a lockref
* @lockref: pointer to lockref structure
*
* Initializes @lockref->count to 1.
*/
static inline void lockref_init(struct lockref *lockref)
{
spin_lock_init(&lockref->lock);
lockref->count = 1;
}
void lockref_get(struct lockref *lockref);
int lockref_put_return(struct lockref *lockref);
bool lockref_get_not_zero(struct lockref *lockref);
bool lockref_put_or_lock(struct lockref *lockref) __cond_acquires(false, &lockref->lock);
void lockref_mark_dead(struct lockref *lockref);
bool lockref_get_not_dead(struct lockref *lockref);
/* Must be called under spinlock for reliable results */
static inline bool __lockref_is_dead(const struct lockref *l)
{
return ((int)l->count < 0);
}
#endif /* __LINUX_LOCKREF_H */
Annotation
- Immediate include surface: `linux/spinlock.h`, `generated/bounds.h`.
- Detected declarations: `struct lockref`, `function lockref_init`, `function __lockref_is_dead`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.