Mark 'ticks', 'time_second', and 'time_uptime' as volatile to prevent the
compiler from caching their values in tight loops. Reviewed by: bde MFC after: 1 week
This commit is contained in:
parent
4e67575ec9
commit
a8df530ddc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246037
@ -500,6 +500,7 @@ cdce_attach(device_t dev)
|
|||||||
const struct usb_interface_descriptor *id;
|
const struct usb_interface_descriptor *id;
|
||||||
const struct usb_cdc_ethernet_descriptor *ued;
|
const struct usb_cdc_ethernet_descriptor *ued;
|
||||||
const struct usb_config *pcfg;
|
const struct usb_config *pcfg;
|
||||||
|
uint32_t seed;
|
||||||
int error;
|
int error;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t data_iface_no;
|
uint8_t data_iface_no;
|
||||||
@ -612,8 +613,9 @@ cdce_attach(device_t dev)
|
|||||||
/* fake MAC address */
|
/* fake MAC address */
|
||||||
|
|
||||||
device_printf(dev, "faking MAC address\n");
|
device_printf(dev, "faking MAC address\n");
|
||||||
|
seed = ticks;
|
||||||
sc->sc_ue.ue_eaddr[0] = 0x2a;
|
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);
|
sc->sc_ue.ue_eaddr[5] = device_get_unit(dev);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,7 +382,7 @@ static void watchdog_config(void *, u_int, int *);
|
|||||||
int stathz;
|
int stathz;
|
||||||
int profhz;
|
int profhz;
|
||||||
int profprocs;
|
int profprocs;
|
||||||
int ticks;
|
volatile int ticks;
|
||||||
int psratio;
|
int psratio;
|
||||||
|
|
||||||
static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */
|
static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */
|
||||||
@ -469,7 +469,7 @@ void
|
|||||||
hardclock(int usermode, uintfptr_t pc)
|
hardclock(int usermode, uintfptr_t pc)
|
||||||
{
|
{
|
||||||
|
|
||||||
atomic_add_int((volatile int *)&ticks, 1);
|
atomic_add_int(&ticks, 1);
|
||||||
hardclock_cpu(usermode);
|
hardclock_cpu(usermode);
|
||||||
tc_ticktock(1);
|
tc_ticktock(1);
|
||||||
cpu_tick_calibration();
|
cpu_tick_calibration();
|
||||||
|
@ -103,8 +103,8 @@ static struct timecounter *timecounters = &dummy_timecounter;
|
|||||||
|
|
||||||
int tc_min_ticktock_freq = 1;
|
int tc_min_ticktock_freq = 1;
|
||||||
|
|
||||||
time_t time_second = 1;
|
volatile time_t time_second = 1;
|
||||||
time_t time_uptime = 1;
|
volatile time_t time_uptime = 1;
|
||||||
|
|
||||||
struct bintime boottimebin;
|
struct bintime boottimebin;
|
||||||
struct timeval boottime;
|
struct timeval boottime;
|
||||||
|
@ -1386,7 +1386,7 @@ static char *ncr_name (ncb_p np)
|
|||||||
* Kernel variables referenced in the scripts.
|
* Kernel variables referenced in the scripts.
|
||||||
* THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
|
* THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
|
||||||
*/
|
*/
|
||||||
static void *script_kvars[] =
|
static volatile void *script_kvars[] =
|
||||||
{ &time_second, &ticks, &ncr_cache };
|
{ &time_second, &ticks, &ncr_cache };
|
||||||
|
|
||||||
static struct script script0 = {
|
static struct script script0 = {
|
||||||
|
@ -63,7 +63,7 @@ extern int psratio; /* ratio: prof / stat */
|
|||||||
extern int stathz; /* statistics clock's frequency */
|
extern int stathz; /* statistics clock's frequency */
|
||||||
extern int profhz; /* profiling clock's frequency */
|
extern int profhz; /* profiling clock's frequency */
|
||||||
extern int profprocs; /* number of process's profiling */
|
extern int profprocs; /* number of process's profiling */
|
||||||
extern int ticks;
|
extern volatile int ticks;
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
@ -287,8 +287,8 @@ struct clockinfo {
|
|||||||
void inittodr(time_t base);
|
void inittodr(time_t base);
|
||||||
void resettodr(void);
|
void resettodr(void);
|
||||||
|
|
||||||
extern time_t time_second;
|
extern volatile time_t time_second;
|
||||||
extern time_t time_uptime;
|
extern volatile time_t time_uptime;
|
||||||
extern struct bintime boottimebin;
|
extern struct bintime boottimebin;
|
||||||
extern struct timeval boottime;
|
extern struct timeval boottime;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user