存放当前cpu的per_cpu变量的offset值,来自__per_cpu_offset[x]
在计算per_cpu变量对应当前cpu的实际虚拟地址时会用到。
案例(对per_cpu变量overflow_stack的获取):
[以下代码来自Linux kernel 5.14 rc6]
arch/arm64/kernel/entry.S
/* Switch to the overflow stack */
adr_this_cpu sp, overflow_stack + OVERFLOW_STACK_SIZE, x0
.macro get_this_cpu_offset, dst
mrs \dst, tpidr_el1
.endm
/*
* @dst: Result of per_cpu(sym, smp_processor_id()) (can be SP)
* @sym: The name of the per-cpu variable
* @tmp: scratch register
*/
.macro adr_this_cpu, dst, sym, tmp
adrp \tmp, \sym
add \dst, \tmp, #:lo12:\sym
get_this_cpu_offset \tmp
add \dst, \dst, \tmp
.endm