From nobody Tue Nov 16 18:27:36 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 488EA189368F; Tue, 16 Nov 2021 18:27:37 +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 4HtvgF0FnMz4RKx; Tue, 16 Nov 2021 18:27:36 +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 D1C491259A; Tue, 16 Nov 2021 18:27:36 +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 1AGIRaYx078565; Tue, 16 Nov 2021 18:27:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AGIRat4078564; Tue, 16 Nov 2021 18:27:36 GMT (envelope-from git) Date: Tue, 16 Nov 2021 18:27:36 GMT Message-Id: <202111161827.1AGIRat4078564@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 57a8fa6f0189 - main - kvmclock: Expose implied TSC frequency via sysctl List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 57a8fa6f0189316ab4d13ffbc6dc5410d56dcbac Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=57a8fa6f0189316ab4d13ffbc6dc5410d56dcbac commit 57a8fa6f0189316ab4d13ffbc6dc5410d56dcbac Author: Colin Percival AuthorDate: 2021-11-16 18:21:31 +0000 Commit: Colin Percival CommitDate: 2021-11-16 18:27:27 +0000 kvmclock: Expose implied TSC frequency via sysctl An interface was added to derive an implied TSC frequency from pvclock in 2015, but this interface was never exposed anywhere user-visible. Reviewed by: kib, bryanv Differential Revision: https://reviews.freebsd.org/D32974 --- sys/dev/kvm_clock/kvm_clock.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c index 1a76432e417d..747b98c4f173 100644 --- a/sys/dev/kvm_clock/kvm_clock.c +++ b/sys/dev/kvm_clock/kvm_clock.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -77,6 +78,7 @@ static devclass_t kvm_clock_devclass; static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); static void kvm_clock_system_time_enable_pcpu(void *arg); +static void kvm_clock_setup_sysctl(device_t); static struct pvclock_wall_clock * kvm_clock_get_wallclock(void *arg) @@ -166,6 +168,7 @@ kvm_clock_attach(device_t dev) sc->pvc.timeinfos = sc->timeinfos; sc->pvc.stable_flag_supported = stable_flag_supported; pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); + kvm_clock_setup_sysctl(dev); return (0); } @@ -217,6 +220,29 @@ kvm_clock_settime(device_t dev, struct timespec *ts) return (0); } +static int +kvm_clock_tsc_freq_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct kvm_clock_softc *sc = oidp->oid_arg1; + uint64_t freq = pvclock_tsc_freq(sc->timeinfos); + + return (sysctl_handle_64(oidp, &freq, 0, req)); +} + +static void +kvm_clock_setup_sysctl(device_t dev) +{ + struct kvm_clock_softc *sc = device_get_softc(dev); + struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); + struct sysctl_oid *tree = device_get_sysctl_tree(dev); + struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); + + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tsc_freq", + CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + kvm_clock_tsc_freq_sysctl, "QU", + "Time Stamp Counter frequency"); +} + static device_method_t kvm_clock_methods[] = { DEVMETHOD(device_identify, kvm_clock_identify), DEVMETHOD(device_probe, kvm_clock_probe),