aboutsummaryrefslogtreecommitdiffstats
path: root/init/calibrate.c
diff options
context:
space:
mode:
authorAlok Kataria <akataria@vmware.com>2008-06-20 18:06:33 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-23 16:51:33 -0400
commit3da757daf86e498872855f0b5e101f763ba79499 (patch)
treebffffafed7322c66a1b886b661cfd8a8a7f5a924 /init/calibrate.c
parente01b70ef3eb3080fecc35e15f68cd274c0a48163 (diff)
x86: use cpu_khz for loops_per_jiffy calculation
On the x86 platform we can use the value of tsc_khz computed during tsc calibration to calculate the loops_per_jiffy value. Its very important to keep the error in lpj values to minimum as any error in that may result in kernel panic in check_timer. In virtualization environment, On a highly overloaded host the guest delay calibration may sometimes result in errors beyond the ~50% that timer_irq_works can handle, resulting in the guest panicking. Does some formating changes to lpj_setup code to now have a single printk to print the bogomips value. We do this only for the boot processor because the AP's can have different base frequencies or the BIOS might boot a AP at a different frequency. Signed-off-by: Alok N Kataria <akataria@vmware.com> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Daniel Hecht <dhecht@vmware.com> Cc: Tim Mann <mann@vmware.com> Cc: Zach Amsden <zach@vmware.com> Cc: Sahil Rihan <srihan@vmware.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'init/calibrate.c')
-rw-r--r--init/calibrate.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/init/calibrate.c b/init/calibrate.c
index ecb3822d4f70..86286974dada 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -8,7 +8,9 @@
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/timex.h> 10#include <linux/timex.h>
11#include <linux/smp.h>
11 12
13unsigned long lpj_tsc;
12unsigned long preset_lpj; 14unsigned long preset_lpj;
13static int __init lpj_setup(char *str) 15static int __init lpj_setup(char *str)
14{ 16{
@@ -108,6 +110,10 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;}
108 * This is the number of bits of precision for the loops_per_jiffy. Each 110 * This is the number of bits of precision for the loops_per_jiffy. Each
109 * bit takes on average 1.5/HZ seconds. This (like the original) is a little 111 * bit takes on average 1.5/HZ seconds. This (like the original) is a little
110 * better than 1% 112 * better than 1%
113 * For the boot cpu we can skip the delay calibration and assign it a value
114 * calculated based on the tsc frequency.
115 * For the rest of the CPUs we cannot assume that the tsc frequency is same as
116 * the cpu frequency, hence do the calibration for those.
111 */ 117 */
112#define LPS_PREC 8 118#define LPS_PREC 8
113 119
@@ -118,20 +124,20 @@ void __cpuinit calibrate_delay(void)
118 124
119 if (preset_lpj) { 125 if (preset_lpj) {
120 loops_per_jiffy = preset_lpj; 126 loops_per_jiffy = preset_lpj;
121 printk("Calibrating delay loop (skipped)... " 127 printk(KERN_INFO
122 "%lu.%02lu BogoMIPS preset\n", 128 "Calibrating delay loop (skipped) preset value.. ");
123 loops_per_jiffy/(500000/HZ), 129 } else if ((smp_processor_id() == 0) && lpj_tsc) {
124 (loops_per_jiffy/(5000/HZ)) % 100); 130 loops_per_jiffy = lpj_tsc;
131 printk(KERN_INFO
132 "Calibrating delay loop (skipped), "
133 "using tsc calculated value.. ");
125 } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { 134 } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) {
126 printk("Calibrating delay using timer specific routine.. "); 135 printk(KERN_INFO
127 printk("%lu.%02lu BogoMIPS (lpj=%lu)\n", 136 "Calibrating delay using timer specific routine.. ");
128 loops_per_jiffy/(500000/HZ),
129 (loops_per_jiffy/(5000/HZ)) % 100,
130 loops_per_jiffy);
131 } else { 137 } else {
132 loops_per_jiffy = (1<<12); 138 loops_per_jiffy = (1<<12);
133 139
134 printk(KERN_DEBUG "Calibrating delay loop... "); 140 printk(KERN_INFO "Calibrating delay loop... ");
135 while ((loops_per_jiffy <<= 1) != 0) { 141 while ((loops_per_jiffy <<= 1) != 0) {
136 /* wait for "start of" clock tick */ 142 /* wait for "start of" clock tick */
137 ticks = jiffies; 143 ticks = jiffies;
@@ -161,12 +167,8 @@ void __cpuinit calibrate_delay(void)
161 if (jiffies != ticks) /* longer than 1 tick */ 167 if (jiffies != ticks) /* longer than 1 tick */
162 loops_per_jiffy &= ~loopbit; 168 loops_per_jiffy &= ~loopbit;
163 } 169 }
164
165 /* Round the value and print it */
166 printk("%lu.%02lu BogoMIPS (lpj=%lu)\n",
167 loops_per_jiffy/(500000/HZ),
168 (loops_per_jiffy/(5000/HZ)) % 100,
169 loops_per_jiffy);
170 } 170 }
171 171 printk(KERN_INFO "%lu.%02lu BogoMIPS (lpj=%lu)\n",
172 loops_per_jiffy/(500000/HZ),
173 (loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy);
172} 174}