arch/powerpc/include/asm/paravirt.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/paravirt.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/paravirt.h- Extension
.h- Size
- 6228 bytes
- Lines
- 221
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
Dependency Surface
linux/jump_label.hasm/smp.hasm/paca.hasm/lppaca.hasm/hvcall.hlinux/smp.hasm/kvm_guest.hasm/cputhreads.h
Detected Declarations
function is_shared_processorfunction paravirt_steal_clockfunction yield_count_offunction instancefunction prod_cpufunction yield_to_anyfunction is_vcpu_idlefunction vcpu_is_dispatchedfunction is_shared_processorfunction yield_count_offunction yield_to_preemptedfunction yield_to_anyfunction prod_cpufunction is_vcpu_idlefunction vcpu_is_dispatchedfunction vcpu_is_preemptedfunction pv_is_native_spin_unlock
Annotated Snippet
#ifndef _ASM_POWERPC_PARAVIRT_H
#define _ASM_POWERPC_PARAVIRT_H
#include <linux/jump_label.h>
#include <asm/smp.h>
#ifdef CONFIG_PPC64
#include <asm/paca.h>
#include <asm/lppaca.h>
#include <asm/hvcall.h>
#endif
#ifdef CONFIG_PPC_SPLPAR
#include <linux/smp.h>
#include <asm/kvm_guest.h>
#include <asm/cputhreads.h>
DECLARE_STATIC_KEY_FALSE(shared_processor);
static inline bool is_shared_processor(void)
{
return static_branch_unlikely(&shared_processor);
}
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
u64 pseries_paravirt_steal_clock(int cpu);
static inline u64 paravirt_steal_clock(int cpu)
{
return pseries_paravirt_steal_clock(cpu);
}
#endif
/* If bit 0 is set, the cpu has been ceded, conferred, or preempted */
static inline u32 yield_count_of(int cpu)
{
__be32 yield_count = READ_ONCE(lppaca_of(cpu).yield_count);
return be32_to_cpu(yield_count);
}
/*
* Spinlock code confers and prods, so don't trace the hcalls because the
* tracing code takes spinlocks which can cause recursion deadlocks.
*
* These calls are made while the lock is not held: the lock slowpath yields if
* it can not acquire the lock, and unlock slow path might prod if a waiter has
* yielded). So this may not be a problem for simple spin locks because the
* tracing does not technically recurse on the lock, but we avoid it anyway.
*
* However the queued spin lock contended path is more strictly ordered: the
* H_CONFER hcall is made after the task has queued itself on the lock, so then
* recursing on that lock will cause the task to then queue up again behind the
* first instance (or worse: queued spinlocks use tricks that assume a context
* never waits on more than one spinlock, so such recursion may cause random
* corruption in the lock code).
*/
static inline void yield_to_preempted(int cpu, u32 yield_count)
{
plpar_hcall_norets_notrace(H_CONFER, get_hard_smp_processor_id(cpu), yield_count);
}
static inline void prod_cpu(int cpu)
{
plpar_hcall_norets_notrace(H_PROD, get_hard_smp_processor_id(cpu));
}
static inline void yield_to_any(void)
{
plpar_hcall_norets_notrace(H_CONFER, -1, 0);
}
static inline bool is_vcpu_idle(int vcpu)
{
return lppaca_of(vcpu).idle;
}
static inline bool vcpu_is_dispatched(int vcpu)
{
/*
* This is the yield_count. An "odd" value (low bit on) means that
* the processor is yielded (either because of an OS yield or a
* hypervisor preempt). An even value implies that the processor is
* currently executing.
*/
return (!(yield_count_of(vcpu) & 1));
}
#else
static inline bool is_shared_processor(void)
{
return false;
}
Annotation
- Immediate include surface: `linux/jump_label.h`, `asm/smp.h`, `asm/paca.h`, `asm/lppaca.h`, `asm/hvcall.h`, `linux/smp.h`, `asm/kvm_guest.h`, `asm/cputhreads.h`.
- Detected declarations: `function is_shared_processor`, `function paravirt_steal_clock`, `function yield_count_of`, `function instance`, `function prod_cpu`, `function yield_to_any`, `function is_vcpu_idle`, `function vcpu_is_dispatched`, `function is_shared_processor`, `function yield_count_of`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
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.