利用底层IPI处理器之间的中断机制,Linux内核可以实现在指定的CPU上执行某个函数的功能。本地CPU,即smp_processor_id()返回的CPU,通过调用smp_call_function函数来指定其他一个或若干个CPU来执行某个回调函数。
smp_call_function函数的基本参数包括:
- int cpu 被指定的一个cpu
- struct cpumask *mask 被指定的一个CPU集合,这里可能有两种模式
- 在指定的CPU集合内的任意一个CPU,在指定CPU集合中选择一个CPU的优先级为:本地cpu;当前NUMA结点上的cpu;其他在线cpu。
- 在指定CPU集合上的每一个CPU
- smp_call_func_t func 回调函数指针
- int wait 表示smp_call_function是否等待回调函数完成
指定CPU
int smp_call_function_single (int cpu, smp_call_func_t func, void *info, int wait)
指定CPU集合中的一个CPU
int smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, void *info, int wait)
指定CPU集合中的每一个CPU
void smp_call_function_many(const struct cpumask *mask, smp_call_func_t func, void *info, bool wait)
系统内其他所有CPU
void smp_call_function(smp_call_func_t func, void *info, int wait)



