arch/x86/include/asm/futex.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/futex.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/futex.h- Extension
.h- Size
- 2520 bytes
- Lines
- 99
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
Dependency Surface
linux/futex.hlinux/uaccess.hasm/asm.hasm/errno.hasm/processor.hasm/smap.h
Detected Declarations
function arch_futex_atomic_op_inuserfunction futex_atomic_cmpxchg_inatomicfunction scoped_user_rw_access
Annotated Snippet
switch (op) {
case FUTEX_OP_SET:
unsafe_atomic_op1("xchgl %0, %2", oval, uaddr, oparg, Efault);
break;
case FUTEX_OP_ADD:
unsafe_atomic_op1(LOCK_PREFIX "xaddl %0, %2", oval, uaddr, oparg, Efault);
break;
case FUTEX_OP_OR:
unsafe_atomic_op2("orl %4, %3", oval, uaddr, oparg, Efault);
break;
case FUTEX_OP_ANDN:
unsafe_atomic_op2("andl %4, %3", oval, uaddr, ~oparg, Efault);
break;
case FUTEX_OP_XOR:
unsafe_atomic_op2("xorl %4, %3", oval, uaddr, oparg, Efault);
break;
default:
return -ENOSYS;
}
}
return 0;
Efault:
return -EFAULT;
}
static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
u32 oldval, u32 newval)
{
int ret = 0;
scoped_user_rw_access(uaddr, Efault) {
asm_inline volatile("\n"
"1:\t" LOCK_PREFIX "cmpxchgl %3, %2\n"
"2:\n"
_ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %0)
: "+r" (ret), "=a" (oldval), "+m" (*uaddr)
: "r" (newval), "1" (oldval)
: "memory");
*uval = oldval;
}
return ret;
Efault:
return -EFAULT;
}
#endif
#endif /* _ASM_X86_FUTEX_H */
Annotation
- Immediate include surface: `linux/futex.h`, `linux/uaccess.h`, `asm/asm.h`, `asm/errno.h`, `asm/processor.h`, `asm/smap.h`.
- Detected declarations: `function arch_futex_atomic_op_inuser`, `function futex_atomic_cmpxchg_inatomic`, `function scoped_user_rw_access`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.