From: Song Liu <songliubraving@fb.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>, Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH v2 0/3] perf-stat: share hardware PMCs with BPF
Date: Fri, 19 Mar 2021 16:14:42 +0000 [thread overview]
Message-ID: <EC00E37D-8587-4662-8E30-7AD5F874FA84@fb.com> (raw)
In-Reply-To: <CAM9d7cgoP28V_ONk2AJeu=Y7RQ8vzovzW=pGVYtERe97+ZH0Aw@mail.gmail.com>
> On Mar 19, 2021, at 8:58 AM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Arnaldo,
>
> On Sat, Mar 20, 2021 at 12:35 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
>>
>> Em Fri, Mar 19, 2021 at 09:54:59AM +0900, Namhyung Kim escreveu:
>>> On Fri, Mar 19, 2021 at 9:22 AM Song Liu <songliubraving@fb.com> wrote:
>>>>> On Mar 18, 2021, at 5:09 PM, Arnaldo <arnaldo.melo@gmail.com> wrote:
>>>>> On March 18, 2021 6:14:34 PM GMT-03:00, Jiri Olsa <jolsa@redhat.com> wrote:
>>>>>> On Thu, Mar 18, 2021 at 03:52:51AM +0000, Song Liu wrote:
>>>>>>> perf stat -C 1,3,5 107.063 [sec]
>>>>>>> perf stat -C 1,3,5 --bpf-counters 106.406 [sec]
>>
>>>>>> I can't see why it's actualy faster than normal perf ;-)
>>>>>> would be worth to find out
>>
>>>>> Isn't this all about contended cases?
>>
>>>> Yeah, the normal perf is doing time multiplexing; while --bpf-counters
>>>> doesn't need it.
>>
>>> Yep, so for uncontended cases, normal perf should be the same as the
>>> baseline (faster than the bperf). But for contended cases, the bperf
>>> works faster.
>>
>> The difference should be small enough that for people that use this in a
>> machine where contention happens most of the time, setting a
>> ~/.perfconfig to use it by default should be advantageous, i.e. no need
>> to use --bpf-counters on the command line all the time.
>>
>> So, Namhyung, can I take that as an Acked-by or a Reviewed-by? I'll take
>> a look again now but I want to have this merged on perf/core so that I
>> can work on a new BPF SKEL to use this:
>
> I have a concern for the per cpu target, but it can be done later, so
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=tmp.bpf/bpf_perf_enable
>
> Interesting! Actually I was thinking about the similar too. :)
Hi Namhyung, Jiri, and Arnaldo,
Thanks a lot for your kind review.
Here is updated 3/3, where we use perf-bench instead of stressapptest.
Thanks,
Song
From cc79d161be9c9d24198f7e35b50058a6e15076fd Mon Sep 17 00:00:00 2001
From: Song Liu <songliubraving@fb.com>
Date: Tue, 16 Mar 2021 00:19:53 -0700
Subject: [PATCH v3 3/3] perf-test: add a test for perf-stat --bpf-counters
option
Add a test to compare the output of perf-stat with and without option
--bpf-counters. If the difference is more than 10%, the test is considered
as failed.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
tools/perf/tests/shell/stat_bpf_counters.sh | 31 +++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100755 tools/perf/tests/shell/stat_bpf_counters.sh
diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh
new file mode 100755
index 0000000000000..7aabf177ce8d1
--- /dev/null
+++ b/tools/perf/tests/shell/stat_bpf_counters.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# perf stat --bpf-counters test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+# check whether $2 is within +/- 10% of $1
+compare_number()
+{
+ first_num=$1
+ second_num=$2
+
+ # upper bound is first_num * 110%
+ upper=$(( $first_num + $first_num / 10 ))
+ # lower bound is first_num * 90%
+ lower=$(( $first_num - $first_num / 10 ))
+
+ if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then
+ echo "The difference between $first_num and $second_num are greater than 10%."
+ exit 1
+ fi
+}
+
+# skip if --bpf-counters is not supported
+perf stat --bpf-counters true > /dev/null 2>&1 || exit 2
+
+base_cycles=$(perf stat --no-big-num -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}')
+bpf_cycles=$(perf stat --no-big-num --bpf-counters -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}')
+
+compare_number $base_cycles $bpf_cycles
+exit 0
--
2.30.2
next prev parent reply other threads:[~2021-03-19 16:15 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 21:18 [PATCH v2 0/3] perf-stat: share hardware PMCs with BPF Song Liu
2021-03-16 21:18 ` [PATCH v2 1/3] perf-stat: introduce bperf, " Song Liu
2021-03-18 5:54 ` Namhyung Kim
2021-03-18 7:22 ` Song Liu
2021-03-18 13:49 ` Namhyung Kim
2021-03-18 17:16 ` Song Liu
2021-03-18 21:15 ` Jiri Olsa
2021-03-19 18:41 ` Arnaldo Carvalho de Melo
2021-03-19 18:55 ` Jiri Olsa
2021-03-19 22:06 ` Song Liu
2021-03-23 0:53 ` Song Liu
2021-03-23 12:25 ` Arnaldo Carvalho de Melo
2021-03-23 12:37 ` Arnaldo Carvalho de Melo
2021-03-23 18:27 ` Arnaldo Carvalho de Melo
2021-03-16 21:18 ` [PATCH v2 2/3] perf-stat: measure t0 and ref_time after enable_counters() Song Liu
2021-03-16 21:18 ` [PATCH v2 3/3] perf-test: add a test for perf-stat --bpf-counters option Song Liu
2021-03-18 6:07 ` Namhyung Kim
2021-03-18 7:39 ` Song Liu
2021-03-17 5:29 ` [PATCH v2 0/3] perf-stat: share hardware PMCs with BPF Namhyung Kim
2021-03-17 9:19 ` Jiri Olsa
2021-03-17 13:11 ` Arnaldo Carvalho de Melo
2021-03-18 3:52 ` Song Liu
2021-03-18 4:32 ` Namhyung Kim
2021-03-18 7:03 ` Song Liu
2021-03-18 21:14 ` Jiri Olsa
2021-03-19 0:09 ` Arnaldo
2021-03-19 0:22 ` Song Liu
2021-03-19 0:54 ` Namhyung Kim
2021-03-19 15:35 ` Arnaldo Carvalho de Melo
2021-03-19 15:58 ` Namhyung Kim
2021-03-19 16:14 ` Song Liu [this message]
2021-03-23 21:10 ` Arnaldo Carvalho de Melo
2021-03-23 21:26 ` Song Liu
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=EC00E37D-8587-4662-8E30-7AD5F874FA84@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@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).