Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls

From: Jacob Pan
Date: Wed Jan 13 2016 - 15:10:22 EST


On Wed, 13 Jan 2016 20:16:22 +0100
Borislav Petkov <bp@xxxxxxxxx> wrote:

> On Wed, Jan 13, 2016 at 10:21:38AM -0800, Jacob Pan wrote:
> > static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
> > {
> > ...
> >
> > rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);
> > if (newstate == DC_DISABLE) {
> > pr_debug("CPU#%d disabling modulation\n", cpu);
> > wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l &
> > ~(1<<4), h); } else {
> > pr_debug("CPU#%d setting duty cycle to %d%%\n",
> > cpu, ((125 * newstate) / 10));
> > /* bits 63 - 5 : reserved
> > * bit 4 : enable/disable
> > * bits 3-1 : duty cycle
> > * bit 0 : reserved
> > */
> > l = (l & ~14);
> > l = l | (1<<4) | ((newstate & 0x7)<<1);
> > wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l, h);
> > }
>
> This cannot be converted because you need to do the stuff between the
> rdmsr_on_cpu() and wrmsr_on_cpu() calls.
>
it can be converted if move the below if statement outside read/write
pair.
if (newstate == DC_DISABLE) {

> > static int sfi_cpufreq_target(struct cpufreq_policy *policy,
> > unsigned int index) {
> > ...
> >
> > rdmsr_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, &lo, &hi);
> > lo = (lo & ~INTEL_PERF_CTL_MASK) |
> > ((u32) sfi_cpufreq_array[next_perf_state].ctrl_val &
> > INTEL_PERF_CTL_MASK);
> > wrmsr_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, lo, hi);
>
> Ditto.
>
> These two examples prove my point, actually.

same here, it is just clear mask and set mask, why not?