linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	dave.hansen@linux.intel.com, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org,
	linux-perf-users <linux-perf-users@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	sandipan.das@amd.com, ananth.narayan@amd.com,
	Kim Phillips <kim.phillips@amd.com>,
	santosh.shukla@amd.com, Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf/amd/ibs: Use interrupt regs ip for stack unwinding
Date: Sun, 1 May 2022 23:07:14 -0700	[thread overview]
Message-ID: <CAM9d7cjksVPHYJEjqckotqzC62dBNW9frsMQaBECngMopU4znw@mail.gmail.com> (raw)
In-Reply-To: <20220429051441.14251-1-ravi.bangoria@amd.com>

Hello,

On Thu, Apr 28, 2022 at 10:15 PM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>
> IbsOpRip is recorded when IBS interrupt is triggered. But there is
> a skid from the time IBS interrupt gets triggered to the time the
> interrupt is presented to the core. Meanwhile processor would have
> moved ahead and thus IbsOpRip will be inconsistent with rsp and rbp
> recorded as part of the interrupt regs. This causes issues while
> unwinding stack using the ORC unwinder as it needs consistent rip,
> rsp and rbp. Fix this by using rip from interrupt regs instead of
> IbsOpRip for stack unwinding.
>
> Fixes: ee9f8fce99640 ("x86/unwind: Add the ORC unwinder")
> Reported-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  arch/x86/events/amd/ibs.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index 9739019d4b67..171941043f53 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
> @@ -304,6 +304,16 @@ static int perf_ibs_init(struct perf_event *event)
>         hwc->config_base = perf_ibs->msr;
>         hwc->config = config;
>
> +       /*
> +        * rip recorded by IbsOpRip will not be consistent with rsp and rbp
> +        * recorded as part of interrupt regs. Thus we need to use rip from
> +        * interrupt regs while unwinding call stack. Setting _EARLY flag
> +        * makes sure we unwind call-stack before perf sample rip is set to
> +        * IbsOpRip.
> +        */
> +       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
> +               event->attr.sample_type |= __PERF_SAMPLE_CALLCHAIN_EARLY;
> +
>         return 0;
>  }
>
> @@ -687,6 +697,14 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
>                 data.raw = &raw;
>         }
>
> +       /*
> +        * rip recorded by IbsOpRip will not be consistent with rsp and rbp
> +        * recorded as part of interrupt regs. Thus we need to use rip from
> +        * interrupt regs while unwinding call stack.
> +        */
> +       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
> +               data.callchain = perf_callchain(event, iregs);
> +
>         throttle = perf_event_overflow(event, &data, &regs);
>  out:
>         if (throttle) {
> --
> 2.27.0
>

  parent reply	other threads:[~2022-05-02  6:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  7:40 [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Dmitry Monakhov
2022-04-12  7:40 ` [PATCH 2/2] x86/unwind/orc: Fix address check size for deref_stack_iret_regs Dmitry Monakhov
2022-04-12 10:01   ` Peter Zijlstra
2022-04-12 10:57     ` Dmitry Monakhov
2022-04-12 10:08 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-16  0:49   ` Josh Poimboeuf
2022-04-29  5:14   ` [PATCH] perf/amd/ibs: Use interrupt regs ip for stack unwinding Ravi Bangoria
2022-04-29 20:28     ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-05-02  6:07     ` Namhyung Kim [this message]
2022-05-04  9:23     ` tip-bot2 for Ravi Bangoria
2022-05-10  9:11     ` tip-bot2 for Ravi Bangoria
2022-04-12 10:11 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-14 15:18   ` Josh Poimboeuf
2022-04-16  0:46 ` Josh Poimboeuf

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=CAM9d7cjksVPHYJEjqckotqzC62dBNW9frsMQaBECngMopU4znw@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dmtrmonakhov@yandex-team.ru \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=kim.phillips@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=sandipan.das@amd.com \
    --cc=santosh.shukla@amd.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).