Bug 16113

Summary: Kernel page fault panic using sysctl to change timer frequency
Product: Base System Reporter: stenn <stenn>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description stenn 2000-01-13 22:50:01 UTC
	Wrote a perl script to wiggle the timer frequency, based on ntpd's
	/etc/ntp.drift file and input from PHK.  It seems to work fine on
	2-STABLE and -CURRENT, but it panics a 3-STABLE kernel with a
	page fault.

How-To-Repeat: 
	Run ntpd long enough to get a valid /etc/ntp.drift file.
	Run the following script.

	#! /usr/bin/perl -w

	$driftfile = "/etc/ntp.drift";

	open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
	while(<DF>) {
	    chop;
	    if (/^-?\d+\.\d+$/) {
		$drift = $_;
	    } else {
		die "Bogus value in driftfile $driftfile: <$_>\n";
	    }
	}
	close(DF);

	print "drift is      <$drift>\n";

	$freq_adj = 1 - $drift / 1000000;

	print "freq_adj is <$freq_adj>\n";

	chop($i8254_freq = `sysctl -n machdep.i8254_freq`);
	chop($tsc_freq = `sysctl -n machdep.tsc_freq 2> /dev/null`);

	print "i8254_freq is <$i8254_freq>\n";
	print "tsc_freq is   <$tsc_freq>\n";

	if ($i8254_freq > 1) {
	    $i8254_freq = int $i8254_freq * $freq_adj;
	    print "i8254_freq -> <$i8254_freq>\n";
	    print "i8254: ".`sysctl -w machdep.i8254_freq=$i8254_freq`;
	}

	if ($tsc_freq > 1) {
	    $tsc_freq = int $tsc_freq * $freq_adj;
	    print "tsc_freq ->   <$tsc_freq>\n";
	    print "tsc: ".`sysctl -w machdep.tsc_freq=$tsc_freq`;
	}
Comment 1 Bruce Evans freebsd_committer freebsd_triage 2000-01-18 16:26:28 UTC
State Changed
From-To: open->closed

Hopefully fixed in clock.c rev.1.129.2.6. 
The bug fixed only affects systems with unfortunate configurations 
(ones with a TSC, but with the TSC unused due to use of apm, 
misconfiguration of apm (configured but not active), or use of SMP. 
or use of a CPU with a known broken TSC.