gpt4 book ai didi

linux - ALT_SMP 和 ALT_UP 有什么作用?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:36:36 30 4
gpt4 key购买 nike

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

最佳答案

指的是 https://github.com/torvalds/linux/blob/master/arch/arm/include/asm/assembler.h#L169

ALT_SMP 应该表示仅在SMP、对称多处理 系统中执行。

#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

也来自这个maillinux-arm-kernel 上:

The ALT_{UP,SMP} macros are used to patch instructions at runtime depending on whether we are running on an SMP platform or not. This is generally done in out-of-line assembly code, but there is also the need for this functionality in inline assembly (e.g. spinlocks).

关于linux - ALT_SMP 和 ALT_UP 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17083941/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com