23.4 Establishing the Multi-Core Communication Mechanism
Across symmetric multiprocessing (SMP) environments, an individual CPU core frequently needs to instruct alternative processor cores to execute a designated callback function. The specific systemic responsibility of call_function_init() is to bootstrap the localized call_single_queue lockless execution queues assigned to each CPU core to house these inbound remote invocation requests.
The function is hosted within the core symmetric multiprocessing source file git/kernel/smp.c, and its definition is implemented as follows:
void __init call_function_init(void)
{
int i;
for_each_possible_cpu(i)
init_llist_head(&per_cpu(call_single_queue, i));
smpcfd_prepare_cpu(smp_processor_id());
}
Within a multi-core SMP hardware topology, CPU $X$ occasionally needs to force CPU $Y$ to execute a target code routine (for instance, mutating control registers localized on CPU $Y$, or forcefully flushing CPU $Y$'s private TLB caches). This coordination paradigm is designated as an Inter-Processor Interrupt Function Call (IPI Function Call). When an active processor core requests an alternate core to run a specific function, the requesting context invokes the kernel interface smp_call_function_single(target_cpu, func, ...). The kernel encapsulates the target callback func into an executable message descriptor object and appends this block onto the tail boundary of the destination core's private call_single_queue. Following this insertion, the requesting core propagates an Inter-Processor Interrupt (IPI) across the system bus, asserting a hardware interrupt on the destination CPU core. Upon catching this IPI exception, the destination core drops into its registered interrupt service routine, drains its local call_single_queue queue, and sequentially processes the attached function descriptors.
The function call_function_init() initializes this critical inter-processor invocation queue architecture within the Linux kernel. Its primary technical objective is to assemble the data structures consumed by the mechanism that dispatches function execution requests across cross-core boundaries.
The routine first iterates systematically through every possible CPU core configured inside the system topology, leveraging the helper routine init_llist_head() to initialize the head descriptor of the lockless linked list call_single_queue bound to each respective core. Whenever an external CPU core attempts to delegate an execution task over to this specific processor, the task node is appended straight onto this local call_single_queue registry.
Upon completing this comprehensive traversal across all possible CPU nodes, the function calls smpcfd_prepare_cpu() to bootstrap the Call Function Data (CFD) structures assigned to the active primary bootstrap CPU core. This pass guarantees that the primary core can safely receive and process asynchronous inter-processor requests forwarded from alternative cores moving forward.
Conceptually, the execution of call_function_init() builds the inner postal delivery system connecting the individual processor cores. Once this infrastructure is operational, the disparate CPU cores gain the ability to smoothly request function execution passes from one another.
At this specific checkpoint along the start_kernel() boot sequence, local hardware interrupts must remain strictly disabled, because the system is executing its final preparatory logic immediately preceding the invocation of local_irq_enable(). If hardware interrupts were to accidentally toggle into an active state at this moment, it would indicate that an upstream initialization function erroneously manipulated the hardware interrupt control registers, introducing severe system instability.
To enforce this architectural constraint, the code block immediately following call_function_init() dispatches an assertion macro, WARN(!irqs_disabled(), ...), executing a definitive audit of the processor's interrupt flags to guarantee that all local hardware interrupts remain locked down.