svn commit: r277406 - in head/sys: kern sys x86/x86
Neel Natu
neel at FreeBSD.org
Tue Jan 20 03:54:32 UTC 2015
Author: neel
Date: Tue Jan 20 03:54:30 2015
New Revision: 277406
URL: https://svnweb.freebsd.org/changeset/base/277406
Log:
Update the vdso timehands only via tc_windup().
Prior to this change CLOCK_MONOTONIC could go backwards when the timecounter
hardware was changed via 'sysctl kern.timecounter.hardware'. This happened
because the vdso timehands update was missing the special treatment in
tc_windup() when changing timecounters.
Reviewed by: kib
Modified:
head/sys/kern/kern_tc.c
head/sys/kern/subr_dummy_vdso_tc.c
head/sys/sys/vdso.h
head/sys/x86/x86/tsc.c
Modified: head/sys/kern/kern_tc.c
==============================================================================
--- head/sys/kern/kern_tc.c Tue Jan 20 02:24:08 2015 (r277405)
+++ head/sys/kern/kern_tc.c Tue Jan 20 03:54:30 2015 (r277406)
@@ -1424,7 +1424,15 @@ sysctl_kern_timecounter_hardware(SYSCTL_
(void)newtc->tc_get_timecount(newtc);
timecounter = newtc;
- timekeep_push_vdso();
+
+ /*
+ * The vdso timehands update is deferred until the next
+ * 'tc_windup()'.
+ *
+ * This is prudent given that 'timekeep_push_vdso()' does not
+ * use any locking and that it can be called in hard interrupt
+ * context via 'tc_windup()'.
+ */
return (0);
}
return (EINVAL);
@@ -1982,7 +1990,6 @@ sysctl_fast_gettime(SYSCTL_HANDLER_ARGS)
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,
@@ -2002,7 +2009,7 @@ tc_fill_vdso_timehands(struct vdso_timeh
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);
+ enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter);
if (!vdso_th_enable)
enabled = 0;
return (enabled);
@@ -2024,7 +2031,7 @@ tc_fill_vdso_timehands32(struct vdso_tim
*(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);
+ enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter);
if (!vdso_th_enable)
enabled = 0;
return (enabled);
Modified: head/sys/kern/subr_dummy_vdso_tc.c
==============================================================================
--- head/sys/kern/subr_dummy_vdso_tc.c Tue Jan 20 02:24:08 2015 (r277405)
+++ head/sys/kern/subr_dummy_vdso_tc.c Tue Jan 20 03:54:30 2015 (r277406)
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/vdso.h>
uint32_t
-cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th)
+cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc)
{
return (0);
@@ -41,7 +41,8 @@ cpu_fill_vdso_timehands(struct vdso_time
#ifdef COMPAT_FREEBSD32
uint32_t
-cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
+cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
+ struct timecounter *tc)
{
return (0);
Modified: head/sys/sys/vdso.h
==============================================================================
--- head/sys/sys/vdso.h Tue Jan 20 02:24:08 2015 (r277405)
+++ head/sys/sys/vdso.h Tue Jan 20 03:54:30 2015 (r277406)
@@ -69,6 +69,8 @@ int __vdso_gettimekeep(struct vdso_timek
#ifdef _KERNEL
+struct timecounter;
+
void timekeep_push_vdso(void);
uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th);
@@ -81,7 +83,8 @@ uint32_t tc_fill_vdso_timehands(struct v
* global sysctl enable override is handled by machine-independed code
* after cpu_fill_vdso_timehands() call is made.
*/
-uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th);
+uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th,
+ struct timecounter *tc);
#define VDSO_TH_NUM 4
@@ -110,7 +113,8 @@ struct vdso_timekeep32 {
};
uint32_t tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32);
-uint32_t cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32);
+uint32_t cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
+ struct timecounter *tc);
#endif
#endif
Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c Tue Jan 20 02:24:08 2015 (r277405)
+++ head/sys/x86/x86/tsc.c Tue Jan 20 03:54:30 2015 (r277406)
@@ -720,21 +720,22 @@ tsc_get_timecount_low_mfence(struct time
}
uint32_t
-cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th)
+cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc)
{
- vdso_th->th_x86_shift = (int)(intptr_t)timecounter->tc_priv;
+ vdso_th->th_x86_shift = (int)(intptr_t)tc->tc_priv;
bzero(vdso_th->th_res, sizeof(vdso_th->th_res));
- return (timecounter == &tsc_timecounter);
+ return (tc == &tsc_timecounter);
}
#ifdef COMPAT_FREEBSD32
uint32_t
-cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
+cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
+ struct timecounter *tc)
{
- vdso_th32->th_x86_shift = (int)(intptr_t)timecounter->tc_priv;
+ vdso_th32->th_x86_shift = (int)(intptr_t)tc->tc_priv;
bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res));
- return (timecounter == &tsc_timecounter);
+ return (tc == &tsc_timecounter);
}
#endif
More information about the svn-src-all
mailing list