From: "Jan Beulich" Subject: Re: [V6] x86/cpuidle: get accurate C0 value with xenpm tool Date: Thu, 21 May 2015 07:50:20 +0100 Message-ID: <555D9C4C020000780007C8BD@mail.emea.novell.com> References: <1432190417-9890-1-git-send-email-huaitong.han@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1432190417-9890-1-git-send-email-huaitong.han@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Huaitong Han Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 21.05.15 at 08:40, wrote: > @@ -329,7 +340,7 @@ static uint64_t acpi_pm_ticks_elapsed(uint64_t t1, uint64_t t2) > } > > uint64_t (*__read_mostly cpuidle_get_tick)(void) = get_acpi_pm_tick; > -static uint64_t (*__read_mostly ticks_elapsed)(uint64_t, uint64_t) > +uint64_t (*__read_mostly ticks_elapsed)(uint64_t, uint64_t) > = acpi_pm_ticks_elapsed; Why? (And if a change like this was needed, you'd have to rename the symbol to become identifiable as cpuidle specific, just like its neighbor is). > @@ -1203,13 +1235,24 @@ int pmstat_get_cx_stat(uint32_t cpuid, struct > pm_cx_stat *stat) > > stat->nr = power->count; > > + spin_lock_irq(&power->stat_lock); > + current_tick = cpuidle_get_tick(); > + current_stime = NOW(); > for ( i = 1; i < nr; i++ ) > { > - spin_lock_irq(&power->stat_lock); > usage[i] = power->states[i].usage; > - res[i] = tick_to_ns(power->states[i].time); > - spin_unlock_irq(&power->stat_lock); > + res[i] = power->states[i].time; > + } > + last_state_update_tick = power->last_state_update_tick; > + stat->last = power->last_state ? power->last_state->idx : 0; > + spin_unlock_irq(&power->stat_lock); > > + usage[stat->last]++; > + res[stat->last] += ticks_elapsed(last_state_update_tick, current_tick); > + > + for ( i = 1; i < nr; i++ ) > + { > + res[i] = tick_to_ns((uint64_t)res[i]); Completely pointless cast. Jan