Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1308870

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

From Jacob Pan <jacob.jun.pan@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls
Date 2016-01-13 23:30 +0100
Message-ID <qQC5s-67v-3@gated-at.bofh.it> (permalink)
References (6 earlier) <qQy1Q-3qh-9@gated-at.bofh.it> <qQylc-3yp-1@gated-at.bofh.it> <qQz7A-44Y-25@gated-at.bofh.it> <qQA3D-4La-9@gated-at.bofh.it> <qQB9o-5uC-13@gated-at.bofh.it>
Organization OTC

Show all headers | View raw


On Wed, 13 Jan 2016 22:26:02 +0100
Borislav Petkov <bp@alien8.de> wrote:

> You mean something like this (I'm having hard time even figuring out
> what goes where):
> 
> 	if (newstate == DC_DISABLE) {
> 		pr_debug("CPU#%d disabling modulation\n", cpu);
> 		rmwmsrl_safe_on_cpu(cpu, MSR_IA32_THERM_CONTROL, (1
> << 4), 0); } else {
> 		pr_debug("CPU#%d setting duty cycle to %d%%\n", cpu,
> ((125 * newstate) / 10)); rmwmsrl_safe_on_cpu(cpu,
> MSR_IA32_THERM_CONTROL, 14, (1 << 4) |	((newstate &
> 0x7)<<1)); }
> 
> Now this is *absolutely* unreadable and hard to use. The previous
> version at least showed what happens to which bits. This call site
> will make everyone go look at the definition of rmwmsrl_safe_on_cpu()
> and see what those last two arguments do actually.
> 
To me the caller code became more readable. I think you are referring
the function name being not readable, which is separate of this
conversion.

> And, again, for the n-th time, this still doesn't work if you need to
> do other stuff between the rdmsr and wrmsr. So your interface will
> cover *some* cases but not all. So people should do
> rmwmsrl_safe_on_cpu() but not always - only if they don't need to do
> stuff between the reads and the writes.
> 
I know, I never disagreed with that :) which is why I am not using it in
the other cases in RAPL driver.
> Hmm, no thanks.
> 
> > > > 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?  
> 
> Like this?
> 
> 	rmwmsrl_safe_on_cpu(policy->cpu, MSR_IA32_PERF_CTL,
> 			    INTEL_PERF_CTL_MASK,
> 			    (u32)sfi_cpufreq_array[next_perf_state].ctrl_val
> & INTEL_PERF_CTL_MASK);
> 
> Yikes!
> 
> So yes, it can work but it is ugly, hard to parse and use, not generic
> enough, etc, etc.
I don't think the conversion adds extra ugliness. It actually makes it
more clear what is the mask to clear and what bits to set.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 02:20 +0100
  Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Thomas Gleixner <tglx@linutronix.de> - 2016-01-13 10:50 +0100
    Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 17:30 +0100
      Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 17:40 +0100
        Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 19:00 +0100
          Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 19:10 +0100
            Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 19:30 +0100
              Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 20:20 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 21:20 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 22:30 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-01-13 23:00 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Thomas Gleixner <tglx@linutronix.de> - 2016-01-13 23:10 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 23:20 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls "H. Peter Anvin" <hpa@zytor.com> - 2016-01-13 23:30 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 23:20 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-01-13 23:50 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-13 23:30 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Borislav Petkov <bp@alien8.de> - 2016-01-13 23:30 +0100
                Re: [PATCH v2 2/2] powercap/rapl: reduce ipi calls Thomas Gleixner <tglx@linutronix.de> - 2016-01-13 23:00 +0100

csiph-web