arch/s390/include/asm/spinlock.h
Source file repositories/reference/linux-study-clean/arch/s390/include/asm/spinlock.h
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/include/asm/spinlock.h- Extension
.h- Size
- 3922 bytes
- Lines
- 169
- Domain
- Architecture Layer
- Bucket
- arch/s390
- 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
linux/smp.hasm/atomic_ops.hasm/barrier.hasm/processor.hasm/alternative.h
Detected Declarations
function Authorfunction arch_spin_lockvalfunction arch_spin_value_unlockedfunction arch_spin_is_lockedfunction arch_spin_trylock_oncefunction arch_spin_lockfunction arch_spin_trylockfunction arch_spin_unlockfunction arch_read_lockfunction arch_read_unlockfunction arch_write_lockfunction arch_write_unlockfunction arch_read_trylockfunction arch_write_trylock
Annotated Snippet
#ifndef __ASM_SPINLOCK_H
#define __ASM_SPINLOCK_H
#include <linux/smp.h>
#include <asm/atomic_ops.h>
#include <asm/barrier.h>
#include <asm/processor.h>
#include <asm/alternative.h>
static __always_inline unsigned int spinlock_lockval(void)
{
unsigned long lc_lockval;
unsigned int lockval;
BUILD_BUG_ON(sizeof_field(struct lowcore, spinlock_lockval) != sizeof(lockval));
lc_lockval = offsetof(struct lowcore, spinlock_lockval);
asm_inline(
ALTERNATIVE(" ly %[lockval],%[offzero](%%r0)\n",
" ly %[lockval],%[offalt](%%r0)\n",
ALT_FEATURE(MFEATURE_LOWCORE))
: [lockval] "=d" (lockval)
: [offzero] "i" (lc_lockval),
[offalt] "i" (lc_lockval + LOWCORE_ALT_ADDRESS),
"m" (((struct lowcore *)0)->spinlock_lockval));
return lockval;
}
extern int spin_retry;
bool arch_vcpu_is_preempted(int cpu);
#define vcpu_is_preempted arch_vcpu_is_preempted
/*
* Simple spin lock operations. There are two variants, one clears IRQ's
* on the local processor, one does not.
*
* We make no fairness assumptions. They have a cost.
*
* (the type definitions are in asm/spinlock_types.h)
*/
void arch_spin_relax(arch_spinlock_t *lock);
#define arch_spin_relax arch_spin_relax
void arch_spin_lock_wait(arch_spinlock_t *);
int arch_spin_trylock_retry(arch_spinlock_t *);
void arch_spin_lock_setup(int cpu);
static inline u32 arch_spin_lockval(int cpu)
{
return cpu + 1;
}
static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
{
return lock.lock == 0;
}
static inline int arch_spin_is_locked(arch_spinlock_t *lp)
{
return READ_ONCE(lp->lock) != 0;
}
static inline int arch_spin_trylock_once(arch_spinlock_t *lp)
{
int old = 0;
barrier();
return likely(arch_try_cmpxchg(&lp->lock, &old, spinlock_lockval()));
}
static inline void arch_spin_lock(arch_spinlock_t *lp)
{
if (!arch_spin_trylock_once(lp))
arch_spin_lock_wait(lp);
}
static inline int arch_spin_trylock(arch_spinlock_t *lp)
{
if (!arch_spin_trylock_once(lp))
return arch_spin_trylock_retry(lp);
return 1;
}
static inline void arch_spin_unlock(arch_spinlock_t *lp)
{
typecheck(int, lp->lock);
kcsan_release();
asm_inline volatile(
Annotation
- Immediate include surface: `linux/smp.h`, `asm/atomic_ops.h`, `asm/barrier.h`, `asm/processor.h`, `asm/alternative.h`.
- Detected declarations: `function Author`, `function arch_spin_lockval`, `function arch_spin_value_unlocked`, `function arch_spin_is_locked`, `function arch_spin_trylock_once`, `function arch_spin_lock`, `function arch_spin_trylock`, `function arch_spin_unlock`, `function arch_read_lock`, `function arch_read_unlock`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.