[Midnightbsd-cvs] src [8874] trunk/sys: mark ticks as volatile to avoid the compiler from caching in tight loops
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Sep 26 09:21:02 EDT 2016
Revision: 8874
http://svnweb.midnightbsd.org/src/?rev=8874
Author: laffer1
Date: 2016-09-26 09:21:02 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
mark ticks as volatile to avoid the compiler from caching in tight loops
Modified Paths:
--------------
trunk/sys/kern/kern_clock.c
trunk/sys/sys/kernel.h
Modified: trunk/sys/kern/kern_clock.c
===================================================================
--- trunk/sys/kern/kern_clock.c 2016-09-26 13:20:01 UTC (rev 8873)
+++ trunk/sys/kern/kern_clock.c 2016-09-26 13:21:02 UTC (rev 8874)
@@ -381,7 +381,7 @@
int stathz;
int profhz;
int profprocs;
-int ticks;
+volatile int ticks;
int psratio;
static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */
@@ -468,7 +468,7 @@
hardclock(int usermode, uintfptr_t pc)
{
- atomic_add_int((volatile int *)&ticks, 1);
+ atomic_add_int(&ticks, 1);
hardclock_cpu(usermode);
tc_ticktock(1);
cpu_tick_calibration();
Modified: trunk/sys/sys/kernel.h
===================================================================
--- trunk/sys/sys/kernel.h 2016-09-26 13:20:01 UTC (rev 8873)
+++ trunk/sys/sys/kernel.h 2016-09-26 13:21:02 UTC (rev 8874)
@@ -63,7 +63,7 @@
extern int stathz; /* statistics clock's frequency */
extern int profhz; /* profiling clock's frequency */
extern int profprocs; /* number of process's profiling */
-extern int ticks;
+extern volatile int ticks;
#endif /* _KERNEL */
More information about the Midnightbsd-cvs
mailing list