From owner-svn-src-all@freebsd.org Sun Aug 23 18:03:44 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BF899C157B; Sun, 23 Aug 2015 18:03:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3FE131431; Sun, 23 Aug 2015 18:03:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NI3ila037928; Sun, 23 Aug 2015 18:03:44 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NI3hMU037926; Sun, 23 Aug 2015 18:03:43 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231803.t7NI3hMU037926@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 18:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287042 - in stable/10: share/man/man4 sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 18:03:44 -0000 Author: ian Date: Sun Aug 23 18:03:43 2015 New Revision: 287042 URL: https://svnweb.freebsd.org/changeset/base/287042 Log: MFC r286701: If a specific timecounter has been chosen via sysctl, and a new timecounter with higher quality registers (presumably in a module that has just been loaded), do not undo the user's choice by switching to the new timecounter. Document that behavior, and also the fact that there is no way to unregister a timecounter (and thus no way to unload a module containing one). Modified: stable/10/share/man/man4/timecounters.4 stable/10/sys/kern/kern_tc.c Modified: stable/10/share/man/man4/timecounters.4 ============================================================================== --- stable/10/share/man/man4/timecounters.4 Sun Aug 23 18:00:19 2015 (r287041) +++ stable/10/share/man/man4/timecounters.4 Sun Aug 23 18:03:43 2015 (r287042) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 12, 2014 +.Dd August 12, 2015 .Dt TIMECOUNTERS 4 .Os .Sh NAME @@ -96,10 +96,16 @@ compared to others. A negative value means this time counter is broken and should not be used. .El .Pp -The time management code of the kernel chooses one time counter from that list. -The current choice can be read and affected via the +The time management code of the kernel automatically switches to a +higher-quality time counter when it registers, unless the .Va kern.timecounter.hardware -tunable/sysctl. +sysctl has been used to choose a specific device. +.Pp +There is no way to unregister a time counter once it has registered +with the kernel. +If a dynamically loaded module contains a time counter you will not +be able to unload that module, even if the time counter it contains +is not the one currently in use. .Sh SEE ALSO .Xr attimer 4 , .Xr eventtimers 4 , Modified: stable/10/sys/kern/kern_tc.c ============================================================================== --- stable/10/sys/kern/kern_tc.c Sun Aug 23 18:00:19 2015 (r287041) +++ stable/10/sys/kern/kern_tc.c Sun Aug 23 18:03:43 2015 (r287042) @@ -133,6 +133,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents"); +static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ + static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -1180,10 +1182,13 @@ tc_init(struct timecounter *tc) "quality", CTLFLAG_RD, &(tc->tc_quality), 0, "goodness of time counter"); /* - * Never automatically use a timecounter with negative quality. + * Do not automatically switch if the current tc was specifically + * chosen. Never automatically use a timecounter with negative quality. * Even though we run on the dummy counter, switching here may be - * worse since this timecounter may not be monotonous. + * worse since this timecounter may not be monotonic. */ + if (tc_chosen) + return; if (tc->tc_quality < 0) return; if (tc->tc_quality < timecounter->tc_quality) @@ -1411,9 +1416,12 @@ sysctl_kern_timecounter_hardware(SYSCTL_ strlcpy(newname, tc->tc_name, sizeof(newname)); error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req); - if (error != 0 || req->newptr == NULL || - strcmp(newname, tc->tc_name) == 0) + if (error != 0 || req->newptr == NULL) return (error); + /* Record that the tc in use now was specifically chosen. */ + tc_chosen = 1; + if (strcmp(newname, tc->tc_name) == 0) + return (0); for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) { if (strcmp(newname, newtc->tc_name) != 0) continue; @@ -1434,7 +1442,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, "Timecounter hardware selected"); -/* Report or change the active timecounter hardware. */ +/* Report the available timecounter hardware. */ static int sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS) {