linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init: Don't decrease loops_per_jiffy when a CPU comes up
@ 2014-05-07 23:50 Doug Anderson
  2014-05-09 16:03 ` Paul Gortmaker
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Anderson @ 2014-05-07 23:50 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: John Stultz, David Riley, Will Deacon, olof, Sonny Rao,
	Russell King, Doug Anderson, linux-kernel

The loops_per_jiffy count continues to be updated as each CPU is
brought up.  This causes problems when we've got an HMP system and
different CPUs have different loops per jiffy.  On exynos 542x
systems, for instance, the A7s will have significantly lower loops per
jiffy than their big brothers.

We should always set the loops_per_jiffy the first time through, then
use the max.

One could argue that complex HMP systems should really be completely
ignoring the global loops_per_jiffy variable anyway.  That's probably
why nobody has fixed this before.  With that argument you could say
that while this change isn't incorrect, it's a bit misguided.  Still,
it doesn't hurt and provides a better fallback than we had without
this.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 init/calibrate.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/init/calibrate.c b/init/calibrate.c
index 520702d..073bf9b 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -265,40 +265,44 @@ unsigned long __attribute__((weak)) calibrate_delay_is_known(void)
 void calibrate_delay(void)
 {
 	unsigned long lpj;
-	static bool printed;
+	static bool already_ran;
 	int this_cpu = smp_processor_id();
 
 	if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
 		lpj = per_cpu(cpu_loops_per_jiffy, this_cpu);
-		if (!printed)
+		if (!already_ran)
 			pr_info("Calibrating delay loop (skipped) "
 				"already calibrated this CPU");
 	} else if (preset_lpj) {
 		lpj = preset_lpj;
-		if (!printed)
+		if (!already_ran)
 			pr_info("Calibrating delay loop (skipped) "
 				"preset value.. ");
-	} else if ((!printed) && lpj_fine) {
+	} else if ((!already_ran) && lpj_fine) {
 		lpj = lpj_fine;
 		pr_info("Calibrating delay loop (skipped), "
 			"value calculated using timer frequency.. ");
 	} else if ((lpj = calibrate_delay_is_known())) {
 		;
 	} else if ((lpj = calibrate_delay_direct()) != 0) {
-		if (!printed)
+		if (!already_ran)
 			pr_info("Calibrating delay using timer "
 				"specific routine.. ");
 	} else {
-		if (!printed)
+		if (!already_ran)
 			pr_info("Calibrating delay loop... ");
 		lpj = calibrate_delay_converge();
 	}
 	per_cpu(cpu_loops_per_jiffy, this_cpu) = lpj;
-	if (!printed)
+	if (!already_ran) {
 		pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
 			lpj/(500000/HZ),
 			(lpj/(5000/HZ)) % 100, lpj);
 
-	loops_per_jiffy = lpj;
-	printed = true;
+		loops_per_jiffy = lpj;
+	} else {
+		loops_per_jiffy = max(loops_per_jiffy, lpj);
+	}
+
+	already_ran = true;
 }
-- 
1.9.1.423.g4596e3a


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] init: Don't decrease loops_per_jiffy when a CPU comes up
  2014-05-07 23:50 [PATCH] init: Don't decrease loops_per_jiffy when a CPU comes up Doug Anderson
@ 2014-05-09 16:03 ` Paul Gortmaker
  2014-05-13 22:54   ` Doug Anderson
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Gortmaker @ 2014-05-09 16:03 UTC (permalink / raw)
  To: Doug Anderson
  Cc: John Stultz, David Riley, Will Deacon, olof, Sonny Rao,
	Russell King, linux-kernel

On 14-05-07 07:50 PM, Doug Anderson wrote:
> The loops_per_jiffy count continues to be updated as each CPU is
> brought up.  This causes problems when we've got an HMP system and
> different CPUs have different loops per jiffy.  On exynos 542x
> systems, for instance, the A7s will have significantly lower loops per
> jiffy than their big brothers.

Based on the other discussion for the ARM variant of this, I'm
assuming this also becomes a WFC issue.  And if not, then it
probably should go by John or similar ; getmaintainers is just
being dumb in spitting my name out, since I only made one
trivial change to this file a year ago or similar.

P.
--

> 
> We should always set the loops_per_jiffy the first time through, then
> use the max.
> 
> One could argue that complex HMP systems should really be completely
> ignoring the global loops_per_jiffy variable anyway.  That's probably
> why nobody has fixed this before.  With that argument you could say
> that while this change isn't incorrect, it's a bit misguided.  Still,
> it doesn't hurt and provides a better fallback than we had without
> this.
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>  init/calibrate.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/init/calibrate.c b/init/calibrate.c
> index 520702d..073bf9b 100644
> --- a/init/calibrate.c
> +++ b/init/calibrate.c
> @@ -265,40 +265,44 @@ unsigned long __attribute__((weak)) calibrate_delay_is_known(void)
>  void calibrate_delay(void)
>  {
>  	unsigned long lpj;
> -	static bool printed;
> +	static bool already_ran;
>  	int this_cpu = smp_processor_id();
>  
>  	if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
>  		lpj = per_cpu(cpu_loops_per_jiffy, this_cpu);
> -		if (!printed)
> +		if (!already_ran)
>  			pr_info("Calibrating delay loop (skipped) "
>  				"already calibrated this CPU");
>  	} else if (preset_lpj) {
>  		lpj = preset_lpj;
> -		if (!printed)
> +		if (!already_ran)
>  			pr_info("Calibrating delay loop (skipped) "
>  				"preset value.. ");
> -	} else if ((!printed) && lpj_fine) {
> +	} else if ((!already_ran) && lpj_fine) {
>  		lpj = lpj_fine;
>  		pr_info("Calibrating delay loop (skipped), "
>  			"value calculated using timer frequency.. ");
>  	} else if ((lpj = calibrate_delay_is_known())) {
>  		;
>  	} else if ((lpj = calibrate_delay_direct()) != 0) {
> -		if (!printed)
> +		if (!already_ran)
>  			pr_info("Calibrating delay using timer "
>  				"specific routine.. ");
>  	} else {
> -		if (!printed)
> +		if (!already_ran)
>  			pr_info("Calibrating delay loop... ");
>  		lpj = calibrate_delay_converge();
>  	}
>  	per_cpu(cpu_loops_per_jiffy, this_cpu) = lpj;
> -	if (!printed)
> +	if (!already_ran) {
>  		pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
>  			lpj/(500000/HZ),
>  			(lpj/(5000/HZ)) % 100, lpj);
>  
> -	loops_per_jiffy = lpj;
> -	printed = true;
> +		loops_per_jiffy = lpj;
> +	} else {
> +		loops_per_jiffy = max(loops_per_jiffy, lpj);
> +	}
> +
> +	already_ran = true;
>  }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] init: Don't decrease loops_per_jiffy when a CPU comes up
  2014-05-09 16:03 ` Paul Gortmaker
@ 2014-05-13 22:54   ` Doug Anderson
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2014-05-13 22:54 UTC (permalink / raw)
  To: Paul Gortmaker, John Stultz
  Cc: David Riley, Will Deacon, Olof Johansson, Sonny Rao,
	Russell King, linux-kernel

Paul,

On Fri, May 9, 2014 at 9:03 AM, Paul Gortmaker
<paul.gortmaker@windriver.com> wrote:
> On 14-05-07 07:50 PM, Doug Anderson wrote:
>> The loops_per_jiffy count continues to be updated as each CPU is
>> brought up.  This causes problems when we've got an HMP system and
>> different CPUs have different loops per jiffy.  On exynos 542x
>> systems, for instance, the A7s will have significantly lower loops per
>> jiffy than their big brothers.
>
> Based on the other discussion for the ARM variant of this, I'm
> assuming this also becomes a WFC issue.  And if not, then it
> probably should go by John or similar ; getmaintainers is just
> being dumb in spitting my name out, since I only made one
> trivial change to this file a year ago or similar.

I think this change could still make sense.  The ARM discussion is
about dealing with the scaling that the ARM code does, but it really
is a separate concept.

In general it seems like at least a warning is in order if
loops_per_jiffy changes significantly from CPU to CPU.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-13 22:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 23:50 [PATCH] init: Don't decrease loops_per_jiffy when a CPU comes up Doug Anderson
2014-05-09 16:03 ` Paul Gortmaker
2014-05-13 22:54   ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).