github.com/lrita/numa@v1.0.2/numa_linux_amd64.s (about)

     1  #include "textflag.h"
     2  
     3  // long vdsoGetCPU(unsigned *, unsigned *, void *)
     4  //
     5  // func getcpu() {
     6  //   vdsoGetCPU(&cpu, &node, NULL)
     7  // }
     8  TEXT ·getcpu(SB), NOSPLIT|NEEDCTXT, $0-0 // this function is running g0 stack, we can overflow safety.
     9  	// We don't know how much stack space the VDSO code will need.
    10  	// In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n
    11  	// and hardening can use a full page of stack space in gettime_sym
    12  	// due to stack probes inserted to avoid stack/heap collisions.
    13  	//
    14  	// https://github.com/golang/go/issues/20427#issuecomment-343255844
    15  
    16  	MOVQ	SP, R12	        // Save old SP; BP unchanged by C code.
    17  
    18  	MOVQ	8(DX), DI       // &cpu
    19  	MOVQ	16(DX), SI      // &node
    20  	MOVQ	$0, DX	        // tcache = NULL
    21  
    22  	SUBQ	$16, SP         //
    23  	ANDQ	$~15, SP        // Align for C code
    24  
    25  	MOVQ	·vdsoGetCPU(SB), AX
    26  	CALL	AX
    27  
    28  	MOVQ	R12, SP		// Restore real SP
    29  
    30  	RET
    31  
    32  TEXT ·GetCPUAndNode(SB),NOSPLIT,$32-16
    33  	// check support fastway
    34  	CMPB	·fastway(SB), $0
    35  	JE	no_fastway
    36  	// RDTSCP go1.11 support RDTSCP opcode but go1.10 not
    37  	BYTE	$0x0F; BYTE $0x01; BYTE $0xF9
    38  	MOVL	CX, AX
    39  	SHRL	$12, AX
    40  	ANDL	$4095, CX
    41  	MOVQ	CX, cpu+0(FP)
    42  	MOVQ	AX, node+8(FP)
    43  	RET
    44  
    45  no_fastway:
    46  	MOVQ    $0, cpu+0(FP)
    47  	MOVQ    $0, node+8(FP)
    48  
    49  	LEAQ	·getcpu(SB), AX
    50  	MOVQ	AX, fn-24(SP)
    51  	LEAQ	cpu+0(FP), AX
    52  	MOVQ	AX, cpu-16(SP)
    53  	LEAQ	node+8(FP), AX
    54  	MOVQ	AX, node-8(SP)
    55  
    56  	LEAQ	fn-24(SP), AX
    57  	MOVQ	AX, zone-32(SP)
    58  
    59  	CALL	runtime·systemstack(SB)
    60  
    61  	RET