* [PATCH] preset loops_per_jiffy for faster booting
@ 2004-07-09 19:25 Tim Bird
2004-07-09 22:24 ` Adam Kropelin
2004-07-09 23:35 ` Adam Kropelin
0 siblings, 2 replies; 29+ messages in thread
From: Tim Bird @ 2004-07-09 19:25 UTC (permalink / raw)
To: linux kernel
Here is a patch which allows developers or users to preset the
value for loops per jiffy. This avoids the overhead of
performing the calibration at boot time. This saves about
250 milliseconds on many non-x86 architectures, and about
25 milliseconds on x86. (The amount of time saved depends
on the value of HZ, and NOT on the processor speed.)
Besides allowing a value to be compiled in, the patch also allows
the value to be specified on the kernel command line with
the syntax: "lpj=xxx" This is available whether the code
is configured with the option or not.
Finally, this code adds a new FASTBOOT menu to the kernel
config system, where we (CE Linux Forum developers) would like
to add this and other config options which can be used to
reduce kernel bootup time.
This technique (of disabling calibration for loops_per_jiffy)
is used by many embedded developers for reducing bootup time.
More commentary on this issue is available at:
http://tree.celinuxforum.org/pubwiki/moin.cgi/PresetLPJ
Comments are welcome.
Thanks.
=============================
Tim Bird
Bootup Time Working Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Electronics
E-mail: tim.bird@am.sony.com
=============================
preset-lpj.patch:
Signed-off-by: Tim Bird <tim.bird@am.sony.com> for CELF
---
Kconfig | 35 ++++++++++++++++++++++++++++
main.c | 78 +++++++++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 86 insertions(+), 27 deletions(-)
diff -ruN -x CVS -x '.#*' -X dontdiff tag_LINUX_2_6_7/init/Kconfig branch_PRESET_LPJ/init/Kconfig
--- tag_LINUX_2_6_7/init/Kconfig 2004-06-18 17:13:03.000000000 -0700
+++ branch_PRESET_LPJ/init/Kconfig 2004-06-22 13:16:05.000000000 -0700
@@ -218,6 +218,41 @@
This option enables access to kernel configuration file and build
information through /proc/config.gz.
+menuconfig FASTBOOT
+ bool "Fast boot options"
+ help
+ Say Y here to enable faster booting of the Linux kernel. If you
+ say Y here, you may be asked to provide hardcoded values for some
+ parameters that the kernel usually determines automatically.
+
+ If unsure, say N.
+
+config USE_PRESET_LPJ
+ bool "Use preset loops_per_jiffy" if FASTBOOT
+ help
+ Say Y here to use a preset value for loops_per_jiffy. This
+ is a value used internally in the kernel for busywait delays.
+ Calculating this value at boot time can take up to 250 ms.
+ Saying Y here, and specifying the value (next) will save
+ this time during boot up.
+
+ If unsure, say N.
+
+config PRESET_LPJ
+ int "Preset loops_per_jiffy" if USE_PRESET_LPJ
+ help
+ This is the number of loops used by delay() to achieve a single
+ jiffy of delay inside the kernel. It is roughly BogoMips * 5000.
+ To determine the correct value for your kernel, first turn off
+ the fast booting option, compile and boot the kernel on your
+ target hardware, then see what value is printed during the
+ kernel boot. Use that value here.
+
+ If unsure, don't enable the "Use preset loops_per_jiffy" option.
+ An incorrect value will cause delays in the kernel to be
+ incorrect. Although unlikely, in the extreme case this might
+ damage your hardware.
+
menuconfig EMBEDDED
bool "Configure standard kernel features (for small systems)"
diff -ruN -x CVS -x '.#*' -X dontdiff tag_LINUX_2_6_7/init/main.c branch_PRESET_LPJ/init/main.c
--- tag_LINUX_2_6_7/init/main.c 2004-06-18 17:13:02.000000000 -0700
+++ branch_PRESET_LPJ/init/main.c 2004-06-22 13:16:05.000000000 -0700
@@ -167,6 +167,15 @@
return 0;
}
+static int __init lpj_setup(char *str)
+{
+ /* low bit indicates a value provided at boot time */
+ loops_per_jiffy = simple_strtoul(str,NULL,10) | 1;
+ return 1;
+}
+
+__setup("lpj=", lpj_setup);
+
/* this should be approx 2 Bo*oMips to start (note initial shift), and will
still work even if initially too large, it will just take slightly longer */
unsigned long loops_per_jiffy = (1<<12);
@@ -183,40 +192,55 @@
unsigned long ticks, loopbit;
int lps_precision = LPS_PREC;
- loops_per_jiffy = (1<<12);
-
- printk("Calibrating delay loop... ");
- while ((loops_per_jiffy <<= 1) != 0) {
- /* wait for "start of" clock tick */
- ticks = jiffies;
- while (ticks == jiffies)
- /* nothing */;
- /* Go .. */
- ticks = jiffies;
- __delay(loops_per_jiffy);
- ticks = jiffies - ticks;
- if (ticks)
- break;
+#ifdef CONFIG_USE_PRESET_LPJ
+ /* if lpj is not provided on command line, use preset value */
+ if ((loops_per_jiffy & 1) == 0) {
+ loops_per_jiffy = CONFIG_PRESET_LPJ | 1;
}
+#endif /* CONFIG_USE_PRESET_LPJ */
-/* Do a binary approximation to get loops_per_jiffy set to equal one clock
- (up to lps_precision bits) */
- loops_per_jiffy >>= 1;
- loopbit = loops_per_jiffy;
- while ( lps_precision-- && (loopbit >>= 1) ) {
- loops_per_jiffy |= loopbit;
- ticks = jiffies;
- while (ticks == jiffies);
- ticks = jiffies;
- __delay(loops_per_jiffy);
- if (jiffies != ticks) /* longer than 1 tick */
- loops_per_jiffy &= ~loopbit;
+ if (loops_per_jiffy & 1) {
+ printk("Calibrating delay loop (skipped)... ");
+ } else {
+
+ printk("Calibrating delay loop... ");
+ while ((loops_per_jiffy <<= 1) != 0) {
+ /* wait for "start of" clock tick */
+ ticks = jiffies;
+ while (ticks == jiffies)
+ /* nothing */;
+ /* Go .. */
+ ticks = jiffies;
+ __delay(loops_per_jiffy);
+ ticks = jiffies - ticks;
+ if (ticks)
+ break;
+ }
+
+ /* Do a binary approximation to get loops_per_jiffy set to equal one clock
+ (up to lps_precision bits) */
+ loops_per_jiffy >>= 1;
+ loopbit = loops_per_jiffy;
+ while ( lps_precision-- && (loopbit >>= 1) ) {
+ loops_per_jiffy |= loopbit;
+ ticks = jiffies;
+ while (ticks == jiffies);
+ ticks = jiffies;
+ __delay(loops_per_jiffy);
+ if (jiffies != ticks) /* longer than 1 tick */
+ loops_per_jiffy &= ~loopbit;
+ }
}
-/* Round the value and print it */
+/* Round the value and print it */
printk("%lu.%02lu BogoMIPS\n",
loops_per_jiffy/(500000/HZ),
(loops_per_jiffy/(5000/HZ)) % 100);
+
+#ifndef CONFIG_USE_PRESET_LPJ
+ printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n",
+ loops_per_jiffy);
+#endif /* CONFIG_USE_PRESET_LPJ */
}
static int __init debug_kernel(char *str)
^ permalink raw reply [flat|nested] 29+ messages in thread* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-09 19:25 [PATCH] preset loops_per_jiffy for faster booting Tim Bird @ 2004-07-09 22:24 ` Adam Kropelin 2004-07-09 23:35 ` Adam Kropelin 1 sibling, 0 replies; 29+ messages in thread From: Adam Kropelin @ 2004-07-09 22:24 UTC (permalink / raw) To: Tim Bird; +Cc: linux kernel On Fri, Jul 09, 2004 at 12:25:03PM -0700, Tim Bird wrote: > Finally, this code adds a new FASTBOOT menu to the kernel > config system, where we (CE Linux Forum developers) would like > to add this and other config options which can be used to > reduce kernel bootup time. <snip> > +menuconfig FASTBOOT > + bool "Fast boot options" > + help > + Say Y here to enable faster booting of the Linux kernel. If you > + say Y here, you may be asked to provide hardcoded values for some > + parameters that the kernel usually determines automatically. If FASTBOOT is intended to be merely a container for individual related options, this help text seems misleading. FASTBOOT=y alone will have no effect on the kernel. It's just a gateway to other more specific options. Something like this may be better: Say Y here to select among various options that can decrease kernel boot time. These options commonly involve providing hardcoded values for some parameters that the kernel usually determines automatically. This option is useful primarily on embedded systems. If unsure, say N. > +config PRESET_LPJ > + int "Preset loops_per_jiffy" if USE_PRESET_LPJ > + help > + This is the number of loops used by delay() to achieve a single > + jiffy of delay inside the kernel. It is roughly BogoMips * 5000. > + To determine the correct value for your kernel, first turn off > + the fast booting option, compile and boot the kernel on your > + target hardware, then see what value is printed during the > + kernel boot. Use that value here. Perhaps mention the new lpj= parameter is an alternative: loops_per_jiffy can also be set via the "lpj=" kernel command line parameter. --Adam ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-09 19:25 [PATCH] preset loops_per_jiffy for faster booting Tim Bird 2004-07-09 22:24 ` Adam Kropelin @ 2004-07-09 23:35 ` Adam Kropelin 2004-07-10 0:20 ` Tim Bird 1 sibling, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-09 23:35 UTC (permalink / raw) To: Tim Bird; +Cc: linux kernel On Fri, Jul 09, 2004 at 12:25:03PM -0700, Tim Bird wrote: > Here is a patch which allows developers or users to preset the > value for loops per jiffy. This avoids the overhead of > performing the calibration at boot time. This saves about > 250 milliseconds on many non-x86 architectures, and about > 25 milliseconds on x86. (The amount of time saved depends > on the value of HZ, and NOT on the processor speed.) Here's an alternate patch (compile tested only) which is slightly simpler, slightly more flexible, and fixes a small bug in the original. The simplification centers around removing USE_PRESET_LPJ and interpeting a preset value of 0 as a signal to autodetect. This eliminates ifdefs in the code and avoids giving magic significance to the loops_per_jiffy LSb. Additionally, the user can always disable the preset by using "lpj=0" which would allow booting a kernel that crashes due to a bogus preset. The only problem I can think of with this approach is if there is a system out there so slow that lpj=0 is actually a valid setting. The final change is to fix a small bug in the original patch: loops_per_jiffy was no longer initialized each time calibrate_delay() was invoked. This is potentially an issue on SMP systems since calibrate_delay() will be invoked for each CPU. One related thing to keep in mind is that on an SMP system, using an lpj preset will result in the same lpj setting on each CPU. On sane systems this shouldn't be a problem, but if there's a machine out there with unequal CPUs it will be a problem. Perhaps this is worth mentioning in the help text as well. While we're on the topic: Should FASTBOOT perhaps depend on EMBEDDED? I can imagine a user with a massively MP system perhaps finding this option useful, so maybe not. --Adam --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Fri Jul 9 18:31:50 2004 @@ -167,6 +167,15 @@ return 0; } +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,10); + return 1; +} + +__setup("lpj=", lpj_setup); + /* this should be approx 2 Bo*oMips to start (note initial shift), and will still work even if initially too large, it will just take slightly longer */ unsigned long loops_per_jiffy = (1<<12); @@ -183,40 +192,48 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... \n"); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } + + /* Do a binary approximation to get loops_per_jiffy set to equal one clock + (up to lps_precision bits) */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while ( lps_precision-- && (loopbit >>= 1) ) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies); + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } + + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", + loops_per_jiffy); - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; } - -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; - } - -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) --- linux-2.6.7/init/Kconfig.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/Kconfig Fri Jul 9 18:41:02 2004 @@ -218,6 +218,40 @@ This option enables access to kernel configuration file and build information through /proc/config.gz. +menuconfig FASTBOOT + bool "Fast boot options" + help + Say Y here to select among various options that can decrease + kernel boot time. These options commonly involve providing + hardcoded values for some parameters that the kernel usually + determines automatically. + + This option is useful primarily on embedded systems. + + If unsure, say N. + +config PRESET_LPJ + int "Preset loops_per_jiffy" if FASTBOOT + default 0 + help + This is the number of loops used by delay() to achieve a single + jiffy of delay inside the kernel. It is normally calculated at + boot time, but that calculation can take up to 250 ms per CPU. + Specifying a constant value here will eliminate that delay. + + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct + value for your kernel, first turn off the fast booting option, + compile and boot the kernel on your target hardware, then see what + value is printed during the kernel boot. Use that value here. + + A value of 0 results in the normal autodetect behavior at boot. + + The kernel command line parameter "lpj=" can be used to override + the value configured here. + + If unsure, set this to 0. An incorrect value will cause delays in + the kernel to be incorrect. Although unlikely, in the extreme case + this might damage your hardware. menuconfig EMBEDDED bool "Configure standard kernel features (for small systems)" ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-09 23:35 ` Adam Kropelin @ 2004-07-10 0:20 ` Tim Bird 2004-07-10 2:01 ` Adam Kropelin 2004-07-10 15:54 ` Adam Kropelin 0 siblings, 2 replies; 29+ messages in thread From: Tim Bird @ 2004-07-10 0:20 UTC (permalink / raw) To: Adam Kropelin; +Cc: linux kernel, CE Linux Developers List Adam Kropelin wrote: > Here's an alternate patch (compile tested only) which is slightly > simpler, slightly more flexible, and fixes a small bug in the original. These are great improvements. Thanks. > The simplification centers around removing USE_PRESET_LPJ and > interpeting a preset value of 0 as a signal to autodetect. This > eliminates ifdefs in the code and avoids giving magic significance > to the loops_per_jiffy LSb. Yeah. When I originally wrote it, I thought using the LSb was cute, and avoided an extra variable. Your way is simpler and provides the extra feature of disabling the preset from the command line. This, and the elimination of ifdefs is quite nice. > Additionally, the user can always disable > the preset by using "lpj=0" which would allow booting a kernel that > crashes due to a bogus preset. The only problem I can think of with > this approach is if there is a system out there so slow that lpj=0 is > actually a valid setting. It's hard to imagine this case, but that would merely result in a calibration, right? For a machine that slow, calibrating the delay is the least of their worries. :-) > > The final change is to fix a small bug in the original patch: > loops_per_jiffy was no longer initialized each time calibrate_delay() > was invoked. This is potentially an issue on SMP systems since > calibrate_delay() will be invoked for each CPU. One related thing to > keep in mind is that on an SMP system, using an lpj preset will result > in the same lpj setting on each CPU. On sane systems this shouldn't be > a problem, but if there's a machine out there with unequal CPUs it will > be a problem. Perhaps this is worth mentioning in the help text as well. I hadn't considered this. (Too much "embedded" on the brain.) By help text, do you mean the config text, or something on the wiki page, or some other file (in Documentation?). On the subject of help text, is there a Documentation file I should modify or someone I should notify about the addition of a new kernel command line option? > > While we're on the topic: Should FASTBOOT perhaps depend on EMBEDDED? I > can imagine a user with a massively MP system perhaps finding this > option useful, so maybe not. I had it there originally, then changed my mind. I know some server guys are interested in fastboot. This particular change might not be that interesting, but some of the other changes we are thinking of might not be specific to just embedded. I will do some runtime testing on your patch, but I probably won't be able to report back until Monday. Thanks very much! -- Tim ============================= Tim Bird Architecture Group Co-Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics E-mail: tim.bird@am.sony.com ============================= ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 0:20 ` Tim Bird @ 2004-07-10 2:01 ` Adam Kropelin 2004-07-10 2:01 ` Todd Poynor 2004-07-10 14:41 ` [Celinux-dev] " Geert Uytterhoeven 2004-07-10 15:54 ` Adam Kropelin 1 sibling, 2 replies; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 2:01 UTC (permalink / raw) To: Tim Bird; +Cc: linux kernel, CE Linux Developers List On Fri, Jul 09, 2004 at 05:20:07PM -0700, Tim Bird wrote: > Adam Kropelin wrote: > > crashes due to a bogus preset. The only problem I can think of with > > this approach is if there is a system out there so slow that lpj=0 is > > actually a valid setting. > It's hard to imagine this case, but that would merely result in > a calibration, right? For a machine that slow, calibrating the > delay is the least of their worries. :-) Good point. ;) > > be a problem. Perhaps this is worth mentioning in the help text as well. > I hadn't considered this. (Too much "embedded" on the brain.) > By help text, do you mean the config text, or something on the wiki page, > or some other file (in Documentation?). I meant the config text. > On the subject of help text, is there a Documentation file I should modify > or someone I should notify about the addition of a new kernel command line > option? Indeed, there is: Documentation/kernel-parameters.txt. You're right; we should update it. > > While we're on the topic: Should FASTBOOT perhaps depend on EMBEDDED? I > > can imagine a user with a massively MP system perhaps finding this > > option useful, so maybe not. > > I had it there originally, then changed my mind. I know some server > guys are interested in fastboot. This particular change might not > be that interesting, but some of the other changes we are thinking of > might not be specific to just embedded. Ok, let's leave it as-is, then. > I will do some runtime testing on your patch, but I probably won't be > able to report back until Monday. I've made an updated patch below that incorporates the items we just discussed as well as a couple of things Andreas Dilger sent to me privately. > Thanks very much! No problem. This was a nice little self-contained project to play with this evening. Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com> --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Fri Jul 9 21:07:44 2004 @@ -167,6 +167,15 @@ return 0; } +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,0); + return 1; +} + +__setup("lpj=", lpj_setup); + /* this should be approx 2 Bo*oMips to start (note initial shift), and will still work even if initially too large, it will just take slightly longer */ unsigned long loops_per_jiffy = (1<<12); @@ -183,40 +192,49 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... "); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } + + /* Do a binary approximation to get loops_per_jiffy set to + equal one clock (up to lps_precision bits) */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while ( lps_precision-- && (loopbit >>= 1) ) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } + + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", + loops_per_jiffy); - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; } - -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; - } - -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) --- linux-2.6.7/init/Kconfig.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/Kconfig Fri Jul 9 21:12:21 2004 @@ -218,6 +218,44 @@ This option enables access to kernel configuration file and build information through /proc/config.gz. +menuconfig FASTBOOT + bool "Fast boot options" + help + Say Y here to select among various options that can decrease + kernel boot time. These options commonly involve providing + hardcoded values for some parameters that the kernel usually + determines automatically. + + This option is useful primarily on embedded systems. + + If unsure, say N. + +config PRESET_LPJ + int "Preset loops_per_jiffy" if FASTBOOT + default 0 + help + This is the number of loops used by delay() to achieve a single + jiffy of delay inside the kernel. It is normally calculated at + boot time, but that calculation can take up to 250 ms per CPU. + Specifying a constant value here will eliminate that delay. + + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct + value for your kernel, first turn off the fast booting option, + compile and boot the kernel on your target hardware, then see what + value is printed during the kernel boot. Use that value here. + + A value of 0 results in the normal autodetect behavior at boot. + + The kernel command line parameter "lpj=" can be used to override + the value configured here. + + Note that on SMP systems the preset will be applied to all CPUs + which will cause problems if for some reason your CPUs need + significantly divergent settings. + + If unsure, set this to 0. An incorrect value will cause delays in + the kernel to be incorrect. Although unlikely, in the extreme case + this might damage your hardware. menuconfig EMBEDDED bool "Configure standard kernel features (for small systems)" --- linux-2.6.7/Documentation/kernel-parameters.txt.orig Fri Jul 9 21:20:16 2004 +++ linux-2.6.7/Documentation/kernel-parameters.txt Fri Jul 9 21:17:11 2004 @@ -576,6 +576,12 @@ so, the driver will manage that printer. See also header of drivers/char/lp.c. + lpj=n [KNL] + Sets loops_per_jiffy to given constant, thus avoiding + time-consuming boot-time autodetection. + 0 enables autodetection (default). See Kconfig help text + for PRESET_LPJ for details. + ltpc= [NET] Format: <io>,<irq>,<dma> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 2:01 ` Adam Kropelin @ 2004-07-10 2:01 ` Todd Poynor 2004-07-10 15:42 ` Adam Kropelin 2004-07-10 14:41 ` [Celinux-dev] " Geert Uytterhoeven 1 sibling, 1 reply; 29+ messages in thread From: Todd Poynor @ 2004-07-10 2:01 UTC (permalink / raw) To: Adam Kropelin; +Cc: Tim Bird, linux kernel, CE Linux Developers List Adam Kropelin wrote: > + if (preset_lpj) { > + loops_per_jiffy = preset_lpj; > + printk("Calibrating delay loop (skipped)... "); Suggest a "\n" at the end of that. Maybe add the precomputed value to help bring incorrect presets to someone's attention, something like: + printk("BogoMIPS preset to %lu.%02lu\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); > + If unsure, set this to 0. An incorrect value will cause delays in > + the kernel to be incorrect. Although unlikely, in the extreme case > + this might damage your hardware. I suppose it may result in unpredictable I/O errors, in case we want to warn against that. -- Todd Poynor MontaVista Software ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 2:01 ` Todd Poynor @ 2004-07-10 15:42 ` Adam Kropelin 0 siblings, 0 replies; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 15:42 UTC (permalink / raw) To: Todd Poynor; +Cc: Tim Bird, linux kernel, CE Linux Developers List On Fri, Jul 09, 2004 at 07:01:58PM -0700, Todd Poynor wrote: > Adam Kropelin wrote: > > > + if (preset_lpj) { > > + loops_per_jiffy = preset_lpj; > > + printk("Calibrating delay loop (skipped)... "); > > Suggest a "\n" at the end of that. Indeed. I propogated that bug from the original patch. I'll fix it. > Maybe add the precomputed value to > help bring incorrect presets to someone's attention, something like: > > + printk("BogoMIPS preset to %lu.%02lu\n", > + loops_per_jiffy/(500000/HZ), > + (loops_per_jiffy/(5000/HZ)) % 100); Will do. > > + If unsure, set this to 0. An incorrect value will cause delays in > > + the kernel to be incorrect. Although unlikely, in the extreme case > > + this might damage your hardware. > > I suppose it may result in unpredictable I/O errors, in case we want to > warn against that. Easy enough to throw it in. Another patch is forthcoming. --Adam ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Celinux-dev] Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 2:01 ` Adam Kropelin 2004-07-10 2:01 ` Todd Poynor @ 2004-07-10 14:41 ` Geert Uytterhoeven 2004-07-10 15:22 ` Adam Kropelin 1 sibling, 1 reply; 29+ messages in thread From: Geert Uytterhoeven @ 2004-07-10 14:41 UTC (permalink / raw) To: Adam Kropelin; +Cc: Tim Bird, linux kernel, CE Linux Developers List On Fri, 9 Jul 2004, Adam Kropelin wrote: > On Fri, Jul 09, 2004 at 05:20:07PM -0700, Tim Bird wrote: > > Adam Kropelin wrote: > + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", > + loops_per_jiffy); > +config PRESET_LPJ > + int "Preset loops_per_jiffy" if FASTBOOT > + default 0 > + help > + This is the number of loops used by delay() to achieve a single > + jiffy of delay inside the kernel. It is normally calculated at > + boot time, but that calculation can take up to 250 ms per CPU. > + Specifying a constant value here will eliminate that delay. > + > + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct > + value for your kernel, first turn off the fast booting option, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > + compile and boot the kernel on your target hardware, then see what > + value is printed during the kernel boot. Use that value here. This is no longer true, it will always print the value if lpj=0. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Celinux-dev] Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 14:41 ` [Celinux-dev] " Geert Uytterhoeven @ 2004-07-10 15:22 ` Adam Kropelin 0 siblings, 0 replies; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 15:22 UTC (permalink / raw) To: Geert Uytterhoeven; +Cc: Tim Bird, linux kernel, CE Linux Developers List On Sat, Jul 10, 2004 at 04:41:04PM +0200, Geert Uytterhoeven wrote: > On Fri, 9 Jul 2004, Adam Kropelin wrote: > > On Fri, Jul 09, 2004 at 05:20:07PM -0700, Tim Bird wrote: > > > Adam Kropelin wrote: > > + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", > > + loops_per_jiffy); > > > +config PRESET_LPJ > > + int "Preset loops_per_jiffy" if FASTBOOT > > + default 0 > > + help > > + This is the number of loops used by delay() to achieve a single > > + jiffy of delay inside the kernel. It is normally calculated at > > + boot time, but that calculation can take up to 250 ms per CPU. > > + Specifying a constant value here will eliminate that delay. > > + > > + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct > > + value for your kernel, first turn off the fast booting option, > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > + compile and boot the kernel on your target hardware, then see what > > + value is printed during the kernel boot. Use that value here. > > This is no longer true, it will always print the value if lpj=0. True enough. I'll fix that along with the things Todd noticed. --Adam ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 0:20 ` Tim Bird 2004-07-10 2:01 ` Adam Kropelin @ 2004-07-10 15:54 ` Adam Kropelin 2004-07-10 18:28 ` Adam Kropelin 1 sibling, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 15:54 UTC (permalink / raw) To: Tim Bird Cc: linux kernel, CE Linux Developers List, Todd Poynor, Geert Uytterhoeven Here's an updated patch which incorporates suggestions from Todd Poynor and Geert Uytterhoeven. Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com> --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Sat Jul 10 11:02:49 2004 @@ -167,6 +167,15 @@ return 0; } +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,0); + return 1; +} + +__setup("lpj=", lpj_setup); + /* this should be approx 2 Bo*oMips to start (note initial shift), and will still work even if initially too large, it will just take slightly longer */ unsigned long loops_per_jiffy = (1<<12); @@ -183,40 +192,52 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); - - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; - } - -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... " + "%lu.%02lu BogoMIPS preset\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } + + /* Do a binary approximation to get loops_per_jiffy set to + equal one clock (up to lps_precision bits) */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while ( lps_precision-- && (loopbit >>= 1) ) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } + + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", + loops_per_jiffy); } -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) --- linux-2.6.7/init/Kconfig.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/Kconfig Sat Jul 10 11:05:27 2004 @@ -218,6 +218,45 @@ This option enables access to kernel configuration file and build information through /proc/config.gz. +menuconfig FASTBOOT + bool "Fast boot options" + help + Say Y here to select among various options that can decrease + kernel boot time. These options commonly involve providing + hardcoded values for some parameters that the kernel usually + determines automatically. + + This option is useful primarily on embedded systems. + + If unsure, say N. + +config PRESET_LPJ + int "Preset loops_per_jiffy" if FASTBOOT + default 0 + help + This is the number of loops used by delay() to achieve a single + jiffy of delay inside the kernel. It is normally calculated at + boot time, but that calculation can take up to 250 ms per CPU. + Specifying a constant value here will eliminate that delay. + + A value of 0 results in the normal autodetect behavior. + + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct + value for your kernel, first set this option to 0, compile and boot + the kernel on your target hardware, then see what value is printed + during the kernel boot. Use that value here. + + The kernel command line parameter "lpj=" can be used to override + the value configured here. + + Note that on SMP systems the preset will be applied to all CPUs + which will cause problems if for some reason your CPUs need + significantly divergent settings. + + If unsure, set this to 0. An incorrect value will cause delays in + the kernel to be wrong, leading to unpredictable I/O errors and + other breakage. Although unlikely, in the extreme case this might + damage your hardware. menuconfig EMBEDDED bool "Configure standard kernel features (for small systems)" --- linux-2.6.7/Documentation/kernel-parameters.txt.orig Fri Jul 9 21:20:16 2004 +++ linux-2.6.7/Documentation/kernel-parameters.txt Fri Jul 9 21:17:11 2004 @@ -576,6 +576,12 @@ so, the driver will manage that printer. See also header of drivers/char/lp.c. + lpj=n [KNL] + Sets loops_per_jiffy to given constant, thus avoiding + time-consuming boot-time autodetection. + 0 enables autodetection (default). See Kconfig help text + for PRESET_LPJ for details. + ltpc= [NET] Format: <io>,<irq>,<dma> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 15:54 ` Adam Kropelin @ 2004-07-10 18:28 ` Adam Kropelin 2004-07-10 18:19 ` Dmitry Torokhov 0 siblings, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 18:28 UTC (permalink / raw) To: Tim Bird Cc: linux kernel, CE Linux Developers List, Todd Poynor, Geert Uytterhoeven On Sat, Jul 10, 2004 at 11:54:13AM -0400, Adam Kropelin wrote: > Here's an updated patch which incorporates suggestions from Todd Poynor > and Geert Uytterhoeven. <snip> > + /* Round the value and print it */ > + printk("%lu.%02lu BogoMIPS\n", > + loops_per_jiffy/(500000/HZ), > + (loops_per_jiffy/(5000/HZ)) % 100); > + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", > + loops_per_jiffy); > } Argh. Here's one with the right tabbing. Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com> --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Sat Jul 10 13:49:12 2004 @@ -167,6 +167,15 @@ return 0; } +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,0); + return 1; +} + +__setup("lpj=", lpj_setup); + /* this should be approx 2 Bo*oMips to start (note initial shift), and will still work even if initially too large, it will just take slightly longer */ unsigned long loops_per_jiffy = (1<<12); @@ -183,40 +192,52 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); - - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; - } - -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... " + "%lu.%02lu BogoMIPS preset\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } + + /* Do a binary approximation to get loops_per_jiffy set to + equal one clock (up to lps_precision bits) */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while ( lps_precision-- && (loopbit >>= 1) ) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } + + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", + loops_per_jiffy); } -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) --- linux-2.6.7/init/Kconfig.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/Kconfig Sat Jul 10 11:05:27 2004 @@ -218,6 +218,45 @@ This option enables access to kernel configuration file and build information through /proc/config.gz. +menuconfig FASTBOOT + bool "Fast boot options" + help + Say Y here to select among various options that can decrease + kernel boot time. These options commonly involve providing + hardcoded values for some parameters that the kernel usually + determines automatically. + + This option is useful primarily on embedded systems. + + If unsure, say N. + +config PRESET_LPJ + int "Preset loops_per_jiffy" if FASTBOOT + default 0 + help + This is the number of loops used by delay() to achieve a single + jiffy of delay inside the kernel. It is normally calculated at + boot time, but that calculation can take up to 250 ms per CPU. + Specifying a constant value here will eliminate that delay. + + A value of 0 results in the normal autodetect behavior. + + loops_per_jiffy is roughly BogoMips * 5000. To determine the correct + value for your kernel, first set this option to 0, compile and boot + the kernel on your target hardware, then see what value is printed + during the kernel boot. Use that value here. + + The kernel command line parameter "lpj=" can be used to override + the value configured here. + + Note that on SMP systems the preset will be applied to all CPUs + which will cause problems if for some reason your CPUs need + significantly divergent settings. + + If unsure, set this to 0. An incorrect value will cause delays in + the kernel to be wrong, leading to unpredictable I/O errors and + other breakage. Although unlikely, in the extreme case this might + damage your hardware. menuconfig EMBEDDED bool "Configure standard kernel features (for small systems)" --- linux-2.6.7/Documentation/kernel-parameters.txt.orig Fri Jul 9 21:20:16 2004 +++ linux-2.6.7/Documentation/kernel-parameters.txt Fri Jul 9 21:17:11 2004 @@ -576,6 +576,12 @@ so, the driver will manage that printer. See also header of drivers/char/lp.c. + lpj=n [KNL] + Sets loops_per_jiffy to given constant, thus avoiding + time-consuming boot-time autodetection. + 0 enables autodetection (default). See Kconfig help text + for PRESET_LPJ for details. + ltpc= [NET] Format: <io>,<irq>,<dma> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 18:28 ` Adam Kropelin @ 2004-07-10 18:19 ` Dmitry Torokhov 2004-07-10 20:14 ` Adam Kropelin 0 siblings, 1 reply; 29+ messages in thread From: Dmitry Torokhov @ 2004-07-10 18:19 UTC (permalink / raw) To: linux-kernel Cc: Adam Kropelin, Tim Bird, CE Linux Developers List, Todd Poynor, Geert Uytterhoeven On Saturday 10 July 2004 01:28 pm, Adam Kropelin wrote: > + Note that on SMP systems the preset will be applied to all CPUs > + which will cause problems if for some reason your CPUs need > + significantly divergent settings. > + > + If unsure, set this to 0. An incorrect value will cause delays in > + the kernel to be wrong, leading to unpredictable I/O errors and > + other breakage. Although unlikely, in the extreme case this might > + damage your hardware. > Note that it may also not work correctly on laptops that switch frequency when working on battery/AC. Also one needs to be careful when changing timesource (pit, tsc, pm, hpet). And always look out for timer code changes in next version of kernel. Does 250 ms worth all this pain? -- Dmitry ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 18:19 ` Dmitry Torokhov @ 2004-07-10 20:14 ` Adam Kropelin 2004-07-11 1:25 ` Andrew Morton 0 siblings, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-10 20:14 UTC (permalink / raw) To: Dmitry Torokhov, linux-kernel Cc: Tim Bird, CE Linux Developers List, Todd Poynor, Geert Uytterhoeven Dmitry Torokhov wrote: > On Saturday 10 July 2004 01:28 pm, Adam Kropelin wrote: >> + Note that on SMP systems the preset will be applied to all CPUs >> + which will cause problems if for some reason your CPUs need >> + significantly divergent settings. >> + >> + If unsure, set this to 0. An incorrect value will cause delays in >> + the kernel to be wrong, leading to unpredictable I/O errors and >> + other breakage. Although unlikely, in the extreme case this might >> + damage your hardware. > > Note that it may also not work correctly on laptops that switch > frequency when working on battery/AC. Also one needs to be careful > when changing timesource (pit, tsc, pm, hpet). And always look out > for timer code changes in next version of kernel. Certainly many demons lurk around the corner, but embedded guys are used to that. > Does 250 ms worth all this pain? On a desktop box, almost certainly not. On a massive SMP machine, maybe. On an embedded system that is required to boot in a ridiculously short time, absolutely. --Adam ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-10 20:14 ` Adam Kropelin @ 2004-07-11 1:25 ` Andrew Morton 2004-07-11 3:44 ` Adam Kropelin 2004-07-12 17:50 ` Tim Bird 0 siblings, 2 replies; 29+ messages in thread From: Andrew Morton @ 2004-07-11 1:25 UTC (permalink / raw) To: Adam Kropelin Cc: dtor_core, linux-kernel, tim.bird, celinux-dev, tpoynor, geert "Adam Kropelin" <akropel1@rochester.rr.com> wrote: > > > Does 250 ms worth all this pain? > > On a desktop box, almost certainly not. On a massive SMP machine, maybe. On > an embedded system that is required to boot in a ridiculously short time, > absolutely. Yes, it's pretty small beer, but we do recognise that although the number of development teams which use features like this is small, the number of systems is large, so the features are correspondingly more important. One of the services which we kernel developers provide the downstream kernel users is the hosting and maintenance of their code so they don't have to carry important stuff off-stream, and when the changes are this small and simple, I don't see a problem with merging them, even if none of "us" will use the feature. wrt this particular patch: a) I don't see much point in making it configurable. Just add the boot option and be done with it. The few hundred bytes of extra code will be dropped from core anyway. The main reason for this is that most people won't turn on the config option, so your new code could get accidentally broken quite easily. Plus it removes some ifdefs. b) Coding style consistency, please: Replace things like /* Do a binary approximation to get loops_per_jiffy set to equal one clock (up to lps_precision bits) */ with /* * Do a binary approximation to get loops_per_jiffy set to * equal one clock (up to lps_precision bits) */ while ( lps_precision-- && (loopbit >>= 1) ) { should be while (lps_precision-- && (loopbit >>= 1)) { Yes, some of the code was already like that, but let's regularise these things as we go. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 1:25 ` Andrew Morton @ 2004-07-11 3:44 ` Adam Kropelin 2004-07-11 4:38 ` Andrew Morton 2004-07-11 4:51 ` Dmitry Torokhov 2004-07-12 17:50 ` Tim Bird 1 sibling, 2 replies; 29+ messages in thread From: Adam Kropelin @ 2004-07-11 3:44 UTC (permalink / raw) To: Andrew Morton Cc: dtor_core, linux-kernel, tim.bird, celinux-dev, tpoynor, geert On Sat, Jul 10, 2004 at 06:25:27PM -0700, Andrew Morton wrote: > "Adam Kropelin" <akropel1@rochester.rr.com> wrote: > > > > > Does 250 ms worth all this pain? > > > > On a desktop box, almost certainly not. On a massive SMP machine, maybe. On > > an embedded system that is required to boot in a ridiculously short time, > > absolutely. Andrew, thanks for the review... > wrt this particular patch: > > a) I don't see much point in making it configurable. Just add the boot > option and be done with it. The few hundred bytes of extra code will be > dropped from core anyway. > > The main reason for this is that most people won't turn on the config > option, so your new code could get accidentally broken quite easily. > Plus it removes some ifdefs. Actually, there are no ifdefs at all (unless there are some auto-generated ones I don't know about). The only function of the config option is to allow a preset without using the command line parameter. I agree that the command line parameter alone is enough. I'm not an actual user of this code, though, so perhaps Tim or someone else can comment if the config option serves a useful purpose for them. > b) Coding style consistency, please: Will do. I actually purposely avoided making "gratuitous" changes to existing code, but I definitely appreciate consistency so I'll happily clean things up a bit. Thanks for your feedback. Here's a patch implementing your suggestions. Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com> --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Sat Jul 10 22:42:34 2004 @@ -167,15 +167,28 @@ return 0; } -/* this should be approx 2 Bo*oMips to start (note initial shift), and will - still work even if initially too large, it will just take slightly longer */ +static unsigned long preset_lpj; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,0); + return 1; +} + +__setup("lpj=", lpj_setup); + +/* + * This should be approx 2 Bo*oMips to start (note initial shift), and will + * still work even if initially too large, it will just take slightly longer + */ unsigned long loops_per_jiffy = (1<<12); EXPORT_SYMBOL(loops_per_jiffy); -/* This is the number of bits of precision for the loops_per_jiffy. Each - bit takes on average 1.5/HZ seconds. This (like the original) is a little - better than 1% */ +/* + * This is the number of bits of precision for the loops_per_jiffy. Each + * bit takes on average 1.5/HZ seconds. This (like the original) is a little + * better than 1% + */ #define LPS_PREC 8 void __devinit calibrate_delay(void) @@ -183,40 +196,54 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... " + "%lu.%02lu BogoMIPS preset\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; - } + /* + * Do a binary approximation to get loops_per_jiffy set to + * equal one clock (up to lps_precision bits) + */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while (lps_precision-- && (loopbit >>= 1)) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", + loops_per_jiffy); } -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) @@ -238,8 +265,10 @@ __setup("debug", debug_kernel); __setup("quiet", quiet_kernel); -/* Unknown boot options get handed to init, unless they look like - failed parameters */ +/* + * Unknown boot options get handed to init, unless they look like + * failed parameters + */ static int __init unknown_bootoption(char *param, char *val) { /* Change NUL term back to "=", to make "param" the whole string. */ @@ -250,8 +279,10 @@ if (obsolete_checksetup(param)) return 0; - /* Preemptive maintenance for "why didn't my mispelled command - line work?" */ + /* + * Preemptive maintenance for "why didn't my mispelled command + * line work?" + */ if (strchr(param, '.') && (!val || strchr(param, '.') < val)) { printk(KERN_ERR "Unknown boot option `%s': ignoring\n", param); return 0; @@ -289,7 +320,8 @@ unsigned int i; execute_command = str; - /* In case LILO is going to boot us with default command line, + /* + * In case LILO is going to boot us with default command line, * it prepends "auto" before the whole cmdline which makes * the shell think it should execute a script with such name. * So we ignore all arguments entered _before_ init=... [MJ] @@ -483,9 +515,9 @@ check_bugs(); /* - * We count on the initial thread going ok - * Like idlers init is an unlocked kernel thread, which will - * make syscalls (and thus be locked). + * We count on the initial thread going ok + * Like idlers init is an unlocked kernel thread, which will + * make syscalls (and thus be locked). */ init_idle(current, smp_processor_id()); --- linux-2.6.7/Documentation/kernel-parameters.txt.orig Fri Jul 9 21:20:16 2004 +++ linux-2.6.7/Documentation/kernel-parameters.txt Sat Jul 10 22:46:30 2004 @@ -576,6 +576,20 @@ so, the driver will manage that printer. See also header of drivers/char/lp.c. + lpj=n [KNL] + Sets loops_per_jiffy to given constant, thus avoiding + time-consuming boot-time autodetection (up to 250 ms per + CPU). 0 enables autodetection (default). To determine + the correct value for your kernel, boot with normal + autodetection and see what value is printed. Note that + on SMP systems the preset will be applied to all CPUs, + which is likely to cause problems if your CPUs need + significantly divergent settings. An incorrect value + will cause delays in the kernel to be wrong, leading to + unpredictable I/O errors and other breakage. Although + unlikely, in the extreme case this might damage your + hardware. + ltpc= [NET] Format: <io>,<irq>,<dma> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 3:44 ` Adam Kropelin @ 2004-07-11 4:38 ` Andrew Morton 2004-07-12 17:31 ` Tim Bird 2004-07-11 4:51 ` Dmitry Torokhov 1 sibling, 1 reply; 29+ messages in thread From: Andrew Morton @ 2004-07-11 4:38 UTC (permalink / raw) To: Adam Kropelin Cc: dtor_core, linux-kernel, tim.bird, celinux-dev, tpoynor, geert Adam Kropelin <akropel1@rochester.rr.com> wrote: > > Actually, there are no ifdefs at all (unless there are some > auto-generated ones I don't know about). OK, I should have looked and not guessed ;) > Thanks for your feedback. Here's a patch implementing your suggestions. Thanks. Tim, could you please review-n-test this? ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 4:38 ` Andrew Morton @ 2004-07-12 17:31 ` Tim Bird 0 siblings, 0 replies; 29+ messages in thread From: Tim Bird @ 2004-07-12 17:31 UTC (permalink / raw) To: Andrew Morton Cc: Adam Kropelin, dtor_core, linux-kernel, celinux-dev, tpoynor, geert Andrew Morton wrote: > Adam Kropelin <akropel1@rochester.rr.com> wrote: > >>Actually, there are no ifdefs at all (unless there are some >> auto-generated ones I don't know about). > > > OK, I should have looked and not guessed ;) > > >> Thanks for your feedback. Here's a patch implementing your suggestions. > > > Thanks. Tim, could you please review-n-test this? Yes. I'll give it a full run-through today. ============================= Tim Bird Bootup Time Working Group Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics E-mail: tim.bird@am.sony.com ============================= ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 3:44 ` Adam Kropelin 2004-07-11 4:38 ` Andrew Morton @ 2004-07-11 4:51 ` Dmitry Torokhov 2004-07-11 4:58 ` Karim Yaghmour 1 sibling, 1 reply; 29+ messages in thread From: Dmitry Torokhov @ 2004-07-11 4:51 UTC (permalink / raw) To: Adam Kropelin Cc: Andrew Morton, linux-kernel, tim.bird, celinux-dev, tpoynor, geert On Saturday 10 July 2004 10:44 pm, Adam Kropelin wrote: > + /* Round the value and print it */ > + printk("%lu.%02lu BogoMIPS\n", > + loops_per_jiffy/(500000/HZ), > + (loops_per_jiffy/(5000/HZ)) % 100); > + printk("Set 'Preset loops_per_jiffy'=%lu for preset lpj.\n", > + loops_per_jiffy); Do we need to encourage ordinary users to turn this option on? 99% of non-embedded market is much safer with that option off... -- Dmitry ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 4:51 ` Dmitry Torokhov @ 2004-07-11 4:58 ` Karim Yaghmour 2004-07-11 5:19 ` Dmitry Torokhov 0 siblings, 1 reply; 29+ messages in thread From: Karim Yaghmour @ 2004-07-11 4:58 UTC (permalink / raw) To: Dmitry Torokhov Cc: Adam Kropelin, Andrew Morton, linux-kernel, tim.bird, celinux-dev, tpoynor, geert Dmitry Torokhov wrote: > Do we need to encourage ordinary users to turn this option on? 99% of > non-embedded market is much safer with that option off... There are other boot params that gather similar if not higher percentages. profile= is one of those. Also, keep in mind that in a not too distant future (and indeed today for some folks already) recompiling and fine-tuning the Linux kernel for your latest gizmo will not be as foreign as your statement may make it sound. Karim -- Author, Speaker, Developer, Consultant Pushing Embedded and Real-Time Linux Systems Beyond the Limits http://www.opersys.com || karim@opersys.com || 1-866-677-4546 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 4:58 ` Karim Yaghmour @ 2004-07-11 5:19 ` Dmitry Torokhov 2004-07-11 5:27 ` Andrew Morton 0 siblings, 1 reply; 29+ messages in thread From: Dmitry Torokhov @ 2004-07-11 5:19 UTC (permalink / raw) To: karim Cc: Adam Kropelin, Andrew Morton, linux-kernel, tim.bird, celinux-dev, tpoynor, geert On Saturday 10 July 2004 11:58 pm, Karim Yaghmour wrote: > > Dmitry Torokhov wrote: > > Do we need to encourage ordinary users to turn this option on? 99% of > > non-embedded market is much safer with that option off... > > There are other boot params that gather similar if not higher percentages. > profile= is one of those. > I do not see anywhere in my boot log suggestion to activate profiling... Nor I see recommendadtion to use idebus=66... But i will see suggesion to set loops_per_jiffy. > Also, keep in mind that in a not too distant future (and indeed today for > some folks already) recompiling and fine-tuning the Linux kernel for your > latest gizmo will not be as foreign as your statement may make it sound. Use of this particular option will require active tracking of kernel timer code to ensure that lpj that was valid for kernel x.y.z is still valid for kernel x.y.z+1. I do not beleive that normal user will ever care to do that even in very distant future. Still, given that message in the boot log, many will probably try the option. I am no longer question presence of the code in the kernel, I just don't like the message... -- Dmitry ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 5:19 ` Dmitry Torokhov @ 2004-07-11 5:27 ` Andrew Morton 2004-07-11 7:46 ` Geert Uytterhoeven 0 siblings, 1 reply; 29+ messages in thread From: Andrew Morton @ 2004-07-11 5:27 UTC (permalink / raw) To: Dmitry Torokhov Cc: karim, akropel1, linux-kernel, tim.bird, celinux-dev, tpoynor, geert Dmitry Torokhov <dtor_core@ameritech.net> wrote: > > I am no longer question presence of the code in the kernel, I just don't like > the message... yup, we shouldn't have the friendly message. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 5:27 ` Andrew Morton @ 2004-07-11 7:46 ` Geert Uytterhoeven 2004-07-11 7:51 ` Andrew Morton 0 siblings, 1 reply; 29+ messages in thread From: Geert Uytterhoeven @ 2004-07-11 7:46 UTC (permalink / raw) To: Andrew Morton Cc: Dmitry Torokhov, karim, akropel1, Linux Kernel Development, Tim Bird, celinux-dev, tpoynor On Sat, 10 Jul 2004, Andrew Morton wrote: > Dmitry Torokhov <dtor_core@ameritech.net> wrote: > > > > I am no longer question presence of the code in the kernel, I just don't like > > the message... > > yup, we shouldn't have the friendly message. Just add the appropriate KERN_*, so it's not displayed by default, and people who want it can look it up in syslog. Or what about a sysfs entry people can cat? The alternative is to cat /proc/cpuinfo and grab a calculcator... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 7:46 ` Geert Uytterhoeven @ 2004-07-11 7:51 ` Andrew Morton 2004-07-11 13:41 ` Adam Kropelin 0 siblings, 1 reply; 29+ messages in thread From: Andrew Morton @ 2004-07-11 7:51 UTC (permalink / raw) To: Geert Uytterhoeven Cc: dtor_core, karim, akropel1, linux-kernel, tim.bird, celinux-dev, tpoynor Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > On Sat, 10 Jul 2004, Andrew Morton wrote: > > Dmitry Torokhov <dtor_core@ameritech.net> wrote: > > > > > > I am no longer question presence of the code in the kernel, I just don't like > > > the message... > > > > yup, we shouldn't have the friendly message. > > Just add the appropriate KERN_*, so it's not displayed by default, and people > who want it can look it up in syslog. Oh crap, sorry. I just worked out what the darn printk is for. Yes, it's legit. Let's just print the bogomips and loops_per_jiffy on the same line. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 7:51 ` Andrew Morton @ 2004-07-11 13:41 ` Adam Kropelin 2004-07-12 18:52 ` Tim Bird 0 siblings, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-11 13:41 UTC (permalink / raw) To: Andrew Morton Cc: Geert Uytterhoeven, dtor_core, karim, linux-kernel, tim.bird, celinux-dev, tpoynor On Sun, Jul 11, 2004 at 12:51:56AM -0700, Andrew Morton wrote: > Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > > > On Sat, 10 Jul 2004, Andrew Morton wrote: > > > Dmitry Torokhov <dtor_core@ameritech.net> wrote: > > > > > > > > I am no longer question presence of the code in the kernel, I just don't like > > > > the message... > > > > > > yup, we shouldn't have the friendly message. > > > > Just add the appropriate KERN_*, so it's not displayed by default, and people > > who want it can look it up in syslog. > > Oh crap, sorry. I just worked out what the darn printk is for. Yes, it's > legit. Let's just print the bogomips and loops_per_jiffy on the same line. Here's a patch. It places the relevant information on the same line as bogomips and does so without encouraging anyone to fiddle with loops_per_jiffy and screw up their kernel. Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com> --- linux-2.6.7/init/main.c.orig Mon Jun 21 17:55:09 2004 +++ linux-2.6.7/init/main.c Sun Jul 11 08:56:07 2004 @@ -167,15 +167,28 @@ return 0; } -/* this should be approx 2 Bo*oMips to start (note initial shift), and will - still work even if initially too large, it will just take slightly longer */ +static unsigned long preset_lpj; +static int __init lpj_setup(char *str) +{ + preset_lpj = simple_strtoul(str,NULL,0); + return 1; +} + +__setup("lpj=", lpj_setup); + +/* + * This should be approx 2 Bo*oMips to start (note initial shift), and will + * still work even if initially too large, it will just take slightly longer + */ unsigned long loops_per_jiffy = (1<<12); EXPORT_SYMBOL(loops_per_jiffy); -/* This is the number of bits of precision for the loops_per_jiffy. Each - bit takes on average 1.5/HZ seconds. This (like the original) is a little - better than 1% */ +/* + * This is the number of bits of precision for the loops_per_jiffy. Each + * bit takes on average 1.5/HZ seconds. This (like the original) is a little + * better than 1% + */ #define LPS_PREC 8 void __devinit calibrate_delay(void) @@ -183,40 +196,53 @@ unsigned long ticks, loopbit; int lps_precision = LPS_PREC; - loops_per_jiffy = (1<<12); + if (preset_lpj) { + loops_per_jiffy = preset_lpj; + printk("Calibrating delay loop (skipped)... " + "%lu.%02lu BogoMIPS preset\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100); + } else { + loops_per_jiffy = (1<<12); + + printk("Calibrating delay loop... "); + while ((loops_per_jiffy <<= 1) != 0) { + /* wait for "start of" clock tick */ + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + /* Go .. */ + ticks = jiffies; + __delay(loops_per_jiffy); + ticks = jiffies - ticks; + if (ticks) + break; + } - printk("Calibrating delay loop... "); - while ((loops_per_jiffy <<= 1) != 0) { - /* wait for "start of" clock tick */ - ticks = jiffies; - while (ticks == jiffies) - /* nothing */; - /* Go .. */ - ticks = jiffies; - __delay(loops_per_jiffy); - ticks = jiffies - ticks; - if (ticks) - break; - } + /* + * Do a binary approximation to get loops_per_jiffy set to + * equal one clock (up to lps_precision bits) + */ + loops_per_jiffy >>= 1; + loopbit = loops_per_jiffy; + while (lps_precision-- && (loopbit >>= 1)) { + loops_per_jiffy |= loopbit; + ticks = jiffies; + while (ticks == jiffies) + /* nothing */; + ticks = jiffies; + __delay(loops_per_jiffy); + if (jiffies != ticks) /* longer than 1 tick */ + loops_per_jiffy &= ~loopbit; + } -/* Do a binary approximation to get loops_per_jiffy set to equal one clock - (up to lps_precision bits) */ - loops_per_jiffy >>= 1; - loopbit = loops_per_jiffy; - while ( lps_precision-- && (loopbit >>= 1) ) { - loops_per_jiffy |= loopbit; - ticks = jiffies; - while (ticks == jiffies); - ticks = jiffies; - __delay(loops_per_jiffy); - if (jiffies != ticks) /* longer than 1 tick */ - loops_per_jiffy &= ~loopbit; + /* Round the value and print it */ + printk("%lu.%02lu BogoMIPS (lpj=%lu)\n", + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100, + loops_per_jiffy); } -/* Round the value and print it */ - printk("%lu.%02lu BogoMIPS\n", - loops_per_jiffy/(500000/HZ), - (loops_per_jiffy/(5000/HZ)) % 100); } static int __init debug_kernel(char *str) @@ -238,8 +264,10 @@ __setup("debug", debug_kernel); __setup("quiet", quiet_kernel); -/* Unknown boot options get handed to init, unless they look like - failed parameters */ +/* + * Unknown boot options get handed to init, unless they look like + * failed parameters + */ static int __init unknown_bootoption(char *param, char *val) { /* Change NUL term back to "=", to make "param" the whole string. */ @@ -250,8 +278,10 @@ if (obsolete_checksetup(param)) return 0; - /* Preemptive maintenance for "why didn't my mispelled command - line work?" */ + /* + * Preemptive maintenance for "why didn't my mispelled command + * line work?" + */ if (strchr(param, '.') && (!val || strchr(param, '.') < val)) { printk(KERN_ERR "Unknown boot option `%s': ignoring\n", param); return 0; @@ -289,7 +319,8 @@ unsigned int i; execute_command = str; - /* In case LILO is going to boot us with default command line, + /* + * In case LILO is going to boot us with default command line, * it prepends "auto" before the whole cmdline which makes * the shell think it should execute a script with such name. * So we ignore all arguments entered _before_ init=... [MJ] @@ -483,9 +514,9 @@ check_bugs(); /* - * We count on the initial thread going ok - * Like idlers init is an unlocked kernel thread, which will - * make syscalls (and thus be locked). + * We count on the initial thread going ok + * Like idlers init is an unlocked kernel thread, which will + * make syscalls (and thus be locked). */ init_idle(current, smp_processor_id()); --- linux-2.6.7/Documentation/kernel-parameters.txt.orig Fri Jul 9 21:20:16 2004 +++ linux-2.6.7/Documentation/kernel-parameters.txt Sat Jul 10 22:46:30 2004 @@ -576,6 +576,20 @@ so, the driver will manage that printer. See also header of drivers/char/lp.c. + lpj=n [KNL] + Sets loops_per_jiffy to given constant, thus avoiding + time-consuming boot-time autodetection (up to 250 ms per + CPU). 0 enables autodetection (default). To determine + the correct value for your kernel, boot with normal + autodetection and see what value is printed. Note that + on SMP systems the preset will be applied to all CPUs, + which is likely to cause problems if your CPUs need + significantly divergent settings. An incorrect value + will cause delays in the kernel to be wrong, leading to + unpredictable I/O errors and other breakage. Although + unlikely, in the extreme case this might damage your + hardware. + ltpc= [NET] Format: <io>,<irq>,<dma> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 13:41 ` Adam Kropelin @ 2004-07-12 18:52 ` Tim Bird 2004-07-12 19:32 ` Adam Kropelin 0 siblings, 1 reply; 29+ messages in thread From: Tim Bird @ 2004-07-12 18:52 UTC (permalink / raw) To: Adam Kropelin Cc: Andrew Morton, Geert Uytterhoeven, dtor_core, karim, linux-kernel, celinux-dev, tpoynor Adam Kropelin wrote: > Here's a patch. It places the relevant information on the same line as > bogomips and does so without encouraging anyone to fiddle with > loops_per_jiffy and screw up their kernel. The patch is missing the Kconfig piece. Is the wording the same as from your earlier patch? ============================= Tim Bird Architecture Group Co-Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics E-mail: tim.bird@am.sony.com ============================= ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-12 18:52 ` Tim Bird @ 2004-07-12 19:32 ` Adam Kropelin 2004-07-12 22:41 ` Tim Bird 0 siblings, 1 reply; 29+ messages in thread From: Adam Kropelin @ 2004-07-12 19:32 UTC (permalink / raw) To: Tim Bird Cc: Andrew Morton, Geert Uytterhoeven, dtor_core, karim, linux-kernel, celinux-dev, tpoynor On Mon, Jul 12, 2004 at 11:52:44AM -0700, Tim Bird wrote: > Adam Kropelin wrote: > > Here's a patch. It places the relevant information on the same line as > > bogomips and does so without encouraging anyone to fiddle with > > loops_per_jiffy and screw up their kernel. > > The patch is missing the Kconfig piece. Is the wording the > same as from your earlier patch? Andrew requested that the config option be removed, so there are no longer any changes to Kconfig. --Adam ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-12 19:32 ` Adam Kropelin @ 2004-07-12 22:41 ` Tim Bird 2004-07-13 19:24 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 29+ messages in thread From: Tim Bird @ 2004-07-12 22:41 UTC (permalink / raw) To: Adam Kropelin Cc: Andrew Morton, Geert Uytterhoeven, karim, linux-kernel, celinux-dev, tpoynor Adam Kropelin wrote: > On Mon, Jul 12, 2004 at 11:52:44AM -0700, Tim Bird wrote: > >>Adam Kropelin wrote: >> >>>Here's a patch. It places the relevant information on the same line as >>>bogomips and does so without encouraging anyone to fiddle with >>>loops_per_jiffy and screw up their kernel. >> >>The patch is missing the Kconfig piece. Is the wording the >>same as from your earlier patch? > > > Andrew requested that the config option be removed, so there are no > longer any changes to Kconfig. Oh - I missed the change where preset_lpj is no longer initialized from CONFIG_PRESET_LPJ. I see it now. I saw the comment from Andrew, but thought he was talking about the first version of the patch that had ifdefs. Here's what Andrew Morton said: > a) I don't see much point in making it configurable. Just add the boot > option and be done with it. The few hundred bytes of extra code will be > dropped from core anyway. > > The main reason for this is that most people won't turn on the config > option, so your new code could get accidentally broken quite easily. > Plus it removes some ifdefs. I have one or two arguments in favor of keeping the config option. First, for embedded systems it is sometimes necessary to compile-in the value. Unfortunately, not all architectures allow the kernel command line to be compiled in. (It would be nice if they did, but that's something to fix separately.) The first restructuring of the patch that you did, I think addresses the issues that Andrew raised. There are now no ifdefs, and since the core code doesn't drop away (and indeed can be turned on at boot time if needed), I think the code is not susceptible to accidental breakage like the first version was. I think Andrew is right that the preset code path won't get much testing outside of embedded circles, so it is important that it be as simple as possible. The only *code* change from the configurable to the config-less version of the code is: +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; vs. +static unsigned long preset_lpj; Secondly, I was hoping to get the FASTBOOT menu in the kernel, because CELF has a few more patches to submit that have the same theme as this one. (I realize this is not justification for making this option configurable, per se. If we need to push for this on a subsequent patch, that's OK.) If we do put the config option back in, then there's a mistake in the wording that needs to be fixed. The statement "loops_per_jiffy is roughly BogoMips * 5000." This is only true when HZ is 100. This statement should just be removed - the rest of the wording works without it. With regard to testing - everything worked as expected. I think the config option issue is the last thing to be resolved before recommending that the patch be applied. ============================= Tim Bird Architecture Group Co-Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics E-mail: tim.bird@am.sony.com ============================= ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-12 22:41 ` Tim Bird @ 2004-07-13 19:24 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 29+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2004-07-13 19:24 UTC (permalink / raw) To: Tim Bird, Adam Kropelin Cc: Andrew Morton, Geert Uytterhoeven, karim, linux-kernel, celinux-dev, tpoynor Hi, On Tuesday 13 of July 2004 00:41, Tim Bird wrote: > Adam Kropelin wrote: > > On Mon, Jul 12, 2004 at 11:52:44AM -0700, Tim Bird wrote: > >>Adam Kropelin wrote: > >>>Here's a patch. It places the relevant information on the same line as > >>>bogomips and does so without encouraging anyone to fiddle with > >>>loops_per_jiffy and screw up their kernel. > >> > >>The patch is missing the Kconfig piece. Is the wording the > >>same as from your earlier patch? > > > > Andrew requested that the config option be removed, so there are no > > longer any changes to Kconfig. > > Oh - I missed the change where preset_lpj is no longer initialized > from CONFIG_PRESET_LPJ. I see it now. I saw the comment from > Andrew, but thought he was talking about the first version of the > patch that had ifdefs. > > Here's what Andrew Morton said: > > a) I don't see much point in making it configurable. Just add the boot > > option and be done with it. The few hundred bytes of extra code will > > be dropped from core anyway. > > > > The main reason for this is that most people won't turn on the config > > option, so your new code could get accidentally broken quite easily. > > Plus it removes some ifdefs. > > I have one or two arguments in favor of keeping the config option. > First, for embedded systems it is sometimes necessary to compile-in > the value. Unfortunately, not all architectures allow the > kernel command line to be compiled in. (It would be nice if they did, > but that's something to fix separately.) Many do (i.e. arm, h8300, mips, ppc, sh) and IMHO it is better to fix it separately where needed. > The first restructuring of the patch that you did, I think addresses > the issues that Andrew raised. There are now no ifdefs, and since the > core code doesn't drop away (and indeed can be turned on at boot time > if needed), I think the code is not susceptible to accidental breakage > like the first version was. I think Andrew is right that the preset > code path won't get much testing outside of embedded circles, so it is > important that it be as simple as possible. > > The only *code* change from the configurable to the config-less version > of the code is: > > +static unsigned long preset_lpj = CONFIG_PRESET_LPJ; > vs. > +static unsigned long preset_lpj; with the latter statement 'preset_lpj' ends up in BSS instead of data section ;-) > Secondly, I was hoping to get the FASTBOOT menu in the kernel, because > CELF has a few more patches to submit that have the same theme as this > one. (I realize this is not justification for making this option > configurable, per se. If we need to push for this on a subsequent patch, > that's OK.) Separate patch please if/when needed. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] preset loops_per_jiffy for faster booting 2004-07-11 1:25 ` Andrew Morton 2004-07-11 3:44 ` Adam Kropelin @ 2004-07-12 17:50 ` Tim Bird 1 sibling, 0 replies; 29+ messages in thread From: Tim Bird @ 2004-07-12 17:50 UTC (permalink / raw) To: Andrew Morton Cc: Adam Kropelin, dtor_core, linux-kernel, celinux-dev, tpoynor, geert Andrew Morton wrote: > "Adam Kropelin" <akropel1@rochester.rr.com> wrote: > >>>Does 250 ms worth all this pain? My requirement is to get to user space in 500 ms from product cold start. It would be very nice to do so in 250 ms, to give user space init more time. This requirement is pretty characteristic of many CE products. >> >> On a desktop box, almost certainly not. On a massive SMP machine, maybe. On >> an embedded system that is required to boot in a ridiculously short time, >> absolutely. > > Yes, it's pretty small beer, but we do recognise that although the number > of development teams which use features like this is small, the number of > systems is large, so the features are correspondingly more important. > > One of the services which we kernel developers provide the downstream > kernel users is the hosting and maintenance of their code so they don't > have to carry important stuff off-stream, and when the changes are this > small and simple, I don't see a problem with merging them, even if none of > "us" will use the feature. Thanks. Even if our features aren't mainstream, if we can make them unintrusive, it's nice to get them integrated. The help offered here, to make this as unintrusive and danger-free as possible, is really appreciated. As to the number of developers and systems using this, I would wager that developers at almost every CE company will use this (with developers in the 100s), and that it will affect (at least) 100s of thousands of devices (possibly millions, depending on how Linux does in cell phones). ============================= Tim Bird Architecture Group Co-Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics E-mail: tim.bird@am.sony.com ============================= ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2004-07-13 19:18 UTC | newest] Thread overview: 29+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-07-09 19:25 [PATCH] preset loops_per_jiffy for faster booting Tim Bird 2004-07-09 22:24 ` Adam Kropelin 2004-07-09 23:35 ` Adam Kropelin 2004-07-10 0:20 ` Tim Bird 2004-07-10 2:01 ` Adam Kropelin 2004-07-10 2:01 ` Todd Poynor 2004-07-10 15:42 ` Adam Kropelin 2004-07-10 14:41 ` [Celinux-dev] " Geert Uytterhoeven 2004-07-10 15:22 ` Adam Kropelin 2004-07-10 15:54 ` Adam Kropelin 2004-07-10 18:28 ` Adam Kropelin 2004-07-10 18:19 ` Dmitry Torokhov 2004-07-10 20:14 ` Adam Kropelin 2004-07-11 1:25 ` Andrew Morton 2004-07-11 3:44 ` Adam Kropelin 2004-07-11 4:38 ` Andrew Morton 2004-07-12 17:31 ` Tim Bird 2004-07-11 4:51 ` Dmitry Torokhov 2004-07-11 4:58 ` Karim Yaghmour 2004-07-11 5:19 ` Dmitry Torokhov 2004-07-11 5:27 ` Andrew Morton 2004-07-11 7:46 ` Geert Uytterhoeven 2004-07-11 7:51 ` Andrew Morton 2004-07-11 13:41 ` Adam Kropelin 2004-07-12 18:52 ` Tim Bird 2004-07-12 19:32 ` Adam Kropelin 2004-07-12 22:41 ` Tim Bird 2004-07-13 19:24 ` Bartlomiej Zolnierkiewicz 2004-07-12 17:50 ` Tim Bird
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox