From f92a69f9079bc6aba242b90f185b5f40ee424fa2 Mon Sep 17 00:00:00 2001 From: Guoqi Chen Date: Fri, 5 Aug 2022 13:32:08 +0800 Subject: [PATCH] runtime: implement cputicks with the stable counter on loong64 The stable counter is described in Section 2.2.10.4, LoongArch Reference Manual Volume 1. Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html Change-Id: I160b695a8c0e38ef49b21fb8b41460fd23d9538c Reviewed-on: https://go-review.googlesource.com/c/go/+/421656 Reviewed-by: Meidan Li TryBot-Result: Gopher Robot Reviewed-by: Wayne Zuo Reviewed-by: David Chase Run-TryBot: Wayne Zuo Reviewed-by: WANG Xuerui Reviewed-by: Michael Pratt --- src/runtime/asm_loong64.s | 6 ++++++ src/runtime/cputicks.go | 2 +- src/runtime/os_linux_loong64.go | 7 ------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/runtime/asm_loong64.s b/src/runtime/asm_loong64.s index 58e6286385..2513d2bb54 100644 --- a/src/runtime/asm_loong64.s +++ b/src/runtime/asm_loong64.s @@ -86,6 +86,12 @@ TEXT runtime·mstart(SB),NOSPLIT|TOPFRAME,$0 JAL runtime·mstart0(SB) RET // not reached +// func cputicks() int64 +TEXT runtime·cputicks(SB),NOSPLIT,$0-8 + RDTIMED R0, R4 + MOVV R4, ret+0(FP) + RET + /* * go-routine */ diff --git a/src/runtime/cputicks.go b/src/runtime/cputicks.go index 91270617fc..2cf3240333 100644 --- a/src/runtime/cputicks.go +++ b/src/runtime/cputicks.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !arm && !arm64 && !loong64 && !mips64 && !mips64le && !mips && !mipsle && !wasm +//go:build !arm && !arm64 && !mips64 && !mips64le && !mips && !mipsle && !wasm package runtime diff --git a/src/runtime/os_linux_loong64.go b/src/runtime/os_linux_loong64.go index 3d84e9accb..61213dadf8 100644 --- a/src/runtime/os_linux_loong64.go +++ b/src/runtime/os_linux_loong64.go @@ -9,10 +9,3 @@ package runtime func archauxv(tag, val uintptr) {} func osArchInit() {} - -//go:nosplit -func cputicks() int64 { - // Currently cputicks() is used in blocking profiler and to seed fastrand(). - // nanotime() is a poor approximation of CPU ticks that is enough for the profiler. - return nanotime() -} -- 2.48.1