arch/x86/kernel/apic/ipi.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/apic/ipi.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/apic/ipi.c- Extension
.c- Size
- 7320 bytes
- Lines
- 292
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpumask.hlinux/delay.hlinux/smp.hlinux/string_choices.hasm/io_apic.hlocal.h
Detected Declarations
function apic_ipi_shorthandfunction print_ipi_modefunction apic_smt_updatefunction apic_send_IPI_allbutselffunction native_smp_send_reschedulefunction native_send_call_func_single_ipifunction native_send_call_func_ipifunction apic_send_nmi_to_offline_cpufunction __prepare_ICR2function apic_mem_wait_icr_idle_timeoutfunction apic_mem_wait_icr_idlefunction wait_icr_idlefunction notationfunction default_send_IPI_single_physfunction default_send_IPI_mask_sequence_physfunction default_send_IPI_mask_allbutself_physfunction default_send_IPI_singlefunction default_send_IPI_allbutselffunction default_send_IPI_allfunction default_send_IPI_selffunction default_send_IPI_mask_sequence_logicalfunction default_send_IPI_mask_allbutself_logicalfunction default_send_IPI_mask_logical
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/cpumask.h>
#include <linux/delay.h>
#include <linux/smp.h>
#include <linux/string_choices.h>
#include <asm/io_apic.h>
#include "local.h"
DEFINE_STATIC_KEY_FALSE(apic_use_ipi_shorthand);
#ifdef CONFIG_SMP
static int apic_ipi_shorthand_off __ro_after_init;
static __init int apic_ipi_shorthand(char *str)
{
get_option(&str, &apic_ipi_shorthand_off);
return 1;
}
__setup("no_ipi_broadcast=", apic_ipi_shorthand);
static int __init print_ipi_mode(void)
{
pr_info("IPI shorthand broadcast: %s\n",
str_disabled_enabled(apic_ipi_shorthand_off));
return 0;
}
late_initcall(print_ipi_mode);
void apic_smt_update(void)
{
/*
* Do not switch to broadcast mode if:
* - Disabled on the command line
* - Only a single CPU is online
* - Not all present CPUs have been at least booted once
*
* The latter is important as the local APIC might be in some
* random state and a broadcast might cause havoc. That's
* especially true for NMI broadcasting.
*/
if (apic_ipi_shorthand_off || num_online_cpus() == 1 ||
!cpumask_equal(cpu_present_mask, &cpus_booted_once_mask)) {
static_branch_disable(&apic_use_ipi_shorthand);
} else {
static_branch_enable(&apic_use_ipi_shorthand);
}
}
void apic_send_IPI_allbutself(unsigned int vector)
{
if (num_online_cpus() < 2)
return;
if (static_branch_likely(&apic_use_ipi_shorthand))
__apic_send_IPI_allbutself(vector);
else
__apic_send_IPI_mask_allbutself(cpu_online_mask, vector);
}
/*
* Send a 'reschedule' IPI to another CPU. It goes straight through and
* wastes no time serializing anything. Worst case is that we lose a
* reschedule ...
*/
void native_smp_send_reschedule(int cpu)
{
if (unlikely(cpu_is_offline(cpu))) {
WARN(1, "sched: Unexpected reschedule of offline CPU#%d!\n", cpu);
return;
}
__apic_send_IPI(cpu, RESCHEDULE_VECTOR);
}
void native_send_call_func_single_ipi(int cpu)
{
__apic_send_IPI(cpu, CALL_FUNCTION_SINGLE_VECTOR);
}
void native_send_call_func_ipi(const struct cpumask *mask)
{
if (static_branch_likely(&apic_use_ipi_shorthand)) {
unsigned int cpu = smp_processor_id();
if (!cpumask_or_equal(mask, cpumask_of(cpu), cpu_online_mask))
goto sendmask;
if (cpumask_test_cpu(cpu, mask))
Annotation
- Immediate include surface: `linux/cpumask.h`, `linux/delay.h`, `linux/smp.h`, `linux/string_choices.h`, `asm/io_apic.h`, `local.h`.
- Detected declarations: `function apic_ipi_shorthand`, `function print_ipi_mode`, `function apic_smt_update`, `function apic_send_IPI_allbutself`, `function native_smp_send_reschedule`, `function native_send_call_func_single_ipi`, `function native_send_call_func_ipi`, `function apic_send_nmi_to_offline_cpu`, `function __prepare_ICR2`, `function apic_mem_wait_icr_idle_timeout`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.