arch/x86/xen/time.c
Source file repositories/reference/linux-study-clean/arch/x86/xen/time.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/xen/time.c- Extension
.c- Size
- 17167 bytes
- Lines
- 661
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/interrupt.hlinux/clocksource.hlinux/clockchips.hlinux/gfp.hlinux/slab.hlinux/pvclock_gtod.hlinux/timekeeper_internal.hlinux/sched/cputime.hasm/cpuid/api.hasm/pvclock.hasm/timer.hasm/xen/hypervisor.hasm/xen/hypercall.hasm/xen/cpuid.hxen/events.hxen/features.hxen/interface/xen.hxen/interface/vcpu.hxen-ops.h
Detected Declarations
struct xen_clock_event_devicefunction xen_tsc_khzfunction xen_clocksource_readfunction xen_clocksource_get_cyclesfunction xen_sched_clockfunction xen_read_wallclockfunction xen_get_wallclockfunction xen_set_wallclockfunction xen_pvclock_gtod_notifyfunction xen_cs_enablefunction clocksourcefunction xen_timerop_shutdownfunction xen_timerop_set_next_eventfunction xen_vcpuop_shutdownfunction xen_vcpuop_set_oneshotfunction xen_vcpuop_set_next_eventfunction xen_timer_interruptfunction xen_teardown_timerfunction xen_setup_timerfunction xen_setup_cpu_clockeventsfunction xen_timer_resumefunction for_each_online_cpufunction xen_save_time_memory_areafunction xen_restore_time_memory_areafunction xen_setup_vsyscall_time_infofunction xen_tsc_safe_clocksourcefunction xen_time_initfunction xen_init_time_commonfunction xen_init_time_opsfunction xen_hvm_setup_cpu_clockeventsfunction xen_hvm_init_time_opsfunction __this_cpu_readfunction parse_xen_timer_slop
Annotated Snippet
struct xen_clock_event_device {
struct clock_event_device evt;
char name[16];
};
static DEFINE_PER_CPU(struct xen_clock_event_device, xen_clock_events) = { .evt.irq = -1 };
static irqreturn_t xen_timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *evt = this_cpu_ptr(&xen_clock_events.evt);
irqreturn_t ret;
ret = IRQ_NONE;
if (evt->event_handler) {
evt->event_handler(evt);
ret = IRQ_HANDLED;
}
return ret;
}
void xen_teardown_timer(int cpu)
{
struct clock_event_device *evt;
evt = &per_cpu(xen_clock_events, cpu).evt;
if (evt->irq >= 0) {
unbind_from_irqhandler(evt->irq, NULL);
evt->irq = -1;
}
}
void xen_setup_timer(int cpu)
{
struct xen_clock_event_device *xevt = &per_cpu(xen_clock_events, cpu);
struct clock_event_device *evt = &xevt->evt;
int irq;
WARN(evt->irq >= 0, "IRQ%d for CPU%d is already allocated\n", evt->irq, cpu);
if (evt->irq >= 0)
xen_teardown_timer(cpu);
printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu);
snprintf(xevt->name, sizeof(xevt->name), "timer%d", cpu);
irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt,
IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER|
IRQF_FORCE_RESUME|IRQF_EARLY_RESUME,
xevt->name, NULL);
(void)xen_set_irq_priority(irq, XEN_IRQ_PRIORITY_MAX);
memcpy(evt, xen_clockevent, sizeof(*evt));
evt->cpumask = cpumask_of(cpu);
evt->irq = irq;
}
void xen_setup_cpu_clockevents(void)
{
clockevents_register_device(this_cpu_ptr(&xen_clock_events.evt));
}
void xen_timer_resume(void)
{
int cpu;
if (xen_clockevent != &xen_vcpuop_clockevent)
return;
for_each_online_cpu(cpu) {
if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
xen_vcpu_nr(cpu), NULL))
BUG();
}
}
static struct pvclock_vsyscall_time_info *xen_clock __read_mostly;
static u64 xen_clock_value_saved;
void xen_save_time_memory_area(void)
{
struct vcpu_register_time_memory_area t;
int ret;
xen_clock_value_saved = xen_clocksource_read() - xen_sched_clock_offset;
if (!xen_clock)
return;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/clocksource.h`, `linux/clockchips.h`, `linux/gfp.h`, `linux/slab.h`, `linux/pvclock_gtod.h`, `linux/timekeeper_internal.h`.
- Detected declarations: `struct xen_clock_event_device`, `function xen_tsc_khz`, `function xen_clocksource_read`, `function xen_clocksource_get_cycles`, `function xen_sched_clock`, `function xen_read_wallclock`, `function xen_get_wallclock`, `function xen_set_wallclock`, `function xen_pvclock_gtod_notify`, `function xen_cs_enable`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.