arch/arm/common/bL_switcher.c
Source file repositories/reference/linux-study-clean/arch/arm/common/bL_switcher.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/common/bL_switcher.c- Extension
.c- Size
- 20705 bytes
- Lines
- 802
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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/atomic.hlinux/init.hlinux/kernel.hlinux/module.hlinux/sched/signal.huapi/linux/sched/types.hlinux/interrupt.hlinux/cpu_pm.hlinux/cpu.hlinux/cpumask.hlinux/kthread.hlinux/wait.hlinux/time.hlinux/clockchips.hlinux/hrtimer.hlinux/tick.hlinux/notifier.hlinux/mm.hlinux/mutex.hlinux/smp.hlinux/spinlock.hlinux/string.hlinux/sysfs.hlinux/irqchip/arm-gic.hlinux/moduleparam.hasm/smp_plat.hasm/cputype.hasm/suspend.hasm/mcpm.hasm/bL_switcher.htrace/events/power_cpu_migrate.h
Detected Declarations
struct bL_threadfunction read_mpidrfunction bL_do_switchfunction cpu_suspendfunction bL_switchpointfunction bL_switch_tofunction bL_switcher_threadfunction bL_switch_request_cbfunction bL_switcher_register_notifierfunction bL_switcher_unregister_notifierfunction bL_activation_notifyfunction bL_switcher_restore_cpusfunction for_each_cpufunction bL_switcher_halve_cpusfunction for_each_cpufunction bL_switcher_get_logical_indexfunction bL_switcher_trace_trigger_cpufunction bL_switcher_trace_triggerfunction bL_switcher_enablefunction for_each_online_cpufunction bL_switcher_disablefunction bL_switcher_active_showfunction bL_switcher_active_storefunction bL_switcher_trace_trigger_storefunction bL_switcher_sysfs_initfunction bL_switcher_get_enabledfunction bL_switcher_put_enabledfunction bL_switcher_cpu_prefunction bL_switcher_initexport bL_switch_request_cbexport bL_switcher_register_notifierexport bL_switcher_unregister_notifierexport bL_switcher_trace_triggerexport bL_switcher_get_enabledexport bL_switcher_put_enabled
Annotated Snippet
struct bL_thread {
spinlock_t lock;
struct task_struct *task;
wait_queue_head_t wq;
int wanted_cluster;
struct completion started;
bL_switch_completion_handler completer;
void *completer_cookie;
};
static struct bL_thread bL_threads[NR_CPUS];
static int bL_switcher_thread(void *arg)
{
struct bL_thread *t = arg;
int cluster;
bL_switch_completion_handler completer;
void *completer_cookie;
sched_set_fifo_low(current);
complete(&t->started);
do {
if (signal_pending(current))
flush_signals(current);
wait_event_interruptible(t->wq,
t->wanted_cluster != -1 ||
kthread_should_stop());
spin_lock(&t->lock);
cluster = t->wanted_cluster;
completer = t->completer;
completer_cookie = t->completer_cookie;
t->wanted_cluster = -1;
t->completer = NULL;
spin_unlock(&t->lock);
if (cluster != -1) {
bL_switch_to(cluster);
if (completer)
completer(completer_cookie);
}
} while (!kthread_should_stop());
return 0;
}
static struct task_struct *bL_switcher_thread_create(int cpu, void *arg)
{
struct task_struct *task;
task = kthread_run_on_cpu(bL_switcher_thread, arg,
cpu, "kswitcher_%d");
if (IS_ERR(task))
pr_err("%s failed for CPU %d\n", __func__, cpu);
return task;
}
/*
* bL_switch_request_cb - Switch to a specific cluster for the given CPU,
* with completion notification via a callback
*
* @cpu: the CPU to switch
* @new_cluster_id: the ID of the cluster to switch to.
* @completer: switch completion callback. if non-NULL,
* @completer(@completer_cookie) will be called on completion of
* the switch, in non-atomic context.
* @completer_cookie: opaque context argument for @completer.
*
* This function causes a cluster switch on the given CPU by waking up
* the appropriate switcher thread. This function may or may not return
* before the switch has occurred.
*
* If a @completer callback function is supplied, it will be called when
* the switch is complete. This can be used to determine asynchronously
* when the switch is complete, regardless of when bL_switch_request()
* returns. When @completer is supplied, no new switch request is permitted
* for the affected CPU until after the switch is complete, and @completer
* has returned.
*/
int bL_switch_request_cb(unsigned int cpu, unsigned int new_cluster_id,
bL_switch_completion_handler completer,
void *completer_cookie)
{
struct bL_thread *t;
if (cpu >= ARRAY_SIZE(bL_threads)) {
pr_err("%s: cpu %d out of bounds\n", __func__, cpu);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/sched/signal.h`, `uapi/linux/sched/types.h`, `linux/interrupt.h`, `linux/cpu_pm.h`.
- Detected declarations: `struct bL_thread`, `function read_mpidr`, `function bL_do_switch`, `function cpu_suspend`, `function bL_switchpoint`, `function bL_switch_to`, `function bL_switcher_thread`, `function bL_switch_request_cb`, `function bL_switcher_register_notifier`, `function bL_switcher_unregister_notifier`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.