1

我刚刚导航到 Linux arm 内核树,我在汇编文件中看到了 ALT_SMP 和 ALT_UP 的用法,它们到底是做什么用的?

4

1 回答 1

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

ALT_{UP,SMP} 宏用于在运行时修补指令,具体取决于我们是否在 SMP 平台上运行。这通常在外联汇编代码中完成,但在内联汇编(例如自旋锁)中也需要此功能。

于 2013-06-13T12:50:50.290 回答