kernel/time/timer_migration.c
Source file repositories/reference/linux-study-clean/kernel/time/timer_migration.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/time/timer_migration.c- Extension
.c- Size
- 69771 bytes
- Lines
- 2179
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpuhotplug.hlinux/slab.hlinux/smp.hlinux/spinlock.hlinux/timerqueue.htrace/events/ipi.hlinux/sched/isolation.htimer_migration.htick-internal.htrace/events/timer_migration.h
Detected Declarations
struct tmigr_walkfunction tmigr_update_eventsfunction tmigr_update_eventsfunction tmigr_is_not_availablefunction idlefunction tmigr_check_migratorfunction tmigr_check_migrator_and_lonelyfunction tmigr_check_lonelyfunction __walk_groups_fromfunction __walk_groupsfunction walk_groupsfunction tmigr_update_eventsfunction eventfunction tmigr_next_groupevt_expiresfunction tmigr_active_upfunction __tmigr_cpu_activatefunction tmigr_cpu_activatefunction tmigr_inactive_upfunction tmigr_new_timer_upfunction tmigr_new_timerfunction tmigr_handle_remote_cpufunction tmigr_handle_remote_upfunction tmigr_handle_remotefunction tmigr_handle_remote_upfunction tmigr_requires_handle_remote_upfunction tmigr_requires_handle_remotefunction tmigr_cpu_new_timerfunction tmigr_inactive_upfunction __tmigr_cpu_deactivatefunction tmigr_cpu_deactivatefunction tmigr_quick_checkfunction tmigr_trigger_activefunction tmigr_get_capacityfunction list_for_each_entryfunction tmigr_clear_cpu_availablefunction __tmigr_set_cpu_availablefunction tmigr_set_cpu_availablefunction tmigr_cpu_isolatefunction tmigr_cpu_unisolatefunction tmigr_isolated_exclude_cpumaskfunction for_each_cpufunction for_each_cpufunction tmigr_init_isolationfunction tmigr_init_groupfunction tmigr_init_rootfunction tmigr_connect_child_parentfunction tmigr_setup_groupsfunction tmigr_connect_old_root
Annotated Snippet
struct tmigr_walk {
u64 nextexp;
u64 firstexp;
struct tmigr_event *evt;
u8 childmask;
bool remote;
unsigned long basej;
u64 now;
bool check;
};
typedef bool (*up_f)(struct tmigr_group *, struct tmigr_group *, struct tmigr_walk *);
static void __walk_groups_from(up_f up, struct tmigr_walk *data,
struct tmigr_group *child, struct tmigr_group *group)
{
do {
WARN_ON_ONCE(group->level >= tmigr_hierarchy_levels);
if (up(group, child, data))
break;
child = group;
/*
* Pairs with the store release on group connection
* to make sure group initialization is visible.
*/
group = READ_ONCE(group->parent);
data->childmask = child->groupmask;
WARN_ON_ONCE(!data->childmask);
} while (group);
}
static void __walk_groups(up_f up, struct tmigr_walk *data,
struct tmigr_cpu *tmc)
{
__walk_groups_from(up, data, NULL, tmc->tmgroup);
}
static void walk_groups(up_f up, struct tmigr_walk *data, struct tmigr_cpu *tmc)
{
lockdep_assert_held(&tmc->lock);
__walk_groups(up, data, tmc);
}
/*
* Returns the next event of the timerqueue @group->events
*
* Removes timers with ignore flag and update next_expiry of the group. Values
* of the group event are updated in tmigr_update_events() only.
*/
static struct tmigr_event *tmigr_next_groupevt(struct tmigr_group *group)
{
struct timerqueue_node *node = NULL;
struct tmigr_event *evt = NULL;
lockdep_assert_held(&group->lock);
WRITE_ONCE(group->next_expiry, KTIME_MAX);
while ((node = timerqueue_getnext(&group->events))) {
evt = container_of(node, struct tmigr_event, nextevt);
if (!READ_ONCE(evt->ignore)) {
WRITE_ONCE(group->next_expiry, evt->nextevt.expires);
return evt;
}
/*
* Remove next timers with ignore flag, because the group lock
* is held anyway
*/
if (!timerqueue_del(&group->events, node))
break;
}
return NULL;
}
/*
* Return the next event (with the expiry equal or before @now)
*
* Event, which is returned, is also removed from the queue.
*/
static struct tmigr_event *tmigr_next_expired_groupevt(struct tmigr_group *group,
u64 now)
{
struct tmigr_event *evt = tmigr_next_groupevt(group);
Annotation
- Immediate include surface: `linux/cpuhotplug.h`, `linux/slab.h`, `linux/smp.h`, `linux/spinlock.h`, `linux/timerqueue.h`, `trace/events/ipi.h`, `linux/sched/isolation.h`, `timer_migration.h`.
- Detected declarations: `struct tmigr_walk`, `function tmigr_update_events`, `function tmigr_update_events`, `function tmigr_is_not_available`, `function idle`, `function tmigr_check_migrator`, `function tmigr_check_migrator_and_lonely`, `function tmigr_check_lonely`, `function __walk_groups_from`, `function __walk_groups`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.