All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: 雷博涵 <garthlei@pku.edu.cn>
To: Atish Patra <atishp@atishpatra.org>
Cc: linux-riscv@lists.infradead.org
Subject: RISC-V PMU driver issue
Date: Wed, 28 Feb 2024 11:49:20 +0800	[thread overview]
Message-ID: <CC51D53B-846C-4D81-86FC-FBF969D0A0D6@pku.edu.cn> (raw)

Hi all,

I am having problems with the RISC-V PMU driver. The overflow handler of my custom perf event kernel counter seems to read an incorrect value from the event.
It seems that the issue lies in the function `riscv_pmu_event_set_period`, which sets `prev_count` to a new value but does not modify the underlying hardware counter. When `perf_event_read_value` gets called later in the user-defined overflow handler, `riscv_pmu_event_update` will update the `count` field again based on the unmodified hardware counter value and the modified `prev_count` field, which causes an incorrect reading.
I noticed that other PMU drivers, such as the ARM one, write to the underlying counter in their set_period functions, which prevents the problem. However, the RISC-V SBI specification does not have such an API to write to a counter without starting it. Using `local64_read(&hw_evt->period_left) <= 0` directly as the guard condition to place `riscv_pmu_event_set_period(event)` after it seems to work, but I am not sure whether it can cause other issues.

Thank you,
Bohan Lei

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2024-02-28  3:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  3:49 雷博涵 [this message]
2024-03-13  0:02 ` RISC-V PMU driver issue Atish Patra
2024-03-13  4:29   ` 雷博涵
2024-03-18 22:18     ` Atish Patra
2024-04-27  0:07       ` Atish Patra
     [not found]         ` <2451aea.567f.18f3c8baa06.Coremail.garthlei@pku.edu.cn>
     [not found]           ` <CAHBxVyEotFmCfc+Ym-p7f=WAocAXtNA_z4MvOr7Ky8fXxPtVXA@mail.gmail.com>
2024-05-08  3:01             ` Re: " 雷博涵
2024-05-08  6:57               ` Atish Kumar Patra

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=CC51D53B-846C-4D81-86FC-FBF969D0A0D6@pku.edu.cn \
    --to=garthlei@pku.edu.cn \
    --cc=atishp@atishpatra.org \
    --cc=linux-riscv@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.