From: Ralf Baechle <ralf@linux-mips.org>
To: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: David Daney <ddaney@caviumnetworks.com>,
linux-mips@linux-mips.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH v2 4/4] MIPS: perf: Add support for 64-bit perf counters.
Date: Thu, 17 Feb 2011 14:36:00 +0100 [thread overview]
Message-ID: <20110217133559.GA12732@linux-mips.org> (raw)
In-Reply-To: <AANLkTikTV-=A8H=h_F+025VB37tHSmxpsNCGndi_dAFW@mail.gmail.com>
On Thu, Feb 17, 2011 at 06:46:39PM +0800, Deng-Cheng Zhu wrote:
> The reason of the perf-record failure on 32bit platforms is that the 32bit
> counter read function mipsxx_pmu_read_counter() returns wrong 64bit values.
> For example, the counter value 0x12345678 will be returned as
> 0xffffffff12345678. So in mipspmu_event_update(), the delta will be wrong.
> So here's a possible fix for your reference:
>
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -184,19 +184,21 @@ static unsigned int
> mipsxx_pmu_swizzle_perf_idx(unsigned int idx)
> return idx;
> }
>
> +#define U32_MASK 0xffffffff
> +
> static u64 mipsxx_pmu_read_counter(unsigned int idx)
> {
> idx = mipsxx_pmu_swizzle_perf_idx(idx);
>
> switch (idx) {
> case 0:
> - return read_c0_perfcntr0();
> + return read_c0_perfcntr0() & U32_MASK;
> case 1:
> - return read_c0_perfcntr1();
> + return read_c0_perfcntr1() & U32_MASK;
> case 2:
> - return read_c0_perfcntr2();
> + return read_c0_perfcntr2() & U32_MASK;
> case 3:
> - return read_c0_perfcntr3();
> + return read_c0_perfcntr3() & U32_MASK;
read_c0_perfctrl0 etc. are defined in mipsregs.h as 32-bit reads returning
a signed int. That was ok on 32-bit kernels. To support the optional
64-bit counters the code will have to be changed to something like:
static u64 mipsxx_pmu_read_counter(unsigned int idx)
{
idx = mipsxx_pmu_swizzle_perf_idx(idx);
switch (idx) {
case 0:
if (read_c0_perfctrl0() & M_PERFCTL_WIDE)
return read_c0_64_bit_perfcntr0();
else
return read_c0_32_bit_perfcntr0();
case 1:
if (read_c0_perfctrl1() & M_PERFCTL_WIDE)
return read_c0_64_bit_perfcntr1();
else
return read_c0_32_bit_perfcntr1();
...
And read_c0_32_bit_perfcntrX need to zero-extend their return value.
Ralf
next prev parent reply other threads:[~2011-02-17 13:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-21 22:59 [PATCH v2 0/4] MIPS: perf: Add support for 64-bit MIPS hardware counters David Daney
2011-01-21 22:59 ` [PATCH v2 1/4] MIPS: Add accessor macros for 64-bit performance counter registers David Daney
2011-01-21 22:59 ` [PATCH v2 2/4] MIPS: perf: Cleanup formatting in arch/mips/kernel/perf_event.c David Daney
2011-01-21 22:59 ` [PATCH v2 3/4] MIPS: perf: Reorganize contents of perf support files David Daney
2011-01-21 22:59 ` [PATCH v2 4/4] MIPS: perf: Add support for 64-bit perf counters David Daney
2011-01-25 3:42 ` Deng-Cheng Zhu
2011-01-26 0:20 ` David Daney
2011-01-27 6:24 ` Deng-Cheng Zhu
2011-01-27 18:41 ` David Daney
2011-01-28 2:46 ` Deng-Cheng Zhu
2011-02-17 10:46 ` Deng-Cheng Zhu
2011-02-17 13:36 ` Ralf Baechle [this message]
2011-02-17 15:26 ` Deng-Cheng Zhu
2011-02-17 17:26 ` David Daney
2011-02-17 19:23 ` David Daney
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=20110217133559.GA12732@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=ddaney@caviumnetworks.com \
--cc=dengcheng.zhu@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.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