svn commit: r247555 - in stable/9/sys: dev/usb/net kern pci sys
John Baldwin
jhb at FreeBSD.org
Fri Mar 1 17:10:46 UTC 2013
Author: jhb
Date: Fri Mar 1 17:10:43 2013
New Revision: 247555
URL: http://svnweb.freebsd.org/changeset/base/247555
Log:
MFC 246037:
Mark 'ticks', 'time_second', and 'time_uptime' as volatile to prevent the
compiler from caching their values in tight loops.
Modified:
stable/9/sys/dev/usb/net/if_cdce.c
stable/9/sys/kern/kern_clock.c
stable/9/sys/kern/kern_tc.c
stable/9/sys/pci/ncr.c
stable/9/sys/sys/kernel.h
stable/9/sys/sys/time.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/dev/ (props changed)
Modified: stable/9/sys/dev/usb/net/if_cdce.c
==============================================================================
--- stable/9/sys/dev/usb/net/if_cdce.c Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/dev/usb/net/if_cdce.c Fri Mar 1 17:10:43 2013 (r247555)
@@ -500,6 +500,7 @@ cdce_attach(device_t dev)
const struct usb_interface_descriptor *id;
const struct usb_cdc_ethernet_descriptor *ued;
const struct usb_config *pcfg;
+ uint32_t seed;
int error;
uint8_t i;
uint8_t data_iface_no;
@@ -612,8 +613,9 @@ alloc_transfers:
/* fake MAC address */
device_printf(dev, "faking MAC address\n");
+ seed = ticks;
sc->sc_ue.ue_eaddr[0] = 0x2a;
- memcpy(&sc->sc_ue.ue_eaddr[1], &ticks, sizeof(uint32_t));
+ memcpy(&sc->sc_ue.ue_eaddr[1], &seed, sizeof(uint32_t));
sc->sc_ue.ue_eaddr[5] = device_get_unit(dev);
} else {
Modified: stable/9/sys/kern/kern_clock.c
==============================================================================
--- stable/9/sys/kern/kern_clock.c Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/kern/kern_clock.c Fri Mar 1 17:10:43 2013 (r247555)
@@ -381,7 +381,7 @@ static void watchdog_config(void *, u_in
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 @@ void
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: stable/9/sys/kern/kern_tc.c
==============================================================================
--- stable/9/sys/kern/kern_tc.c Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/kern/kern_tc.c Fri Mar 1 17:10:43 2013 (r247555)
@@ -91,8 +91,8 @@ static struct timecounter *timecounters
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;
Modified: stable/9/sys/pci/ncr.c
==============================================================================
--- stable/9/sys/pci/ncr.c Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/pci/ncr.c Fri Mar 1 17:10:43 2013 (r247555)
@@ -1386,7 +1386,7 @@ static char *ncr_name (ncb_p np)
* Kernel variables referenced in the scripts.
* THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
*/
-static void *script_kvars[] =
+static volatile void *script_kvars[] =
{ &time_second, &ticks, &ncr_cache };
static struct script script0 = {
Modified: stable/9/sys/sys/kernel.h
==============================================================================
--- stable/9/sys/sys/kernel.h Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/sys/kernel.h Fri Mar 1 17:10:43 2013 (r247555)
@@ -63,7 +63,7 @@ extern int psratio; /* ratio: prof / s
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 */
Modified: stable/9/sys/sys/time.h
==============================================================================
--- stable/9/sys/sys/time.h Fri Mar 1 16:19:09 2013 (r247554)
+++ stable/9/sys/sys/time.h Fri Mar 1 17:10:43 2013 (r247555)
@@ -281,8 +281,8 @@ struct clockinfo {
void inittodr(time_t base);
void resettodr(void);
-extern time_t time_second;
-extern time_t time_uptime;
+extern volatile time_t time_second;
+extern volatile time_t time_uptime;
extern struct bintime boottimebin;
extern struct timeval boottime;
More information about the svn-src-stable-9
mailing list