diff mbox

[v1] cpufreq: intel_pstate: divide by zero on Knights Landing (KNL)

Message ID 1444937661-9519-2-git-send-email-srinivas.pandruvada@linux.intel.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

srinivas pandruvada Oct. 15, 2015, 7:34 p.m. UTC
This is a workaround for KNL platform, where in some cases MPERF counter
will not have updated value before next read of MSR_IA32_MPERF. In this
case divide by zero will occur. This change ignores current sample for
busy calculation in this case.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kristen Carlson Accardi Oct. 15, 2015, 8:43 p.m. UTC | #1
On Thu, 15 Oct 2015 12:34:21 -0700
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:

> This is a workaround for KNL platform, where in some cases MPERF counter
> will not have updated value before next read of MSR_IA32_MPERF. In this
> case divide by zero will occur. This change ignores current sample for
> busy calculation in this case.
> 
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 3af9dd7..aa33b92 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -776,6 +776,11 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
>  	local_irq_save(flags);
>  	rdmsrl(MSR_IA32_APERF, aperf);
>  	rdmsrl(MSR_IA32_MPERF, mperf);
> +	if (cpu->prev_mperf == mperf) {
> +		local_irq_restore(flags);
> +		return;
> +	}
> +
>  	tsc = rdtsc();
>  	local_irq_restore(flags);
>  

Acked-by: Kristen Carlson Accardi <kristen@linux.intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki Oct. 15, 2015, 9:09 p.m. UTC | #2
On Thursday, October 15, 2015 12:34:21 PM Srinivas Pandruvada wrote:
> This is a workaround for KNL platform, where in some cases MPERF counter
> will not have updated value before next read of MSR_IA32_MPERF. In this
> case divide by zero will occur. This change ignores current sample for
> busy calculation in this case.
> 
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Applied.

I've also marked it for 4.1.y-stable (and later).

Kristen, please let me know if there are any concerns regarding this one.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 3af9dd7..aa33b92 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -776,6 +776,11 @@  static inline void intel_pstate_sample(struct cpudata *cpu)
 	local_irq_save(flags);
 	rdmsrl(MSR_IA32_APERF, aperf);
 	rdmsrl(MSR_IA32_MPERF, mperf);
+	if (cpu->prev_mperf == mperf) {
+		local_irq_restore(flags);
+		return;
+	}
+
 	tsc = rdtsc();
 	local_irq_restore(flags);