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

From: Joe Perches
Date: Fri Jun 03 2011 - 18:00:21 EST


On Fri, 2011-06-03 at 14:45 -0700, Andrew Morton wrote:
> But the whole thing is a bit weird. Does this look better?
> Make these messages more gramatically pleasing, more consistent and remove
> strange ellipses.

or maybe something like this:

init/calibrate.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/init/calibrate.c b/init/calibrate.c
index cfd7000..827a45c 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -246,32 +246,38 @@ recalibrate:
return lpj;
}

+static DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 };
+
void __cpuinit calibrate_delay(void)
{
+ int this_cpu = smp_processor_id();
static bool printed;
+ const char *msg;

- if (preset_lpj) {
+ if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
+ loops_per_jiffy = per_cpu(cpu_loops_per_jiffy, this_cpu);
+ msg = " CPU previously calibrated";
+ } else if (preset_lpj) {
loops_per_jiffy = preset_lpj;
- if (!printed)
- pr_info("Calibrating delay loop (skipped) "
- "preset value.. ");
+ msg = " preset value";
} else if ((!printed) && lpj_fine) {
loops_per_jiffy = lpj_fine;
- pr_info("Calibrating delay loop (skipped), "
- "value calculated using timer frequency.. ");
+ msg = " using timer frequency";
} else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) {
- if (!printed)
- pr_info("Calibrating delay using timer "
- "specific routine.. ");
+ msg = " using timer specific routine";
} else {
- if (!printed)
- pr_info("Calibrating delay loop... ");
+ pr_info("Calibrating delay loop...\n");
loops_per_jiffy = calibrate_delay_converge();
+ per_cpu(cpu_loops_per_jiffy, this_cpu) = loops_per_jiffy;
+ msg = "";
}
- if (!printed)
- pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
+
+ if (!printed) {
+ pr_info("Delay loop calibration:%s %lu.%02lu BogoMIPS (lpj=%lu)\n",
+ msg,
loops_per_jiffy/(500000/HZ),
(loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy);

- printed = true;
+ printed = true;
+ }
}


--
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/