diff mbox

[SRU,wily] Fix KNL Intel P State driver divide by zero

Message ID 8082FF9BCB2B054996454E47167FF4EC0B0C6AD8@SHSMSX104.ccr.corp.intel.com
State New
Headers show

Commit Message

Xiong Zhang Oct. 20, 2015, 8:40 a.m. UTC
The following commit is from 4.3 kernel which fix devide by zero in intel P state driver on KNL.

commit 8e601a9f97a00bab031980de34f9a81891c1f82f
Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date:   Thu Oct 15 12:34:21 2015 -0700

    cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL)

    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.

    Fixes: b34ef932d79a (intel_pstate: Knights Landing support)
    Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Acked-by: Kristen Carlson Accardi <kristen@linux.intel.com>
    Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

thanks

Comments

Tim Gardner Oct. 20, 2015, 12:40 p.m. UTC | #1
On 10/20/2015 02:40 AM, Zhang, Xiong Y wrote:
> The following commit is from 4.3 kernel which fix devide by zero in
> intel P state driver on KNL.
>  
> commit 8e601a9f97a00bab031980de34f9a81891c1f82f
> Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Date:   Thu Oct 15 12:34:21 2015 -0700
>  
>     cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL)
>  
>     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.
>  
>     Fixes: b34ef932d79a (intel_pstate: Knights Landing support)
>     Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
>     Acked-by: Kristen Carlson Accardi <kristen@linux.intel.com>
>     Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
>     Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>  
> 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);
>  
> thanks
>  
> 
> 

Wily is now subject to SRU policies. Do you have a bug report for this
patch ?

rtg
Xiong Zhang Oct. 21, 2015, 1:33 a.m. UTC | #2
> On 10/20/2015 02:40 AM, Zhang, Xiong Y wrote:
> > The following commit is from 4.3 kernel which fix devide by zero in
> > intel P state driver on KNL.
> >
> > commit 8e601a9f97a00bab031980de34f9a81891c1f82f
> > Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > Date:   Thu Oct 15 12:34:21 2015 -0700
> >
> >     cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL)
> >
> >     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.
> >
> >     Fixes: b34ef932d79a (intel_pstate: Knights Landing support)
> >     Signed-off-by: Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com>
> >     Acked-by: Kristen Carlson Accardi <kristen@linux.intel.com>
> >     Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
> >     Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > 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);
> >
> > thanks
> >
> >
> >
> 
> Wily is now subject to SRU policies. Do you have a bug report for this
> patch ?
[Zhang, Xiong Y] We only have a bug report internally and don't have one on launchpad. Because I don't have KNL hardware, so I couldn't fill one on launchpad and couldn't supply the verification.
> 
> rtg
> 
> 
> --
> Tim Gardner tim.gardner@canonical.com
Brad Figg Oct. 26, 2015, 8:27 p.m. UTC | #3
On Wed, Oct 21, 2015 at 01:33:16AM +0000, Zhang, Xiong Y wrote:
> > On 10/20/2015 02:40 AM, Zhang, Xiong Y wrote:
> > > The following commit is from 4.3 kernel which fix devide by zero in
> > > intel P state driver on KNL.
> > >
> > > commit 8e601a9f97a00bab031980de34f9a81891c1f82f
> > > Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > > Date:   Thu Oct 15 12:34:21 2015 -0700
> > >
> > >     cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL)
> > >
> > >     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.
> > >
> > >     Fixes: b34ef932d79a (intel_pstate: Knights Landing support)
> > >     Signed-off-by: Srinivas Pandruvada
> > <srinivas.pandruvada@linux.intel.com>
> > >     Acked-by: Kristen Carlson Accardi <kristen@linux.intel.com>
> > >     Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
> > >     Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > >
> > > 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);
> > >
> > > thanks
> > >
> > >
> > >
> > 
> > Wily is now subject to SRU policies. Do you have a bug report for this
> > patch ?
> [Zhang, Xiong Y] We only have a bug report internally and don't have one on launchpad. Because I don't have KNL hardware, so I couldn't fill one on launchpad and couldn't supply the verification.

You don't need the specific HW in order to create a bug for this. However,
someone needs to be able to verify the kernel that has the fix does the
right thing. You need to find someone with the HW in order to verify the
fix.

Brad

> > 
> > rtg
> > 
> > 
> > --
> > Tim Gardner tim.gardner@canonical.com
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
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);