From: Samuel Holland <samuel.holland@sifive.com>
To: Shifrin Dmitry <dmitry.shifrin@syntacore.com>,
linux-riscv@lists.infradead.org
Cc: atishp@atishpatra.org, anup@brainfault.org, will@kernel.org,
mark.rutland@arm.com, paul.walmsley@sifive.com,
palmer@dabbelt.com, aou@eecs.berkeley.edu,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, alexghiti@rivosinc.com
Subject: Re: [PATCH] perf: riscv: Fix selecting counters in legacy mode
Date: Wed, 31 Jul 2024 02:37:40 -0500 [thread overview]
Message-ID: <0fa3cf3d-48f6-405b-8b66-8935a629089e@sifive.com> (raw)
In-Reply-To: <20240729125858.630653-1-dmitry.shifrin@syntacore.com>
Hi Dmitry,
On 2024-07-29 7:58 AM, Shifrin Dmitry wrote:
> It is required to check event type before checking event config.
> Events with the different types can have the same config.
> This check is missed for legacy mode code
>
> For such perf usage:
> sysctl -w kernel.perf_user_access=2
> perf stat -e cycles,L1-dcache-loads --
> driver will try to force both events to CYCLE counter.
>
> This commit implements event type check before forcing
> events on the special counters.
It looks like pmu_sbi_event_mapped() and pmu_sbi_event_mapped() have a similar
bug where they do not check event->attr.type.
Regards,
Samuel
>
> Signed-off-by: Shifrin Dmitry <dmitry.shifrin@syntacore.com>
> ---
> drivers/perf/riscv_pmu_sbi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index 36d128ff166f..bf14ab282e11 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -416,7 +416,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
> * but not in the user access mode as we want to use the other counters
> * that support sampling/filtering.
> */
> - if (hwc->flags & PERF_EVENT_FLAG_LEGACY) {
> + if ((hwc->flags & PERF_EVENT_FLAG_LEGACY) && (event->attr.type == PERF_TYPE_HARDWARE)) {
> if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
> cflags |= SBI_PMU_CFG_FLAG_SKIP_MATCH;
> cmask = 1;
next prev parent reply other threads:[~2024-07-31 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 12:58 Shifrin Dmitry
2024-07-31 7:37 ` Samuel Holland [this message]
2024-08-01 8:09 ` Dmitry Shifrin
2024-08-01 16:40 ` patchwork-bot+linux-riscv
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=0fa3cf3d-48f6-405b-8b66-8935a629089e@sifive.com \
--to=samuel.holland@sifive.com \
--cc=alexghiti@rivosinc.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=dmitry.shifrin@syntacore.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=will@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
all inboxes | Powered by JetHome®