[Midnightbsd-cvs] src [8300] trunk/sys/kern/kern_tc.c: sync with freebsd 9.2
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 18:21:27 EDT 2016
Revision: 8300
http://svnweb.midnightbsd.org/src/?rev=8300
Author: laffer1
Date: 2016-09-17 18:21:27 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
sync with freebsd 9.2
Modified Paths:
--------------
trunk/sys/kern/kern_tc.c
Modified: trunk/sys/kern/kern_tc.c
===================================================================
--- trunk/sys/kern/kern_tc.c 2016-09-17 22:18:39 UTC (rev 8299)
+++ trunk/sys/kern/kern_tc.c 2016-09-17 22:21:27 UTC (rev 8300)
@@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$MidnightBSD$");
+__MBSDID("$MidnightBSD$");
#include "opt_compat.h"
#include "opt_ntp.h"
@@ -21,6 +21,7 @@
#include <sys/timepps.h>
#include <sys/timetc.h>
#include <sys/timex.h>
+#include <sys/vdso.h>
/*
* A large step happens on boot. This constant detects such steps.
@@ -90,8 +91,8 @@
int tc_min_ticktock_freq = 1;
-time_t time_second = 1;
-time_t time_uptime = 1;
+volatile time_t time_second = 1;
+volatile time_t time_uptime = 1;
struct bintime boottimebin;
struct timeval boottime;
@@ -514,10 +515,10 @@
/* Now is a good time to change timecounters. */
if (th->th_counter != timecounter) {
#ifndef __arm__
- if ((timecounter->tc_flags & TC_FLAGS_C2STOP) != 0)
- cpu_disable_c2_sleep++;
- if ((th->th_counter->tc_flags & TC_FLAGS_C2STOP) != 0)
- cpu_disable_c2_sleep--;
+ if ((timecounter->tc_flags & TC_FLAGS_C3STOP) != 0)
+ cpu_disable_deep_sleep++;
+ if ((th->th_counter->tc_flags & TC_FLAGS_C3STOP) != 0)
+ cpu_disable_deep_sleep--;
#endif
th->th_counter = timecounter;
th->th_offset_count = ncount;
@@ -565,6 +566,7 @@
time_second = th->th_microtime.tv_sec;
time_uptime = th->th_offset.sec;
timehands = th;
+ timekeep_push_vdso();
}
/* Report or change the active timecounter hardware. */
@@ -591,6 +593,7 @@
(void)newtc->tc_get_timecount(newtc);
timecounter = newtc;
+ timekeep_push_vdso();
return (0);
}
return (EINVAL);
@@ -981,3 +984,63 @@
}
cpu_tick_f *cpu_ticks = tc_cpu_ticks;
+
+static int vdso_th_enable = 1;
+static int
+sysctl_fast_gettime(SYSCTL_HANDLER_ARGS)
+{
+ int old_vdso_th_enable, error;
+
+ old_vdso_th_enable = vdso_th_enable;
+ error = sysctl_handle_int(oidp, &old_vdso_th_enable, 0, req);
+ if (error != 0)
+ return (error);
+ vdso_th_enable = old_vdso_th_enable;
+ timekeep_push_vdso();
+ return (0);
+}
+SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime,
+ CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
+ NULL, 0, sysctl_fast_gettime, "I", "Enable fast time of day");
+
+uint32_t
+tc_fill_vdso_timehands(struct vdso_timehands *vdso_th)
+{
+ struct timehands *th;
+ uint32_t enabled;
+
+ th = timehands;
+ vdso_th->th_algo = VDSO_TH_ALGO_1;
+ vdso_th->th_scale = th->th_scale;
+ vdso_th->th_offset_count = th->th_offset_count;
+ vdso_th->th_counter_mask = th->th_counter->tc_counter_mask;
+ vdso_th->th_offset = th->th_offset;
+ vdso_th->th_boottime = boottimebin;
+ enabled = cpu_fill_vdso_timehands(vdso_th);
+ if (!vdso_th_enable)
+ enabled = 0;
+ return (enabled);
+}
+
+#ifdef COMPAT_FREEBSD32
+uint32_t
+tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
+{
+ struct timehands *th;
+ uint32_t enabled;
+
+ th = timehands;
+ vdso_th32->th_algo = VDSO_TH_ALGO_1;
+ *(uint64_t *)&vdso_th32->th_scale[0] = th->th_scale;
+ vdso_th32->th_offset_count = th->th_offset_count;
+ vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask;
+ vdso_th32->th_offset.sec = th->th_offset.sec;
+ *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac;
+ vdso_th32->th_boottime.sec = boottimebin.sec;
+ *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac;
+ enabled = cpu_fill_vdso_timehands32(vdso_th32);
+ if (!vdso_th_enable)
+ enabled = 0;
+ return (enabled);
+}
+#endif
More information about the Midnightbsd-cvs
mailing list