arch/s390/kernel/vtime.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/vtime.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/vtime.c- Extension
.c- Size
- 11350 bytes
- Lines
- 439
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel_stat.hlinux/export.hlinux/kernel.hlinux/timex.hlinux/types.hlinux/time.hasm/alternative.hasm/cputime.hasm/vtimer.hasm/vtime.hasm/cpu_mf.hasm/idle.hasm/smp.hentry.h
Detected Declarations
function set_vtimerfunction virt_timer_forwardfunction update_mt_scalingfunction update_tsk_timerfunction scale_vtimefunction account_system_index_scaledfunction vtime_reset_last_updatefunction do_account_vtimefunction vtime_task_switchfunction vtime_flushfunction vtime_deltafunction vtime_account_kernelfunction vtime_account_softirqfunction vtime_account_hardirqfunction list_add_sortedfunction list_for_each_entryfunction virt_timer_expirefunction init_virt_timerfunction vtimer_pendingfunction internal_add_vtimerfunction __add_vtimerfunction add_virt_timerfunction add_virt_timer_periodicfunction __mod_vtimerfunction timerfunction timerfunction pendingfunction vtime_initexport vtime_account_kernelexport init_virt_timerexport add_virt_timerexport add_virt_timer_periodicexport mod_virt_timerexport mod_virt_timer_periodicexport del_virt_timer
Annotated Snippet
if (tmp->expires > timer->expires) {
list_add_tail(&timer->entry, &tmp->entry);
return;
}
}
list_add_tail(&timer->entry, head);
}
/*
* Handler for expired virtual CPU timer.
*/
static void virt_timer_expire(void)
{
struct vtimer_list *timer, *tmp;
unsigned long elapsed;
LIST_HEAD(cb_list);
/* walk timer list, fire all expired timers */
spin_lock(&virt_timer_lock);
elapsed = atomic64_read(&virt_timer_elapsed);
list_for_each_entry_safe(timer, tmp, &virt_timer_list, entry) {
if (timer->expires < elapsed)
/* move expired timer to the callback queue */
list_move_tail(&timer->entry, &cb_list);
else
timer->expires -= elapsed;
}
if (!list_empty(&virt_timer_list)) {
timer = list_first_entry(&virt_timer_list,
struct vtimer_list, entry);
atomic64_set(&virt_timer_current, timer->expires);
}
atomic64_sub(elapsed, &virt_timer_elapsed);
spin_unlock(&virt_timer_lock);
/* Do callbacks and recharge periodic timers */
list_for_each_entry_safe(timer, tmp, &cb_list, entry) {
list_del_init(&timer->entry);
timer->function(timer->data);
if (timer->interval) {
/* Recharge interval timer */
timer->expires = timer->interval +
atomic64_read(&virt_timer_elapsed);
spin_lock(&virt_timer_lock);
list_add_sorted(timer, &virt_timer_list);
spin_unlock(&virt_timer_lock);
}
}
}
void init_virt_timer(struct vtimer_list *timer)
{
timer->function = NULL;
INIT_LIST_HEAD(&timer->entry);
}
EXPORT_SYMBOL(init_virt_timer);
static inline int vtimer_pending(struct vtimer_list *timer)
{
return !list_empty(&timer->entry);
}
static void internal_add_vtimer(struct vtimer_list *timer)
{
if (list_empty(&virt_timer_list)) {
/* First timer, just program it. */
atomic64_set(&virt_timer_current, timer->expires);
atomic64_set(&virt_timer_elapsed, 0);
list_add(&timer->entry, &virt_timer_list);
} else {
/* Update timer against current base. */
timer->expires += atomic64_read(&virt_timer_elapsed);
if (likely((s64) timer->expires <
(s64) atomic64_read(&virt_timer_current)))
/* The new timer expires before the current timer. */
atomic64_set(&virt_timer_current, timer->expires);
/* Insert new timer into the list. */
list_add_sorted(timer, &virt_timer_list);
}
}
static void __add_vtimer(struct vtimer_list *timer, int periodic)
{
unsigned long flags;
timer->interval = periodic ? timer->expires : 0;
spin_lock_irqsave(&virt_timer_lock, flags);
internal_add_vtimer(timer);
spin_unlock_irqrestore(&virt_timer_lock, flags);
}
Annotation
- Immediate include surface: `linux/kernel_stat.h`, `linux/export.h`, `linux/kernel.h`, `linux/timex.h`, `linux/types.h`, `linux/time.h`, `asm/alternative.h`, `asm/cputime.h`.
- Detected declarations: `function set_vtimer`, `function virt_timer_forward`, `function update_mt_scaling`, `function update_tsk_timer`, `function scale_vtime`, `function account_system_index_scaled`, `function vtime_reset_last_update`, `function do_account_vtime`, `function vtime_task_switch`, `function vtime_flush`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: integration 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.