From: Gautam Menghani <gautam@linux.ibm.com>
To: maddy@linux.ibm.com, atrajeev@linux.ibm.com, npiggin@gmail.com,
mpe@ellerman.id.au, chleroy@kernel.org
Cc: Gautam Menghani <gautam@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] powerpc/perf: Update prev_count of event to get accurate values
Date: Tue, 11 Aug 2026 19:33:09 +0530 [thread overview]
Message-ID: <20260811140313.15397-4-gautam@linux.ibm.com> (raw)
In-Reply-To: <20260811140313.15397-1-gautam@linux.ibm.com>
When vpa_pmu_read() is called twice while a process is running on a cpu,
the "event->hw.prev_count" variable returns a stale value on the 2nd
read which results in a larger value getting added to event->count.
Fix this by updating the event->hw.prev_count every time vpa_pmu_read()
is called.
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
arch/powerpc/perf/vpa-pmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/perf/vpa-pmu.c b/arch/powerpc/perf/vpa-pmu.c
index 334ef7719db9..f5cfa4d5e369 100644
--- a/arch/powerpc/perf/vpa-pmu.c
+++ b/arch/powerpc/perf/vpa-pmu.c
@@ -145,6 +145,7 @@ static void vpa_pmu_read(struct perf_event *event)
final_data = new_data - prev_data;
local64_add(final_data, &event->count);
+ local64_set(&event->hw.prev_count, new_data);
}
static void vpa_pmu_del(struct perf_event *event, int flags)
--
2.54.0
prev parent reply other threads:[~2026-08-11 14:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 14:03 [PATCH 0/3] powerpc/perf: Fix vpa-pmu driver to report correct Gautam Menghani
2026-08-11 14:03 ` [PATCH 1/3] KVM: PPC: Book3S HV: Maintain aggregate context switch values for vCPUs Gautam Menghani
2026-08-11 14:03 ` [PATCH 2/3] powerpc/perf: Use the aggregate context switch values from vcpu struct Gautam Menghani
2026-08-11 14:03 ` Gautam Menghani [this message]
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=20260811140313.15397-4-gautam@linux.ibm.com \
--to=gautam@linux.ibm.com \
--cc=atrajeev@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
/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