arch/riscv/kernel/cpu-hotplug.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/cpu-hotplug.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/cpu-hotplug.c- Extension
.c- Size
- 1507 bytes
- Lines
- 77
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- 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/kernel.hlinux/mm.hlinux/sched.hlinux/err.hlinux/irq.hlinux/cpuhotplug.hlinux/cpu.hlinux/sched/hotplug.hasm/irq.hasm/cpu_ops.hasm/numa.hasm/smp.h
Detected Declarations
function Copyrightfunction __cpu_disablefunction arch_cpuhp_cleanup_dead_cpufunction arch_cpu_idle_dead
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 Western Digital Corporation or its affiliates.
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/err.h>
#include <linux/irq.h>
#include <linux/cpuhotplug.h>
#include <linux/cpu.h>
#include <linux/sched/hotplug.h>
#include <asm/irq.h>
#include <asm/cpu_ops.h>
#include <asm/numa.h>
#include <asm/smp.h>
bool cpu_has_hotplug(unsigned int cpu)
{
if (cpu_ops->cpu_stop)
return true;
return false;
}
/*
* __cpu_disable runs on the processor to be shutdown.
*/
int __cpu_disable(void)
{
unsigned int cpu = smp_processor_id();
if (!cpu_ops->cpu_stop)
return -EOPNOTSUPP;
remove_cpu_topology(cpu);
numa_remove_cpu(cpu);
set_cpu_online(cpu, false);
riscv_ipi_disable();
irq_migrate_all_off_this_cpu();
return 0;
}
/*
* Called on the thread which is asking for a CPU to be shutdown, if the
* CPU reported dead to the hotplug core.
*/
void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
{
int ret = 0;
pr_notice("CPU%u: off\n", cpu);
clear_tasks_mm_cpumask(cpu);
/* Verify from the firmware if the cpu is really stopped*/
if (cpu_ops->cpu_is_stopped)
ret = cpu_ops->cpu_is_stopped(cpu);
if (!ret)
pr_warn("CPU%u may not have stopped\n", cpu);
}
/*
* Called from the idle thread for the CPU which has been shutdown.
*/
void __noreturn arch_cpu_idle_dead(void)
{
idle_task_exit();
cpuhp_ap_report_dead();
cpu_ops->cpu_stop();
/* It should never reach here */
BUG();
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mm.h`, `linux/sched.h`, `linux/err.h`, `linux/irq.h`, `linux/cpuhotplug.h`, `linux/cpu.h`, `linux/sched/hotplug.h`.
- Detected declarations: `function Copyright`, `function __cpu_disable`, `function arch_cpuhp_cleanup_dead_cpu`, `function arch_cpu_idle_dead`.
- Atlas domain: Architecture Layer / arch/riscv.
- 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.