From: Sandipan Das <sandipan.das@amd.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
ananth.narayan@amd.com, ravi.bangoria@amd.com
Subject: Re: [PATCH 2/2] perf/x86/amd/lbr: adjust LBR regardless of filtering
Date: Thu, 29 Sep 2022 12:31:13 +0530 [thread overview]
Message-ID: <9c40ef91-b7fc-5ee6-2ab5-446a10f8c00a@amd.com> (raw)
In-Reply-To: <20220928184043.408364-3-eranian@google.com>
On 9/29/2022 12:10 AM, Stephane Eranian wrote:
> In case of fused compare and taken branch instructions, the AMD LBR points to
> the compare instruction instead of the branch. Users of LBR usually expects
> the from address to point to a branch instruction. The kernel has code to
> adjust the from address via get_branch_type_fused(). However this correction
> is only applied when a branch filter is applied. That means that if no
> filter is present, the quality of the data is lower.
>
> Fix the problem by applying the adjustment regardless of the filter setting,
> bringing the AMD LBR to the same level as other LBR implementations.
>
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
> arch/x86/events/amd/lbr.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c
> index 2e1c1573efe7..38a75216c12c 100644
> --- a/arch/x86/events/amd/lbr.c
> +++ b/arch/x86/events/amd/lbr.c
> @@ -99,12 +99,13 @@ static void amd_pmu_lbr_filter(void)
> struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> int br_sel = cpuc->br_sel, offset, type, i, j;
> bool compress = false;
> + bool fused_only = false;
> u64 from, to;
>
> /* If sampling all branches, there is nothing to filter */
> if (((br_sel & X86_BR_ALL) == X86_BR_ALL) &&
> ((br_sel & X86_BR_TYPE_SAVE) != X86_BR_TYPE_SAVE))
> - return;
> + fused_only = true;
>
> for (i = 0; i < cpuc->lbr_stack.nr; i++) {
> from = cpuc->lbr_entries[i].from;
> @@ -116,8 +117,11 @@ static void amd_pmu_lbr_filter(void)
> * fusion where it points to an instruction preceding the
> * actual branch
> */
> - if (offset)
> + if (offset) {
> cpuc->lbr_entries[i].from += offset;
> + if (fused_only)
> + continue;
> + }
>
> /* If type does not correspond, then discard */
> if (type == X86_BR_NONE || (br_sel & type) != type) {
Reviewed-by: Sandipan Das <sandipan.das@amd.com>
next prev parent reply other threads:[~2022-09-29 7:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 18:40 [PATCH 0/2] perf/x86/amd/lbr: fix LBR filtering support Stephane Eranian
2022-09-28 18:40 ` [PATCH 1/2] perf/x86/utils: fix uninitialized var in get_branch_type() Stephane Eranian
2022-09-29 7:00 ` Sandipan Das
2022-09-30 9:31 ` [tip: perf/core] perf/x86/utils: Fix " tip-bot2 for Stephane Eranian
2022-09-28 18:40 ` [PATCH 2/2] perf/x86/amd/lbr: adjust LBR regardless of filtering Stephane Eranian
2022-09-29 7:01 ` Sandipan Das [this message]
2022-09-30 9:31 ` [tip: perf/core] perf/x86/amd/lbr: Adjust " tip-bot2 for Stephane Eranian
2022-09-29 8:14 ` [PATCH 0/2] perf/x86/amd/lbr: fix LBR filtering support Peter Zijlstra
2022-09-29 8:30 ` Sandipan Das
2022-09-29 10:19 ` Peter Zijlstra
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=9c40ef91-b7fc-5ee6-2ab5-446a10f8c00a@amd.com \
--to=sandipan.das@amd.com \
--cc=ananth.narayan@amd.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.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 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.