From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf test: Fix LBR test by adding indirect calls
Date: Mon, 4 Nov 2024 15:34:38 -0800 [thread overview]
Message-ID: <ZylaDu6NjJIq6rUf@google.com> (raw)
In-Reply-To: <CAP-5=fUg-DFKM4SQa7P2fWRd62y7kDiP+qP2kP-TiZMy2EX7mQ@mail.gmail.com>
On Sat, Nov 02, 2024 at 09:58:03PM -0700, Ian Rogers wrote:
> On Sat, Nov 2, 2024 at 5:24 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > I've noticed sometimes perf record LBR tests failed on indirect call
> > test because it has empty branch stacks more than expected.
> >
> > The test workload (thloop) spawns a thread and calls a loop function for
> > 1 second both from the main thread and the new thread. However neither
> > of them has indirect calls in the body so it ended up with empty branch
> > stacks.
> >
> > LBR any indirect call test
> > [ perf record: Woken up 21 times to write data ]
> > [ perf record: Captured and wrote 5.607 MB /tmp/__perf_test.perf.data.pujKd (7924 samples) ]
> > LBR any indirect call test: 7924 samples
> > LBR any indirect call test [Failed empty br stack ratio exceed 2%: 3%]
> >
> > Refactor the test workload to call the test_loop() both directly and
> > indirectly. Now expectation of indirect call is 50% but let's add some
> > margin for startup and finish routines.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/tests/shell/record_lbr.sh | 2 +-
> > tools/perf/tests/workloads/thloop.c | 9 ++++++---
> > 2 files changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
> > index 8d750ee631f877fd..7a23b2095be8acba 100755
> > --- a/tools/perf/tests/shell/record_lbr.sh
> > +++ b/tools/perf/tests/shell/record_lbr.sh
> > @@ -121,7 +121,7 @@ lbr_test "-j any_ret" "any ret" 2
> > lbr_test "-j ind_call" "any indirect call" 2
> > lbr_test "-j ind_jmp" "any indirect jump" 100
> > lbr_test "-j call" "direct calls" 2
> > -lbr_test "-j ind_call,u" "any indirect user call" 100
> > +lbr_test "-j ind_call,u" "any indirect user call" 52
> > lbr_test "-a -b" "system wide any branch" 2
> > lbr_test "-a -j any_call" "system wide any call" 2
> >
> > diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c
> > index 457b29f91c3ee277..fa5547939882cf6c 100644
> > --- a/tools/perf/tests/workloads/thloop.c
> > +++ b/tools/perf/tests/workloads/thloop.c
> > @@ -18,14 +18,16 @@ static void sighandler(int sig __maybe_unused)
> >
> > noinline void test_loop(void)
> > {
> > - while (!done);
> > + for (volatile int i = 0; i < 10000; i++)
>
> I don't think the volatile here will stop a sufficiently eager
> optimizing compiler. I think it may need to be static as well.
Ok, probably we can disbale optimizations in this code like others
in the test workloads.
Thanks for your review!
Namhyung
prev parent reply other threads:[~2024-11-04 23:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 0:24 [PATCH] perf test: Fix LBR test by adding indirect calls Namhyung Kim
2024-11-03 4:58 ` Ian Rogers
2024-11-04 23:34 ` Namhyung Kim [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=ZylaDu6NjJIq6rUf@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@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 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).