From owner-dev-commits-src-branches@freebsd.org Mon Mar 15 06:23:15 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 91C7B57184B; Mon, 15 Mar 2021 06:23:15 +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 4DzRDz3l5Nz3tYq; Mon, 15 Mar 2021 06:23:15 +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 68DA13478; Mon, 15 Mar 2021 06:23:15 +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 12F6NFZE066526; Mon, 15 Mar 2021 06:23:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12F6NFSG066525; Mon, 15 Mar 2021 06:23:15 GMT (envelope-from git) Date: Mon, 15 Mar 2021 06:23:15 GMT Message-Id: <202103150623.12F6NFSG066525@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 791b89dad7c2 - stable/12 - Make kern.timecounter.hardware tunable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 791b89dad7c2f13c00f6771891da2a8506a5544b 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: Mon, 15 Mar 2021 06:23:15 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=791b89dad7c2f13c00f6771891da2a8506a5544b commit 791b89dad7c2f13c00f6771891da2a8506a5544b Author: Konstantin Belousov AuthorDate: 2021-03-07 23:50:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-03-15 06:22:40 +0000 Make kern.timecounter.hardware tunable (cherry picked from commit 56b9bee63a42dbac712acf540f23a4c3dbd099a9) --- sys/kern/kern_tc.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index f916cbc75ac8..7f9b48cb1dd4 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -136,6 +136,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, volatile int rtc_generation = 1; static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ +static char tc_from_tunable[16]; static void tc_windup(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); @@ -1195,11 +1196,17 @@ tc_init(struct timecounter *tc) return; if (tc->tc_quality < 0) return; - if (tc->tc_quality < timecounter->tc_quality) - return; - if (tc->tc_quality == timecounter->tc_quality && - tc->tc_frequency < timecounter->tc_frequency) - return; + if (tc_from_tunable[0] != '\0' && + strcmp(tc->tc_name, tc_from_tunable) == 0) { + tc_chosen = 1; + tc_from_tunable[0] = '\0'; + } else { + if (tc->tc_quality < timecounter->tc_quality) + return; + if (tc->tc_quality == timecounter->tc_quality && + tc->tc_frequency < timecounter->tc_frequency) + return; + } (void)tc->tc_get_timecount(tc); timecounter = tc; } @@ -1479,8 +1486,9 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS) return (EINVAL); } -SYSCTL_PROC(_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING | CTLFLAG_RW, - 0, 0, sysctl_kern_timecounter_hardware, "A", +SYSCTL_PROC(_kern_timecounter, OID_AUTO, hardware, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, 0, 0, + sysctl_kern_timecounter_hardware, "A", "Timecounter hardware selected"); @@ -1918,6 +1926,9 @@ inittimehands(void *dummy) for (i = 1, thp = &ths[0]; i < timehands_count; thp = &ths[i++]) thp->th_next = &ths[i]; thp->th_next = &ths[0]; + + TUNABLE_STR_FETCH("kern.timecounter.hardware", tc_from_tunable, + sizeof(tc_from_tunable)); } SYSINIT(timehands, SI_SUB_TUNABLES, SI_ORDER_ANY, inittimehands, NULL);