From owner-svn-src-all@FreeBSD.ORG Mon Jan 28 19:38:14 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E2600A7F; Mon, 28 Jan 2013 19:38:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D4ABA74F; Mon, 28 Jan 2013 19:38:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0SJcEwR091858; Mon, 28 Jan 2013 19:38:14 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0SJcDKp091851; Mon, 28 Jan 2013 19:38:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201301281938.r0SJcDKp091851@svn.freebsd.org> From: John Baldwin Date: Mon, 28 Jan 2013 19:38:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246037 - in head/sys: dev/usb/net kern pci sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2013 19:38:15 -0000 Author: jhb Date: Mon Jan 28 19:38:13 2013 New Revision: 246037 URL: http://svnweb.freebsd.org/changeset/base/246037 Log: 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 Modified: head/sys/dev/usb/net/if_cdce.c head/sys/kern/kern_clock.c head/sys/kern/kern_tc.c head/sys/pci/ncr.c head/sys/sys/kernel.h head/sys/sys/time.h Modified: head/sys/dev/usb/net/if_cdce.c ============================================================================== --- head/sys/dev/usb/net/if_cdce.c Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/dev/usb/net/if_cdce.c Mon Jan 28 19:38:13 2013 (r246037) @@ -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: head/sys/kern/kern_clock.c ============================================================================== --- head/sys/kern/kern_clock.c Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/kern/kern_clock.c Mon Jan 28 19:38:13 2013 (r246037) @@ -382,7 +382,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. */ @@ -469,7 +469,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: head/sys/kern/kern_tc.c ============================================================================== --- head/sys/kern/kern_tc.c Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/kern/kern_tc.c Mon Jan 28 19:38:13 2013 (r246037) @@ -103,8 +103,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: head/sys/pci/ncr.c ============================================================================== --- head/sys/pci/ncr.c Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/pci/ncr.c Mon Jan 28 19:38:13 2013 (r246037) @@ -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: head/sys/sys/kernel.h ============================================================================== --- head/sys/sys/kernel.h Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/sys/kernel.h Mon Jan 28 19:38:13 2013 (r246037) @@ -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: head/sys/sys/time.h ============================================================================== --- head/sys/sys/time.h Mon Jan 28 17:25:53 2013 (r246036) +++ head/sys/sys/time.h Mon Jan 28 19:38:13 2013 (r246037) @@ -287,8 +287,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;