perf/x86/intel/rapl: Calculate timing once
No point in doing the same calculation over and over. Do it once in rapl_check_hw_unit(). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andi Kleen <andi.kleen@intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Harish Chegondi <harish.chegondi@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20160222221012.409238136@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Родитель
b8b3319a47
Коммит
75c7003fbf
|
@ -129,6 +129,7 @@ static int rapl_hw_unit[NR_RAPL_DOMAINS] __read_mostly; /* 1/2^hw_unit Joule */
|
||||||
static struct pmu rapl_pmu_class;
|
static struct pmu rapl_pmu_class;
|
||||||
static cpumask_t rapl_cpu_mask;
|
static cpumask_t rapl_cpu_mask;
|
||||||
static int rapl_cntr_mask;
|
static int rapl_cntr_mask;
|
||||||
|
static u64 rapl_timer_ms;
|
||||||
|
|
||||||
static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu);
|
static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu);
|
||||||
static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu_to_free);
|
static DEFINE_PER_CPU(struct rapl_pmu *, rapl_pmu_to_free);
|
||||||
|
@ -558,7 +559,6 @@ static int rapl_cpu_prepare(int cpu)
|
||||||
{
|
{
|
||||||
struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
|
struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
|
||||||
int phys_id = topology_physical_package_id(cpu);
|
int phys_id = topology_physical_package_id(cpu);
|
||||||
u64 ms;
|
|
||||||
|
|
||||||
if (pmu)
|
if (pmu)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -575,19 +575,7 @@ static int rapl_cpu_prepare(int cpu)
|
||||||
|
|
||||||
pmu->pmu = &rapl_pmu_class;
|
pmu->pmu = &rapl_pmu_class;
|
||||||
|
|
||||||
/*
|
pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
|
||||||
* use reference of 200W for scaling the timeout
|
|
||||||
* to avoid missing counter overflows.
|
|
||||||
* 200W = 200 Joules/sec
|
|
||||||
* divide interval by 2 to avoid lockstep (2 * 100)
|
|
||||||
* if hw unit is 32, then we use 2 ms 1/200/2
|
|
||||||
*/
|
|
||||||
if (rapl_hw_unit[0] < 32)
|
|
||||||
ms = (1000 / (2 * 100)) * (1ULL << (32 - rapl_hw_unit[0] - 1));
|
|
||||||
else
|
|
||||||
ms = 2;
|
|
||||||
|
|
||||||
pmu->timer_interval = ms_to_ktime(ms);
|
|
||||||
|
|
||||||
rapl_hrtimer_init(pmu);
|
rapl_hrtimer_init(pmu);
|
||||||
|
|
||||||
|
@ -676,6 +664,19 @@ static int rapl_check_hw_unit(void (*quirk)(void))
|
||||||
/* Apply cpu model quirk */
|
/* Apply cpu model quirk */
|
||||||
if (quirk)
|
if (quirk)
|
||||||
quirk();
|
quirk();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate the timer rate:
|
||||||
|
* Use reference of 200W for scaling the timeout to avoid counter
|
||||||
|
* overflows. 200W = 200 Joules/sec
|
||||||
|
* Divide interval by 2 to avoid lockstep (2 * 100)
|
||||||
|
* if hw unit is 32, then we use 2 ms 1/200/2
|
||||||
|
*/
|
||||||
|
rapl_timer_ms = 2;
|
||||||
|
if (rapl_hw_unit[0] < 32) {
|
||||||
|
rapl_timer_ms = (1000 / (2 * 100));
|
||||||
|
rapl_timer_ms *= (1ULL << (32 - rapl_hw_unit[0] - 1));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,9 +696,7 @@ static const struct x86_cpu_id rapl_cpu_match[] = {
|
||||||
static int __init rapl_pmu_init(void)
|
static int __init rapl_pmu_init(void)
|
||||||
{
|
{
|
||||||
void (*quirk)(void) = NULL;
|
void (*quirk)(void) = NULL;
|
||||||
struct rapl_pmu *pmu;
|
int cpu, ret, i;
|
||||||
int cpu, ret;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check for Intel processor family 6
|
* check for Intel processor family 6
|
||||||
|
@ -758,15 +757,14 @@ static int __init rapl_pmu_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
__perf_cpu_notifier(rapl_cpu_notifier);
|
__perf_cpu_notifier(rapl_cpu_notifier);
|
||||||
|
cpu_notifier_register_done();
|
||||||
pmu = __this_cpu_read(rapl_pmu);
|
|
||||||
|
|
||||||
pr_info("RAPL PMU detected,"
|
pr_info("RAPL PMU detected,"
|
||||||
" API unit is 2^-32 Joules,"
|
" API unit is 2^-32 Joules,"
|
||||||
" %d fixed counters"
|
" %d fixed counters"
|
||||||
" %llu ms ovfl timer\n",
|
" %llu ms ovfl timer\n",
|
||||||
hweight32(rapl_cntr_mask),
|
hweight32(rapl_cntr_mask),
|
||||||
ktime_to_ms(pmu->timer_interval));
|
rapl_timer_ms);
|
||||||
for (i = 0; i < NR_RAPL_DOMAINS; i++) {
|
for (i = 0; i < NR_RAPL_DOMAINS; i++) {
|
||||||
if (rapl_cntr_mask & (1 << i)) {
|
if (rapl_cntr_mask & (1 << i)) {
|
||||||
pr_info("hw unit of domain %s 2^-%d Joules\n",
|
pr_info("hw unit of domain %s 2^-%d Joules\n",
|
||||||
|
@ -774,7 +772,6 @@ static int __init rapl_pmu_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_notifier_register_done();
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче