arch/um/os-Linux/smp.c
Source file repositories/reference/linux-study-clean/arch/um/os-Linux/smp.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/os-Linux/smp.c- Extension
.c- Size
- 2744 bytes
- Lines
- 149
- Domain
- Architecture Layer
- Bucket
- arch/um
- 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.
- 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
errno.hpthread.hsignal.hkern_util.hum_malloc.hinit.hos.hsmp.hinternal.h
Detected Declarations
struct cpu_thread_datafunction uml_curr_cpufunction os_start_cpu_threadfunction os_start_secondaryfunction os_send_ipifunction __local_ipi_setfunction os_local_ipi_enablefunction os_local_ipi_disablefunction ipi_sig_handlerfunction os_init_smp
Annotated Snippet
struct cpu_thread_data {
int cpu;
sigset_t sigset;
};
static __thread int __curr_cpu;
int uml_curr_cpu(void)
{
return __curr_cpu;
}
static pthread_t cpu_threads[CONFIG_NR_CPUS];
static void *cpu_thread(void *arg)
{
struct cpu_thread_data *data = arg;
__curr_cpu = data->cpu;
uml_start_secondary(data);
return NULL;
}
int os_start_cpu_thread(int cpu)
{
struct cpu_thread_data *data;
sigset_t sigset, oset;
int err;
data = uml_kmalloc(sizeof(*data), UM_GFP_ATOMIC);
if (!data)
return -ENOMEM;
sigfillset(&sigset);
if (sigprocmask(SIG_SETMASK, &sigset, &oset) < 0) {
err = errno;
goto err;
}
data->cpu = cpu;
data->sigset = oset;
err = pthread_create(&cpu_threads[cpu], NULL, cpu_thread, data);
if (sigprocmask(SIG_SETMASK, &oset, NULL) < 0)
panic("Failed to restore the signal mask, errno = %d", errno);
if (err != 0)
goto err;
return 0;
err:
kfree(data);
return -err;
}
void os_start_secondary(void *arg, jmp_buf *switch_buf)
{
struct cpu_thread_data *data = arg;
sigaddset(&data->sigset, IPI_SIGNAL);
sigaddset(&data->sigset, SIGIO);
if (sigprocmask(SIG_SETMASK, &data->sigset, NULL) < 0)
panic("Failed to restore the signal mask, errno = %d", errno);
kfree(data);
longjmp(*switch_buf, 1);
/* unreachable */
printk(UM_KERN_ERR "impossible long jump!");
fatal_sigsegv();
}
int os_send_ipi(int cpu, int vector)
{
union sigval value = { .sival_int = vector };
return pthread_sigqueue(cpu_threads[cpu], IPI_SIGNAL, value);
}
static void __local_ipi_set(int enable)
{
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, IPI_SIGNAL);
if (sigprocmask(enable ? SIG_UNBLOCK : SIG_BLOCK, &sigset, NULL) < 0)
Annotation
- Immediate include surface: `errno.h`, `pthread.h`, `signal.h`, `kern_util.h`, `um_malloc.h`, `init.h`, `os.h`, `smp.h`.
- Detected declarations: `struct cpu_thread_data`, `function uml_curr_cpu`, `function os_start_cpu_thread`, `function os_start_secondary`, `function os_send_ipi`, `function __local_ipi_set`, `function os_local_ipi_enable`, `function os_local_ipi_disable`, `function ipi_sig_handler`, `function os_init_smp`.
- Atlas domain: Architecture Layer / arch/um.
- 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.