From: Peter Zijlstra <peterz@infradead.org>
To: Robert Richter <rric@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>, Josh Boyer <jwboyer@redhat.com>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
x86@kernel.org, linux-kernel@vger.kernel.org, gleb@redhat.com,
Jacob Shin <jacob.shin@amd.com>
Subject: Re: Drop WARN on AMD lack of perfctrs
Date: Tue, 21 May 2013 13:05:37 +0200 [thread overview]
Message-ID: <20130521110537.GG26912@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20130521085630.GA1860@rric.localhost>
On Tue, May 21, 2013 at 10:56:30AM +0200, Robert Richter wrote:
> On 17.05.13 12:57:30, Peter Zijlstra wrote:
> >
> > So what about something like the below?
>
> See my comments below, otherwise it looks fine to me.
I've been liberal and read an Ack there, holler if that needs be amended.
> There is the question about core performance counters and its
> constraints on fam16h. Not sure if there are any. Cc'ing Jacob.
Currently the code doesn't work for Fam16h afaict, so I didn't wreck
that did I?
> > /*
> > * If core performance counter extensions exists, we must use
> > * MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
>
> ... amd_pmu_addr_offset():
>
> * If core performance counter extensions exists, we must use
> * MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
> * amd_pmu_addr_offset().
>
Done.
> > @@ -675,8 +670,7 @@ static int setup_perfctr_core(void)
> > x86_pmu.perfctr = MSR_F15H_PERF_CTR;
> > x86_pmu.num_counters = AMD64_NUM_COUNTERS_CORE;
> >
> > - printk(KERN_INFO "perf: AMD core performance counters detected\n");
> > -
> > + pr_cont("core perfctr, ");
> > return 0;
> > }
> >
> > @@ -688,8 +682,8 @@ __init int amd_pmu_init(void)
> >
> > x86_pmu = amd_pmu;
> >
> > - setup_event_constraints();
> > - setup_perfctr_core();
> > + if (cpu_has_perfctr_core && amd_core_pmu_init())
> > + return -ENODEV;
>
> Better return result of amd_core_pmu_init().
Done.. that was admittedly a tad lazy of me :-)
---
Subject: perf, x86: Rework AMD PMU init code
From: Peter Zijlstra <peterz@infradead.org>
Date: Fri, 17 May 2013 12:57:30 +0200
Josh reported that his QEMU is a bad hardware emulator and trips a
WARN in the AMD PMU init code. He requested the WARN be turned into a
pr_err() or similar.
While there, rework the code a little.
Reported-by: Josh Boyer <jwboyer@redhat.com>
Acked-by: Robert Richter <rric@kernel.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
arch/x86/kernel/cpu/perf_event_amd.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -648,48 +648,48 @@ static __initconst const struct x86_pmu
.cpu_dead = amd_pmu_cpu_dead,
};
-static int setup_event_constraints(void)
+__init int amd_core_pmu_init(void)
{
- if (boot_cpu_data.x86 == 0x15)
+ if (!cpu_has_perfctr_core)
+ return 0;
+
+ switch (boot_cpu_data.x86) {
+ case 0x15:
+ pr_cont("Fam15h ");
x86_pmu.get_event_constraints = amd_get_event_constraints_f15h;
- return 0;
-}
+ break;
-static int setup_perfctr_core(void)
-{
- if (!cpu_has_perfctr_core) {
- WARN(x86_pmu.get_event_constraints == amd_get_event_constraints_f15h,
- KERN_ERR "Odd, counter constraints enabled but no core perfctrs detected!");
+ default:
+ pr_err("core perfctr but no constraints; unknown hardware!\n");
return -ENODEV;
}
- WARN(x86_pmu.get_event_constraints == amd_get_event_constraints,
- KERN_ERR "hw perf events core counters need constraints handler!");
-
/*
* If core performance counter extensions exists, we must use
* MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
- * x86_pmu_addr_offset().
+ * amd_pmu_addr_offset().
*/
x86_pmu.eventsel = MSR_F15H_PERF_CTL;
x86_pmu.perfctr = MSR_F15H_PERF_CTR;
x86_pmu.num_counters = AMD64_NUM_COUNTERS_CORE;
- printk(KERN_INFO "perf: AMD core performance counters detected\n");
-
+ pr_cont("core perfctr, ");
return 0;
}
__init int amd_pmu_init(void)
{
+ int ret;
+
/* Performance-monitoring supported from K7 and later: */
if (boot_cpu_data.x86 < 6)
return -ENODEV;
x86_pmu = amd_pmu;
- setup_event_constraints();
- setup_perfctr_core();
+ ret = amd_core_pmu_init();
+ if (ret)
+ return ret;
/* Events are common for all AMDs */
memcpy(hw_cache_event_ids, amd_hw_cache_event_ids,
next prev parent reply other threads:[~2013-05-21 13:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 15:10 Josh Boyer
2013-05-16 17:51 ` Peter Zijlstra
2013-05-16 17:55 ` Josh Boyer
2013-05-16 18:10 ` Peter Zijlstra
2013-05-16 20:55 ` Robert Richter
2013-05-16 21:34 ` Borislav Petkov
2013-05-17 9:04 ` Peter Zijlstra
2013-05-17 9:16 ` Borislav Petkov
2013-05-17 9:27 ` Peter Zijlstra
2013-05-17 9:45 ` Borislav Petkov
2013-05-17 10:36 ` Robert Richter
2013-05-17 10:57 ` Peter Zijlstra
2013-05-21 8:56 ` Robert Richter
2013-05-21 11:05 ` Peter Zijlstra [this message]
2013-05-21 13:58 ` Robert Richter
2013-05-21 15:20 ` Jacob Shin
2013-05-28 13:03 ` [tip:perf/core] perf/x86/amd: Rework AMD PMU init code tip-bot for Peter Zijlstra
2013-05-16 21:54 ` Drop WARN on AMD lack of perfctrs Josh Boyer
2013-05-16 22:33 ` Robert Richter
2013-05-16 19:31 ` Gleb Natapov
2013-05-16 20:00 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130521110537.GG26912@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@ghostprotocols.net \
--cc=bp@alien8.de \
--cc=gleb@redhat.com \
--cc=jacob.shin@amd.com \
--cc=jwboyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rric@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome