DragonFly BSD
DragonFly submit List (threaded) for 2006-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

64-bit tsc_freq initial patch


From: Michal Belczyk <belczyk@xxxxxxxxxxxxx>
Date: Sat, 8 Jul 2006 21:11:25 +0200

Hello,

this is an initial patch to make tsc_freq 64-bit, please review.  Thanks.

-- 
Michal Belczyk
Index: sys/emulation/linux/i386/linprocfs/linprocfs_misc.c
===================================================================
RCS file: /home/dcvs/src/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c,v
retrieving revision 1.14
diff -u -r1.14 linprocfs_misc.c
--- sys/emulation/linux/i386/linprocfs/linprocfs_misc.c	6 Jan 2006 15:01:38 -0000	1.14
+++ sys/emulation/linux/i386/linprocfs/linprocfs_misc.c	8 Jul 2006 11:38:30 -0000
@@ -231,12 +231,12 @@
 	ps += sprintf(ps, "\n");
         if (class >= 5) {
 		ps += sprintf(ps,
-			"cpu MHz\t\t: %d.%02d\n"
-			"bogomips\t: %d.%02d\n",
+			"cpu MHz\t\t: %qu.%02d\n"
+			"bogomips\t: %qu.%02d\n",
                         (tsc_freq + 4999) / 1000000,
-                        ((tsc_freq + 4999) / 10000) % 100,
+                        (int)(((tsc_freq + 4999) / 10000) % 100),
                         (tsc_freq + 4999) / 1000000,
-                        ((tsc_freq + 4999) / 10000) % 100);
+                        (int)(((tsc_freq + 4999) / 10000) % 100));
         }
         
 	return (uiomove_frombuf(psbuf, ps - psbuf, uio));
Index: sys/i386/i386/identcpu.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/i386/identcpu.c,v
retrieving revision 1.10
diff -u -r1.10 identcpu.c
--- sys/i386/i386/identcpu.c	11 May 2006 16:44:43 -0000	1.10
+++ sys/i386/i386/identcpu.c	8 Jul 2006 11:39:04 -0000
@@ -591,17 +591,17 @@
 #endif
 #if defined(I586_CPU)
 	case CPUCLASS_586:
-		printf("%d.%02d-MHz ",
+		printf("%qu.%02d-MHz ",
 		       (tsc_freq + 4999) / 1000000,
-		       ((tsc_freq + 4999) / 10000) % 100);
+		       (int)(((tsc_freq + 4999) / 10000) % 100));
 		printf("586");
 		break;
 #endif
 #if defined(I686_CPU)
 	case CPUCLASS_686:
-		printf("%d.%02d-MHz ",
+		printf("%qu.%02d-MHz ",
 		       (tsc_freq + 4999) / 1000000,
-		       ((tsc_freq + 4999) / 10000) % 100);
+		       (int)(((tsc_freq + 4999) / 10000) % 100));
 		printf("686");
 		break;
 #endif
Index: sys/i386/i386/perfmon.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/i386/perfmon.c,v
retrieving revision 1.8
diff -u -r1.8 perfmon.c
--- sys/i386/i386/perfmon.c	19 May 2004 22:52:57 -0000	1.8
+++ sys/i386/i386/perfmon.c	8 Jul 2006 10:33:41 -0000
@@ -383,7 +383,7 @@
 		}
 		pmct = (struct pmc_tstamp *)param;
 		/* XXX interface loses precision. */
-		pmct->pmct_rate = tsc_freq / 1000000;
+		pmct->pmct_rate = (int)(tsc_freq / 1000000);
 		pmct->pmct_value = rdtsc();
 		rv = 0;
 		break;
Index: sys/i386/include/clock.h
===================================================================
RCS file: /home/dcvs/src/sys/i386/include/clock.h,v
retrieving revision 1.8
diff -u -r1.8 clock.h
--- sys/i386/include/clock.h	20 May 2006 02:42:06 -0000	1.8
+++ sys/i386/include/clock.h	8 Jul 2006 11:35:57 -0000
@@ -26,7 +26,7 @@
 extern u_int	timer_freq;
 extern int	timer0_max_count;
 extern int	tsc_present;
-extern u_int	tsc_freq;
+extern u_int64_t tsc_freq;
 extern int	tsc_is_broken;
 extern int	wall_cmos_clock;
 #ifdef APIC_IO
Index: sys/i386/isa/clock.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/isa/clock.c,v
retrieving revision 1.46
diff -u -r1.46 clock.c
--- sys/i386/isa/clock.c	25 Jan 2006 19:56:19 -0000	1.46
+++ sys/i386/isa/clock.c	8 Jul 2006 11:40:20 -0000
@@ -115,8 +115,7 @@
 int	disable_rtc_set;	/* disable resettodr() if != 0 */
 int	statclock_disable = 1;	/* we don't use the statclock right now */
 int	tsc_present;
-u_int	tsc_freq;		/* XXX obsolete, convert users */
-int64_t	tsc_frequency;
+u_int64_t tsc_freq;
 int	tsc_is_broken;
 int	wall_cmos_clock;	/* wall CMOS clock assumed if != 0 */
 int	timer0_running;
@@ -559,12 +558,11 @@
 	 * similar to those for the i8254 clock.
 	 */
 	if (tsc_present) {
-		tsc_frequency = rdtsc() - old_tsc;
-		tsc_freq = (u_int)tsc_frequency;	/* XXX */
+		tsc_freq = rdtsc() - old_tsc;
 	}
 
 	if (tsc_present)
-		printf("TSC clock: %u Hz, ", tsc_freq);
+		printf("TSC clock: %qu Hz, ", tsc_freq);
 	printf("i8254 clock: %u Hz\n", tot_count);
 	return (tot_count);
 
@@ -743,7 +741,6 @@
 		    "%d Hz differs from default of %d Hz by more than 1%%\n",
 			       freq, i8254_cputimer.freq);
 		tsc_freq = 0;
-		tsc_frequency = 0;
 	}
 
 #ifndef CLK_USE_TSC_CALIBRATION
@@ -752,10 +749,9 @@
 			printf(
 "CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
 		tsc_freq = 0;
-		tsc_frequency = 0;
 	}
 #endif
-	if (tsc_present && tsc_frequency == 0) {
+	if (tsc_present && tsc_freq == 0) {
 		/*
 		 * Calibration of the i586 clock relative to the mc146818A
 		 * clock failed.  Do a less accurate calibration relative
@@ -764,11 +760,10 @@
 		u_int64_t old_tsc = rdtsc();
 
 		DELAY(1000000);
-		tsc_frequency = rdtsc() - old_tsc;
-		tsc_freq = (u_int)tsc_frequency;
+		tsc_freq = rdtsc() - old_tsc;
 #ifdef CLK_USE_TSC_CALIBRATION
 		if (bootverbose)
-			printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
+			printf("TSC clock: %qu Hz (Method B)\n", tsc_freq);
 #endif
 	}
 
Index: sys/net/altq/altq_subr.c
===================================================================
RCS file: /home/dcvs/src/sys/net/altq/altq_subr.c,v
retrieving revision 1.7
diff -u -r1.7 altq_subr.c
--- sys/net/altq/altq_subr.c	28 Nov 2005 17:13:45 -0000	1.7
+++ sys/net/altq/altq_subr.c	8 Jul 2006 10:18:32 -0000
@@ -734,7 +734,7 @@
 	 * accessible, just use it.
 	 */
 #ifdef __i386__
-	machclk_freq = tsc_freq;
+	machclk_freq = (uint32_t)tsc_freq;	/* XXX */
 #else
 #error "machclk_freq interface not implemented"
 #endif
Index: sys/sys/gmon.h
===================================================================
RCS file: /home/dcvs/src/sys/sys/gmon.h,v
retrieving revision 1.3
diff -u -r1.3 gmon.h
--- sys/sys/gmon.h	21 May 2006 03:43:47 -0000	1.3
+++ sys/sys/gmon.h	8 Jul 2006 11:41:35 -0000
@@ -50,11 +50,11 @@
 	u_long	hpc;		/* max pc address of sampled buffer */
 	int	ncnt;		/* size of sample buffer (plus this header) */
 	int	version;	/* version number */
-	int	profrate;	/* profiling clock rate */
-	int	spare[3];	/* reserved */
+	u_int64_t profrate;	/* profiling clock rate */
+	int	spare[2];	/* reserved */
 	/* XXX should record counter size and density */
 };
-#define GMONVERSION	0x00051879
+#define GMONVERSION	0x0005187a
 
 /*
  * Type of histogram counters used in the kernel.
@@ -172,7 +172,7 @@
 	uintfptr_t	highpc;
 	u_long		textsize;
 	u_long		hashfraction;
-	int		profrate;	/* XXX wrong type to match gmonhdr */
+	u_int64_t	profrate;	/* XXX wrong type to match gmonhdr */
 	HISTCOUNTER	*cputime_count;
 	int		cputime_overhead;
 	HISTCOUNTER	*mcount_count;
Index: usr.bin/gprof/gprof.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/gprof/gprof.c,v
retrieving revision 1.5
diff -u -r1.5 gprof.c
--- usr.bin/gprof/gprof.c	22 Jan 2006 03:43:37 -0000	1.5
+++ usr.bin/gprof/gprof.c	8 Jul 2006 11:42:21 -0000
@@ -255,7 +255,7 @@
     struct gmonhdr	tmp;
     FILE		*pfile;
     int			size;
-    int			rate;
+    u_int64_t		rate;
 
     if((pfile = fopen(filename, "r")) == NULL) {
 	perror(filename);
@@ -281,7 +281,7 @@
 	hz = rate;
     } else if (hz != rate) {
 	fprintf(stderr,
-	    "%s: profile clock rate (%d) %s (%d) in first gmon file\n",
+	    "%s: profile clock rate (%qu) %s (%qu) in first gmon file\n",
 	    filename, rate, "incompatible with clock rate", hz);
 	done();
     }
@@ -301,7 +301,7 @@
 		lowpc , highpc );
 	    printf( "[openpfile] sampbytes %d nsamples %d\n" ,
 		sampbytes , nsamples );
-	    printf( "[openpfile] sample rate %d\n" , hz );
+	    printf( "[openpfile] sample rate %qu\n" , hz );
 	}
 #   endif /* DEBUG */
     return(pfile);
Index: usr.bin/gprof/gprof.h
===================================================================
RCS file: /home/dcvs/src/usr.bin/gprof/gprof.h,v
retrieving revision 1.1
diff -u -r1.1 gprof.h
--- usr.bin/gprof/gprof.h	17 Jun 2003 02:56:09 -0000	1.1
+++ usr.bin/gprof/gprof.h	8 Jul 2006 11:42:42 -0000
@@ -76,7 +76,7 @@
     /*
      *	ticks per second
      */
-long	hz;
+u_int64_t	hz;
 
 #ifdef GPROF4
 typedef	int64_t UNIT;
Index: usr.bin/ktrdump/ktrdump.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/ktrdump/ktrdump.c,v
retrieving revision 1.6
diff -u -r1.6 ktrdump.c
--- usr.bin/ktrdump/ktrdump.c	19 Dec 2005 17:09:58 -0000	1.6
+++ usr.bin/ktrdump/ktrdump.c	8 Jul 2006 10:20:14 -0000
@@ -67,7 +67,7 @@
 	{ "_ktr_idx" },
 	{ "_ktr_buf" },
 	{ "_ncpus" },
-	{ "_tsc_frequency" },
+	{ "_tsc_freq" },
 	{ NULL }
 };
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]