Corrected gettimeofday() test code

Don Bowman don at sandvine.com
Sat Nov 29 15:28:11 PST 2003


From: Kris Kennaway [mailto:kris at obsecurity.org]
> 
> I forwarded the reports of timecounter problems to phk, and he asked
> that people who are seeing timecounter problems provide FULL details
> of their system configuration, including:
> 
> * dmesg
> 
> * kernel configuration
> 
> * compiler options
> 
> * time-related system configuration (whether ntpd/timed/ntpdate is
> running, and if so whether it's correcting for a seriously drifting
> clock)
> 
> * The kernel timecounter configuration, e.g. the
> kern.timecounter.method and kern.timecounter.hardware sysctls, and
> whether changing them has any effect.
> 
> * The exact output of the corrected test program below (the original
> would give spurious errors if it didn't run at least once a second,
> which may have been confusing some people if their systems were
> sufficiently loaded).
> 
> * The system status when the problem is observed (i.e. does it only
> occur under load; what else is running at the time)
> 

For this config (below), kern.timecounter.method=0 reproduces the
problem, kern.timecounter.method=1 does not.

Output in 'error' case:
1070147643.248866 1070147651.028646 1070147643.248866 1070147651.028646
1070147656.287818 1070147664.067692 1070147656.287818 1070147664.067692
1070147659.326429 1070147667.106238 1070147659.326429 1070147667.106238
1070147668.370071 1070147676.149884 1070147668.370071 1070147676.149884
1070147681.433111 1070147689.212926 1070147681.433111 1070147689.212926
1070147683.418743 1070147691.198632 1070147683.418743 1070147691.198632

problem shows up within ~30s of starting the test program, and the messages
will come out about once per 1-5s period after that, not regularly.

kern.timecounter.hardware: TSC

on this machine, i have others which are i8254 which do it too.

hw.ncpu=1

compiler flags:
COPTFLAGS= -O2 -pipe -malign-loops=4 -malign-jumps=4 -malign-functions=4
-mcpu=i686 -march=i686 -fno-gcse -g



machine is running 4.7-RELEASE-p2.

dmesg, kernel config attached.


Intel-specific functions:
Version 00000673:
Type 0 - Original OEM
Family 6 - Pentium Pro
Model 7 - Pentium III/Pentium III Xeon - external L2 cache
Stepping 3
Reserved 0

from cpuid.

ntpd -p /var/run/ntpd.pid -b -g -A
runs.

Clock does not drift much, less than 2s/day. Clock is 
stepped when system boots. There is a chimer on our router 
which broadcasts ntp time every minute. ntpd is not
observed to step clock.

On the 8254 machine [a dual 0f27 xeon, 533 FSB with HTT enabled]
1070147645.119531 1070148340.497729 1070148339.-693880469 1070148340.497729

both systems were unloaded. This was with the corrected program
you included.

--don

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmesg.boot
Type: application/octet-stream
Size: 3605 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20031129/de27f7d9/dmesg.obj
-------------- next part --------------
___#
___# GENERIC -- Generic kernel configuration file for FreeBSD/i386
___#
___# For more information on this file, please read the handbook section on
___# Kernel Configuration Files:
___#
___#    http://www.FreeBSD.org/handbook/kernelconfig-config.html
___#
___# The handbook is also available locally in /usr/share/doc/handbook
___# if you've installed the doc distribution, otherwise always see the
___# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
___# latest information.
___#
___# An exhaustive list of options and more detailed explanations of the
___# device lines is also present in the ./LINT configuration file. If you are
___# in doubt as to the purpose or necessity of a line, check first in LINT.
___#
___# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.39 2002/03/24 13:19:10 wilko Exp $
___machine		i386
___#cpu		I386_CPU
___#cpu		I486_CPU
___cpu		I586_CPU
___cpu		I686_CPU
___ident		TPC
___maxusers	0
___makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
___#options 	MATH_EMULATE		#Support for x87 emulation
___options 	INET			#InterNETworking
___#options 	INET6			#IPv6 communications protocols
___options 	FFS			#Berkeley Fast Filesystem
___options 	FFS_ROOT		#FFS usable as root device [keep this!]
___options 	SOFTUPDATES		#Enable FFS soft updates support
___options 	UFS_DIRHASH		#Improve performance on big directories
___options 	MFS			#Memory Filesystem
___options 	MD_ROOT			#MD is a potential root device
___options 	NFS			#Network Filesystem
___options 	NFS_ROOT		#NFS usable as root device, NFS required
___options 	MSDOSFS			#MSDOS Filesystem
___options 	CD9660			#ISO 9660 Filesystem
___options 	CD9660_ROOT		#CD-ROM usable as root, CD9660 required
___options 	PROCFS			#Process filesystem
___options 	COMPAT_43		#Compatible with BSD 4.3 [KEEP THIS!]
___options 	SCSI_DELAY=2000		#Delay (in ms) before probing SCSI
___options 	UCONSOLE		#Allow users to grab the console
___options 	USERCONFIG		#boot -c editor
___options 	VISUAL_USERCONFIG	#visual boot -c editor
___options 	KTRACE			#ktrace(1) support
___options 	SYSVSHM			#SYSV-style shared memory
___options 	SYSVMSG			#SYSV-style message queues
___options 	SYSVSEM			#SYSV-style semaphores
___options 	P1003_1B		#Posix P1003_1B real-time extensions
___options 	_KPOSIX_PRIORITY_SCHEDULING
___options		ICMP_BANDLIM		#Rate limit bad replies
___options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
___# To make an SMP kernel, the next two are needed
___#options 	SMP			# Symmetric MultiProcessor Kernel
___#options 	APIC_IO			# Symmetric (APIC) I/O
___device		isa
___device		eisa
___device		pci
___# Floppy drives
___device		fdc0	at isa? port IO_FD1 irq 6 drq 2
___device		fd0	at fdc0 drive 0
___device		fd1	at fdc0 drive 1
___#
___# ATA and ATAPI devices
___device		ata0	at isa? port IO_WD1 irq 14
___device		ata1	at isa? port IO_WD2 irq 15
___device		ata
___device		atadisk			# ATA disk drives
___device		atapicd			# ATAPI CDROM drives
___device		atapifd			# ATAPI floppy drives
___device		atapist			# ATAPI tape drives
___options 	ATA_STATIC_ID		#Static device numbering
___# SCSI Controllers
___device		ahb		# EISA AHA1742 family
___device		ahc		# AHA2940 and onboard AIC7xxx devices
___device		amd		# AMD 53C974 (Tekram DC-390(T))
___device		isp		# Qlogic family
___device		ncr		# NCR/Symbios Logic
___device		sym		# NCR/Symbios Logic (newer chipsets)
___options		SYM_SETUP_LP_PROBE_MAP=0x40
___				# Allow ncr to attach legacy NCR devices when 
___				# both sym and ncr are configured
___device		adw
___device		ncv		# NCR 53C500
___device		nsp		# Workbit Ninja SCSI-3
___device		stg		# TMC 18C30/18C50
___# SCSI peripherals
___device		scbus		# SCSI bus (required)
___device		da		# Direct Access (disks)
___device		sa		# Sequential Access (tape etc)
___device		cd		# CD
___device		pass		# Passthrough device (direct SCSI access)
___# RAID controllers interfaced to the SCSI subsystem
___device		asr		# DPT SmartRAID V, VI and Adaptec SCSI RAID
___device		dpt		# DPT Smartcache - See LINT for options!
___device		mly		# Mylex AcceleRAID/eXtremeRAID
___device          ciss		# Compaq SmartRAID 5* series
___# RAID controllers
___device		aac		# Adaptec FSA RAID, Dell PERC2/PERC3
___device		ida		# Compaq Smart RAID
___device		amr		# AMI MegaRAID
___device		mlx		# Mylex DAC960 family
___device		twe		# 3ware Escalade
___# atkbdc0 controls both the keyboard and the PS/2 mouse
___device		atkbdc0	at isa? port IO_KBD
___device		atkbd0	at atkbdc? irq 1 flags 0x1
___device		psm0	at atkbdc? irq 12
___device		vga0	at isa?
___# splash screen/screen saver
___pseudo-device	splash
___# syscons is the default console driver, resembling an SCO console
___device		sc0	at isa? flags 0x100
___# Enable this and PCVT_FREEBSD for pcvt vt220 compatible console driver
___#device		vt0	at isa?
___#options 	XSERVER			# support for X server on a vt console
___#options 	FAT_CURSOR		# start with block cursor
___# If you have a ThinkPAD, uncomment this along with the rest of the PCVT lines
___#options 	PCVT_SCANSET=2		# IBM keyboards are non-std
___# Floating point support - do not disable.
___device		npx0	at nexus? port IO_NPX irq 13
___# Power management support (see LINT for more options)
___#device		apm0    at nexus? disable flags 0x20 # Advanced Power Management
___# Serial (COM) ports
___device		sio0	at isa? port IO_COM1 flags 0x10 irq 4
___device		sio1	at isa? port IO_COM2 irq 3
___# PCI Ethernet NICs that use the common MII bus controller code.
___# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
___#device		miibus		# MII bus support
___#device		fxp		# Intel EtherExpress PRO/100B (82557, 82558)
___#device		wx		# Intel Gigabit Ethernet Card (``Wiseman'')
___#device		xl		# 3Com 3c90x (``Boomerang'', ``Cyclone'')
___#device		bge		# Broadcom BCM570x (``Tigon III'')
___#device		gx
___#device		em		# Intel Gigabit cards
___# Pseudo devices - the number indicates how many units to allocate.
___pseudo-device	loop		# Network loopback
___pseudo-device	ether		# Ethernet support
___#pseudo-device	sl	1	# Kernel SLIP
___#pseudo-device	ppp	1	# Kernel PPP
___pseudo-device	tun		# Packet tunnel.
___pseudo-device	pty		# Pseudo-ttys (telnet etc)
___pseudo-device	md		# Memory "disks"
___#pseudo-device	gif		# IPv6 and IPv4 tunneling
___#pseudo-device	faith	1	# IPv6-to-IPv4 relaying (translation)
___# The `bpf' pseudo-device enables the Berkeley Packet Filter.
___# Be aware of the administrative consequences of enabling this!
___pseudo-device	bpf		#Berkeley packet filter
___# USB support
___device		uhci		# UHCI PCI->USB interface
___device		ohci		# OHCI PCI->USB interface
___device		usb		# USB Bus (required)
___device		ugen		# Generic
___device		uhid		# "Human Interface Devices"
___device		ukbd		# Keyboard
___device		ulpt		# Printer
___device		umass		# Disks/Mass storage - Requires scbus and da
___device		ums		# Mouse
___device		uscanner	# Scanners
___device		urio		# Diamond Rio MP3 Player
___# USB Ethernet, requires mii
___#device		aue		# ADMtek USB ethernet
___#device		cue		# CATC USB ethernet
___#device		kue		# Kawasaki LSI USB ethernet
___# Local options
___options 	HZ=1000
___options 	INCLUDE_CONFIG_FILE	# Include this file in kernel
___options 	IPFIREWALL		#firewall
___options 	IPFIREWALL_DEFAULT_TO_ACCEPT	#allow everything by default
___options 	IPFIREWALL_FORWARD	#enable transparent proxy support
___options 	IPDIVERT		#divert sockets
___#options 	DUMMYNET
___#options 	BRIDGE
___options 	RANDOM_IP_ID
___#options 	TCP_DROP_SYNFIN		#drop TCP packets with SYN+FIN
___options 	EXT2FS			#Add linux FS support
___options 	MAXDSIZ="(512*1024*1024)"
___options 	DFLDSIZ="(512*1024*1024)"
___options 	NETSMB			#SMB/CIFS requester
___options 	NETSMBCRYPTO		#encrypted password support for SMB
___options 	LIBMCHAIN		#mbuf management library
___options 	LIBICONV		#Kernel side iconv library
___options		SMBFS			#SMB/CIFS filesystem
___options 	CONSPEED=115200		# speed for serial console
___options 	USER_LDT		#allow user-level control of i386 ldt
___options 	CPU_ENABLE_SSE
___#options		IPFW2
___device smbus
___device iicbus
___device iicbb
___device intpm
___device alpm
___device ichsmb
___device smb
___device pcf


More information about the freebsd-current mailing list