From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 22:32:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5BD1254C127; Thu, 25 Feb 2021 22:32:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dmnb8250Bz3s2N; Thu, 25 Feb 2021 22:32:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30C211F94B; Thu, 25 Feb 2021 22:32:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PMW4MW010564; Thu, 25 Feb 2021 22:32:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PMW4i6010563; Thu, 25 Feb 2021 22:32:04 GMT (envelope-from git) Date: Thu, 25 Feb 2021 22:32:04 GMT Message-Id: <202102252232.11PMW4i6010563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Watson Subject: git: 97bfffafda88 - releng/13.0 - Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rwatson X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 97bfffafda88fde623ca732efbb089cae9eb209f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 22:32:04 -0000 The branch releng/13.0 has been updated by rwatson: URL: https://cgit.FreeBSD.org/src/commit/?id=97bfffafda88fde623ca732efbb089cae9eb209f commit 97bfffafda88fde623ca732efbb089cae9eb209f Author: Robert Watson AuthorDate: 2021-02-16 15:19:05 +0000 Commit: Robert Watson CommitDate: 2021-02-25 22:31:52 +0000 Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. Approved by: re (gjb) Reviewed by: andrew, bsdimp (older version) Useful comments appreciated: jrtc27, emaste Differential Revision: https://reviews.freebsd.org/D28723 --- sys/cddl/dev/dtrace/aarch64/dtrace_subr.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c index 6646e51fc191..9bf9f0798bb5 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c @@ -153,23 +153,26 @@ dtrace_sync(void) } /* - * DTrace needs a high resolution time function which can - * be called from a probe context and guaranteed not to have - * instrumented with probes itself. + * DTrace needs a high resolution time function which can be called from a + * probe context and guaranteed not to have instrumented with probes itself. * - * Returns nanoseconds since boot. + * Returns nanoseconds since some arbitrary point in time (likely SoC reset?). */ uint64_t -dtrace_gethrtime() +dtrace_gethrtime(void) { - struct timespec curtime; - - dtrace_getnanouptime(&curtime); - - return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec); + uint64_t count, freq; + count = READ_SPECIALREG(cntvct_el0); + freq = READ_SPECIALREG(cntfrq_el0); + return ((1000000000UL * count) / freq); } +/* + * Return a much lower resolution wallclock time based on the system clock + * updated by the timer. If needed, we could add a version interpolated from + * the system clock as is the case with dtrace_gethrtime(). + */ uint64_t dtrace_gethrestime(void) {