public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: peterz@infradead.org, mingo@redhat.com,
	linux-kernel@vger.kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
	ak@linux.intel.com, eranian@google.com,
	alexey.v.bayduraev@linux.intel.com, tinghao.zhang@intel.com
Subject: Re: [PATCH V5 2/8] perf/x86: Add PERF_X86_EVENT_NEEDS_BRANCH_STACK flag
Date: Thu, 9 Nov 2023 13:45:49 -0300	[thread overview]
Message-ID: <ZU0MvXe1GF6xejlf@kernel.org> (raw)
In-Reply-To: <a40ff4eb-5507-45b9-9f21-1d153a544e16@linux.intel.com>

Em Thu, Nov 09, 2023 at 11:14:31AM -0500, Liang, Kan escreveu:
> 
> 
> On 2023-11-08 4:31 p.m., Arnaldo Carvalho de Melo wrote:
> > Em Tue, Nov 07, 2023 at 12:11:50PM -0300, Arnaldo Carvalho de Melo escreveu:
> >> Em Mon, Nov 06, 2023 at 04:19:13PM -0500, Liang, Kan escreveu:
> >>> On 2023-11-06 4:12 p.m., Arnaldo Carvalho de Melo wrote:
> >>>> Em Wed, Oct 25, 2023 at 01:16:20PM -0700, kan.liang@linux.intel.com escreveu:
> >>> Ian has already reviewed the tool parts.
> > 
> >>> But I still owe a test case for the feature. I will post a patch later.
> >>> https://lore.kernel.org/lkml/acbb895a-475e-4679-98fc-6b90c05a00af@linux.intel.com/
> > 
> >> I saw Ian's suggestion, and agree with it, we need to pair new features
> >> with regression tests in 'perf test', thanks for working on it!
> > 
> > Kan,
> > 
> > 	I still have to bisect, but can you check if this works for you?
> 
> The branch counters feature requires all the events to belong to a
> group. There is no problem for the normal perf usage which usually
> initializes an evlist even for a single evsel.
> But perf test is special, which may not initialize an evlist. The Sample
> parsing test case is one of the examples. It crashes with the
> !evsel->evlist.
> 
> The below change should fix it. I will post a complete patch shortly.

Thanks for the quick response, if all that is needed are the checks
below, I'll fold it into your original patch:

2ae01908298426e4 perf tools: Add branch counter knob

So that we don't regress, ok?

I'll add a note and the Link tag points to this discussion in case
people want to do historical digs in the future :-)

- Arnaldo
 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 58a9b8c82790..7a6a2d1f96db 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2355,6 +2355,10 @@ static inline bool
> evsel__has_branch_counters(const struct evsel *evsel)
>  {
>         struct evsel *cur, *leader = evsel__leader(evsel);
> 
> +       /* The branch counters feature only supports group */
> +       if (!leader || !evsel->evlist)
> +               return false;
> +
>         evlist__for_each_entry(evsel->evlist, cur) {
>                 if ((leader == evsel__leader(cur)) &&
>                     (cur->core.attr.branch_sample_type &
> PERF_SAMPLE_BRANCH_COUNTERS))
> 
> Thanks,
> Kan
> 
> > 
> > 
> > (gdb) run test -F -v 27
> > Starting program: /root/bin/perf test -F -v 27
> > 
> >  27: Sample parsing                                                  :
> > --- start ---
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x00000000004e4aa6 in evsel.parse_sample ()
> > Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-13.fc38.x86_64 cyrus-sasl-lib-2.1.28-9.fc38.x86_64 elfutils-debuginfod-client-0.189-3.fc38.x86_64 elfutils-libelf-0.189-3.fc38.x86_64 elfutils-libs-0.189-3.fc38.x86_64 glib2-2.76.5-2.fc38.x86_64 glibc-2.37-13.fc38.x86_64 keyutils-libs-1.6.1-6.fc38.x86_64 krb5-libs-1.21-3.fc38.x86_64 libbabeltrace-1.5.11-2.fc38.x86_64 libbrotli-1.0.9-11.fc38.x86_64 libcap-2.48-6.fc38.x86_64 libcom_err-1.46.5-4.fc38.x86_64 libcurl-8.0.1-5.fc38.x86_64 libevent-2.1.12-8.fc38.x86_64 libgcc-13.2.1-4.fc38.x86_64 libidn2-2.3.4-2.fc38.x86_64 libnghttp2-1.52.0-2.fc38.x86_64 libpfm-4.11.0-11.fc38.x86_64 libpsl-0.21.2-2.fc38.x86_64 libselinux-3.5-1.fc38.x86_64 libssh-0.10.5-1.fc38.x86_64 libstdc++-13.2.1-4.fc38.x86_64 libtraceevent-1.7.2-1.fc38.x86_64 libunistring1.0-1.0-1.fc38.x86_64 libunwind-1.6.2-7.fc38.x86_64 libuuid-2.38.1-4.fc38.x86_64 libxcrypt-4.4.36-1.fc38.x86_64 libzstd-1.5.5-1.fc38.x86_64 opencsd-1.3.3-1.fc38.x86_64 openldap-2.6.6-1.fc38.x86_64 openssl-libs-3.0.9-2.fc38.x86_64 perl-libs-5.36.1-497.fc38.x86_64 popt-1.19-2.fc38.x86_64 python3-libs-3.11.6-1.fc38.x86_64 slang-2.3.3-3.fc38.x86_64 zlib-1.2.13-3.fc38.x86_64
> > (gdb) bt
> > #0  0x00000000004e4aa6 in evsel.parse_sample ()
> > #1  0x00000000004b28dc in do_test ()
> > #2  0x00000000004b2acd in test.sample_parsing ()
> > #3  0x0000000000495348 in test_and_print.isra ()
> > #4  0x0000000000495f5d in cmd_test ()
> > #5  0x00000000004c2a29 in run_builtin ()
> > #6  0x000000000041053f in main ()
> > (gdb)
> > 

-- 

- Arnaldo

  reply	other threads:[~2023-11-09 16:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 20:16 [PATCH V5 1/8] perf: Add branch stack counters kan.liang
2023-10-25 20:16 ` [PATCH V5 2/8] perf/x86: Add PERF_X86_EVENT_NEEDS_BRANCH_STACK flag kan.liang
2023-11-06 21:12   ` Arnaldo Carvalho de Melo
2023-11-06 21:19     ` Liang, Kan
2023-11-07 15:11       ` Arnaldo Carvalho de Melo
2023-11-08 21:31         ` Arnaldo Carvalho de Melo
2023-11-09 16:14           ` Liang, Kan
2023-11-09 16:45             ` Arnaldo Carvalho de Melo [this message]
2023-11-09 17:05               ` Liang, Kan
2023-11-09 18:46                 ` Arnaldo Carvalho de Melo
2023-11-09 19:07                   ` Liang, Kan
2023-10-25 20:16 ` [PATCH V5 3/8] perf: Add branch_sample_call_stack kan.liang
2023-10-25 20:16 ` [PATCH V5 4/8] perf/x86/intel: Reorganize attrs and is_visible kan.liang
2023-10-25 20:16 ` [PATCH V5 5/8] perf/x86/intel: Support branch counters logging kan.liang
2023-10-25 20:16 ` [PATCH V5 6/8] tools headers UAPI: Sync include/uapi/linux/perf_event.h header with the kernel kan.liang
2023-10-25 20:16 ` [PATCH V5 7/8] perf header: Support num and width of branch counters kan.liang
2023-10-26  2:10   ` Ian Rogers
2023-10-25 20:16 ` [PATCH V5 8/8] perf tools: Add branch counter knob kan.liang
2023-10-26  2:12   ` Ian Rogers
2023-10-26 18:28     ` Liang, Kan

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=ZU0MvXe1GF6xejlf@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tinghao.zhang@intel.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