arch/loongarch/include/asm/qspinlock.h
Source file repositories/reference/linux-study-clean/arch/loongarch/include/asm/qspinlock.h
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/include/asm/qspinlock.h- Extension
.h- Size
- 1416 bytes
- Lines
- 61
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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
asm/kvm_para.hasm/paravirt.hasm-generic/qspinlock.h
Detected Declarations
function virt_spin_lock
Annotated Snippet
#ifndef _ASM_LOONGARCH_QSPINLOCK_H
#define _ASM_LOONGARCH_QSPINLOCK_H
#include <asm/kvm_para.h>
#include <asm/paravirt.h>
#ifdef CONFIG_PARAVIRT
#define virt_spin_lock virt_spin_lock
static inline bool virt_spin_lock(struct qspinlock *lock)
{
int val;
if (!static_branch_unlikely(&virt_spin_lock_key))
return false;
/*
* On hypervisors without PARAVIRT_SPINLOCKS support we fall
* back to a Test-and-Set spinlock, because fair locks have
* horrible lock 'holder' preemption issues.
*/
__retry:
val = atomic_read(&lock->val);
if (val || !atomic_try_cmpxchg(&lock->val, &val, _Q_LOCKED_VAL)) {
cpu_relax();
goto __retry;
}
return true;
}
/*
* Macro is better than inline function here
* With macro, parameter cpu is parsed only when it is used.
* With inline function, parameter cpu is parsed even though it is not used.
* This may cause cache line thrashing across NUMA nodes.
*/
#define vcpu_is_preempted(cpu) \
({ \
bool __val; \
\
if (!static_branch_unlikely(&virt_preempt_key)) \
__val = false; \
else { \
struct kvm_steal_time *src; \
src = &per_cpu(steal_time, cpu); \
__val = !!(READ_ONCE(src->preempted) & KVM_VCPU_PREEMPTED); \
} \
__val; \
})
#endif /* CONFIG_PARAVIRT */
#include <asm-generic/qspinlock.h>
#endif // _ASM_LOONGARCH_QSPINLOCK_H
Annotation
- Immediate include surface: `asm/kvm_para.h`, `asm/paravirt.h`, `asm-generic/qspinlock.h`.
- Detected declarations: `function virt_spin_lock`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.