我刚刚导航到Linux arm内核树,我在汇编文件中看到了ALT_SMP和ALT_UP的用法,它们到底是什么用的?
答案 0 :(得分:0)
参考 https://github.com/torvalds/linux/blob/master/arch/arm/include/asm/assembler.h#L169
ALT_SMP
应该仅表示在SMP, Symmetric MultiProcessing
系统中执行。
#ifdef CONFIG_SMP
#define ALT_SMP(instr...) \
9998: instr
#define ALT_UP(instr...) \
.pushsection ".alt.smp.init", "a" ;\
.long 9998b ;\
9997: instr ;\
.if . - 9997b != 4 ;\
.error "ALT_UP() content must assemble to exactly 4 bytes";\
.endif ;\
.popsection
// skipped
#else
#define ALT_SMP(instr...)
#define ALT_UP(instr...) instr
考虑此背景UP
应该是Uni Processor
。
同样来自linux-arm-kernel
上的mail:
ALT_ {UP,SMP}宏用于在运行时修补指令 取决于我们是否在SMP平台上运行。这是 通常在外部汇编代码中完成,但也有需要 用于内联汇编(例如自旋锁)的此功能。