Re: [PATCH] init: skip calibration delay if previously done

From: Sameer Nanda
Date: Fri Jun 03 2011 - 18:16:52 EST


On Fri, Jun 3, 2011 at 2:45 PM, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 03 Jun 2011 14:08:01 -0700
> David Daney <ddaney@xxxxxxxxxxxxxxxxxx> wrote:
>
> > On 06/03/2011 02:00 PM, Andrew Morton wrote:
> > > On Tue, 24 May 2011 16:19:06 -0700
> > > Sameer Nanda<snanda@xxxxxxxxxxxx> Âwrote:
> > >
> > >> For each CPU, do the calibration delay only once. For subsequent calls,
> > >> use the cached per-CPU value of loops_per_jiffy.
> > >>
> > >> This saves about 200ms of resume time on dual core Intel Atom N5xx based
> > >> systems. This helps bring down the kernel resume time on such systems from
> > >> about 500ms to about 300ms.
> > >>
> > >> Signed-off-by: Sameer Nanda<snanda@xxxxxxxxxxxx>
> > >> ---
> > >> Â init/calibrate.c | Â 10 +++++++++-
> > >> Â 1 files changed, 9 insertions(+), 1 deletions(-)
> > >>
> > >> diff --git a/init/calibrate.c b/init/calibrate.c
> > >> index 76ac919..47d3408 100644
> > >> --- a/init/calibrate.c
> > >> +++ b/init/calibrate.c
> > >> @@ -183,11 +183,18 @@ recalibrate:
> > >> Â Âreturn lpj;
> > >> Â }
> > >>
> > >> +DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 };
> > >> +
> > >> Â void __cpuinit calibrate_delay(void)
> > >> Â {
> > >> Â Âstatic bool printed;
> > >> + Âint this_cpu = smp_processor_id();
> > >>
> > >> - Âif (preset_lpj) {
> > >> + Âif (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
> > >> + Â Â Â Â Âloops_per_jiffy = per_cpu(cpu_loops_per_jiffy, this_cpu);
> > >> + Â Â Â Â Âpr_info("Calibrating delay loop (skipped) "
> > >> + Â Â Â Â Â Â Â Â Â Â Â Â Â"already calibrated this CPU previously.. ");
> >
> > That wording seems a little redundant, and there are two '.' at the end.
> >
> > How about:
> > s/"already calibrated this CPU previously.. "/", this CPU previously
> > calibrated."/
> >
>
> Pedant ;)
>
> --- a/init/calibrate.c~init-skip-calibration-delay-if-previously-done-fix-fix
> +++ a/init/calibrate.c
> @@ -256,7 +256,7 @@ void __cpuinit calibrate_delay(void)
> Â Â Â Âif (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
> Â Â Â Â Â Â Â Âloops_per_jiffy = per_cpu(cpu_loops_per_jiffy, this_cpu);
> Â Â Â Â Â Â Â Âpr_info("Calibrating delay loop (skipped) "
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "already calibrated this CPU previously.. ");
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "already calibrated this CPU");
> Â Â Â Â} else if (preset_lpj) {
> Â Â Â Â Â Â Â Âloops_per_jiffy = preset_lpj;
> Â Â Â Â Â Â Â Âif (!printed)
> _
>
> But the whole thing is a bit weird. ÂDoes this look better?
>
> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>
> Make these messages more gramatically pleasing, more consistent and remove
> strange ellipses.
>
> Cc: Andrew Worsley <amworsley@xxxxxxxxx>
> Cc: Phil Carmody <ext-phil.2.carmody@xxxxxxxxx>
> Cc: Sameer Nanda <snanda@xxxxxxxxxxxx>
> Cc: David Daney <ddaney@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> ---
>
> Âinit/calibrate.c | Â 18 +++++++++---------
> Â1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff -puN init/calibrate.c~init-calibratec-calibrate_delay-tidy-up-the-pr_info-messages init/calibrate.c
> --- a/init/calibrate.c~init-calibratec-calibrate_delay-tidy-up-the-pr_info-messages
> +++ a/init/calibrate.c
> @@ -255,24 +255,24 @@ void __cpuinit calibrate_delay(void)
>
> Â Â Â Âif (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
> Â Â Â Â Â Â Â Âloops_per_jiffy = per_cpu(cpu_loops_per_jiffy, this_cpu);
> - Â Â Â Â Â Â Â pr_info("Calibrating delay loop (skipped) "
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "already calibrated this CPU");
> + Â Â Â Â Â Â Â pr_info("Calibrating delay loop. ÂSkipped: already calibrated "
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "this CPU");
> Â Â Â Â} else if (preset_lpj) {
> Â Â Â Â Â Â Â Âloops_per_jiffy = preset_lpj;
> Â Â Â Â Â Â Â Âif (!printed)
> - Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay loop (skipped) "
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "preset value.. ");
> + Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay loop. ÂSkipped: "
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "preset value");
> Â Â Â Â} else if ((!printed) && lpj_fine) {
> Â Â Â Â Â Â Â Âloops_per_jiffy = lpj_fine;
> - Â Â Â Â Â Â Â pr_info("Calibrating delay loop (skipped), "
> - Â Â Â Â Â Â Â Â Â Â Â "value calculated using timer frequency.. ");
> + Â Â Â Â Â Â Â pr_info("Calibrating delay loop. ÂSkipped: value calculated "
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "using timer frequency");
> Â Â Â Â} else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) {
> Â Â Â Â Â Â Â Âif (!printed)
> - Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay using timer "
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "specific routine.. ");
> + Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay loop using timer-specific "
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "routine");
> Â Â Â Â} else {
> Â Â Â Â Â Â Â Âif (!printed)
> - Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay loop... ");
> + Â Â Â Â Â Â Â Â Â Â Â pr_info("Calibrating delay loop");
> Â Â Â Â Â Â Â Âloops_per_jiffy = calibrate_delay_converge();
> Â Â Â Â}
> Â Â Â Âper_cpu(cpu_loops_per_jiffy, this_cpu) = loops_per_jiffy;
> _
>

Thanks for picking this up.
Mind adding the following to this patch to prevent ARM build breakage :)

diff --git a/init/calibrate.c b/init/calibrate.c
index ec1e528..1b76597 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -9,6 +9,7 @@
#include <linux/init.h>
#include <linux/timex.h>
#include <linux/smp.h>
+#include <linux/percpu.h>

unsigned long lpj_fine;
unsigned long preset_lpj;





--
Sameer
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/