linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Yicong Yang <yangyicong@hisilicon.com>,
	James Clark <james.clark@linaro.org>,
	"Dr. David Alan Gilbert" <linux@treblig.org>,
	Levi Yun <yeoreum.yun@arm.com>, Ze Gao <zegao2021@gmail.com>,
	Weilin Wang <weilin.wang@intel.com>, Xu Yang <xu.yang_2@nxp.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Howard Chu <howardchu95@gmail.com>
Subject: Re: [PATCH v2 11/11] perf python tracepoint: Switch to using parse_events
Date: Tue, 11 Mar 2025 12:32:05 -0300	[thread overview]
Message-ID: <Z9BXdbWnX19ua5Mr@x1> (raw)
In-Reply-To: <Z89ZYVgL_bT3ampz@x1>

On Mon, Mar 10, 2025 at 06:28:01PM -0300, Arnaldo Carvalho de Melo wrote:
> On Mon, Mar 10, 2025 at 02:17:59PM -0700, Ian Rogers wrote:
> > On Mon, Mar 10, 2025 at 2:16 PM Arnaldo Carvalho de Melo
> > <acme@kernel.org> wrote:
> > >
> > > On Mon, Mar 10, 2025 at 06:15:42PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > On Fri, Feb 28, 2025 at 02:23:08PM -0800, Ian Rogers wrote:
> > > > > Rather than manually configuring an evsel, switch to using
> > > > > parse_events for greater commonality with the rest of the perf code.
> > > > >
> > > > > Reviewed-by: Howard Chu <howardchu95@gmail.com>
> > > > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > >
> > > > Now will all in place I'm trying to test it and I am getting some
> > > > strange results:
> > > >
> > > > root@number:/home/acme/git/perf-tools-next# tools/perf/python/tracepoint.py
> > > > <SNIP lots of seemingly ok lines>
> > > > time 78318710956557 prev_comm=sudo prev_pid=3133818 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/14 next_pid=0 next_prio=120
> > > > time 78318720082300 prev_comm=swapper/16 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=kworker/u112:8 next_pid=1752774 next_prio=120
> > > > time 78318706232435 prev_comm=kworker/u112:17 prev_pid=1551246 prev_prio=120 prev_state=0x80 ==> next_comm=swapper/21 next_pid=0 next_prio=120
> > > > time 78318708202121 prev_comm=sudo prev_pid=3133818 prev_prio=120 prev_state=0x2 ==> next_comm=swapper/25 next_pid=0 next_prio=120
> > > > time 78318748346989 prev_comm=swapper/26 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=gnome-terminal- next_pid=3551 next_prio=120
> > > > Traceback (most recent call last):
> > > >   File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 47, in <module>
> > > >     main()
> > > >   File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 42, in main
> > > >     event.next_comm,
> > > >     ^^^^^^^^^^^^^^^
> > > > AttributeError: 'perf.sample_event' object has no attribute 'next_comm'
> > > > root@number:/home/acme/git/perf-tools-next#
> > > >
> > > > But it shouldn't get there as there is this check:
> > > >
> > > >             if not isinstance(event, perf.sample_event):
> > > >                 continue
> > > >
> > > >
> > > > :-\
> > > >
> > > > Trying to debug that...
> > >
> > > And it doesn't seem related to your series, I checked and v6.13 has the
> > > same problem, I nuked the build dir, etc.
> > 
> > Right. I'd seen the same issue.
> 
> time 79411977132102 prev_comm=sudo prev_pid=3133818 prev_prio=120 prev_state=0x2 ==> next_comm=swapper/12 next_pid=0 next_prio=120
> { type: sample }
> time 79411977200343 prev_comm=kworker/u112:17 prev_pid=1551246 prev_prio=120 prev_state=0x80 ==> next_comm=swapper/16 next_pid=0 next_prio=120
> { type: sample }
> time 79411964535268 prev_comm=kworker/u112:14 prev_pid=810939 prev_prio=120 prev_state=0x80 ==> next_comm=swapper/17 next_pid=0 next_prio=120
> { type: sample }
> time 79411964746511 prev_comm=swapper/18 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=kworker/u112:12 next_pid=2109251 next_prio=120
> { type: sample }
> Traceback (most recent call last):
>   File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 48, in <module>
>     main()
>   File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 43, in main
>     event.next_comm,
>     ^^^^^^^^^^^^^^^
> AttributeError: 'perf.sample_event' object has no attribute 'next_comm'
> root@number:/home/acme/git/perf-tools-next#
> 
> And it says it is a sample... 
> 
> Well, ran out of time, will try later or early tomorrow, will also try
> to review the syscalltbl series and Howard's off cpu profiling.

Its some sort of corruption, I added printing the sample_* fields and
then up to the field before next_comm:

time 2462907120158 prev_comm=swapper/8 prev_pid=0 prev_prio=120 prev_state=0x0 ==>
next_comm=gnome-terminal- next_pid=3646 next_prio=120
ip 0 pid=0 tid=0 cpu=12
time 2462916970223 prev_comm=swapper/12 prev_pid=0 prev_prio=120 prev_state=0x0 ==>
next_comm=gnome-terminal- next_pid=3646 next_prio=120
ip 0 pid=0 tid=0 cpu=14
time 2462902120635 prev_comm= prev_pid=1919907691 prev_prio=796026219 prev_state=0x323a32313175 ==>
Traceback (most recent call last):
  File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 51, in <module>
    main()
  File "/home/acme/git/perf-tools-next/tools/perf/python/tracepoint.py", line 46, in main
    event.next_comm,
    ^^^^^^^^^^^^^^^
AttributeError: 'perf.sample_event' object has no attribute 'next_comm'
root@number:/home/acme/git/perf-tools-next# 

See the empty prev_comm, bogus pref_pid, ditto for prev_state and
pref_prio and then it simple doesn't have that next_comm...

Also I noticed that in tracepoint_field() (tools/perf/util/python.c) we
can get the string tracepoint fields as a bytearray or as a string,
ahere:

                if (field->flags & TEP_FIELD_IS_STRING &&
                    is_printable_array(data + offset, len)) {
                        ret = PyUnicode_FromString((char *)data + offset);
                } else {
                        ret = PyByteArray_FromStringAndSize((const char *) data + offset, len);
                        field->flags &= ~TEP_FIELD_IS_STRING;
                }


For some reason in sessions where bytearrays are returned, and all comes
as bytearrays, the problem is not noticed.

But when it comes as a string it breaks after a short time, /me
scratches head...

- Arnaldo

  reply	other threads:[~2025-03-11 15:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 22:22 [PATCH v2 00/11] Python improvements for a real use of parse_events Ian Rogers
2025-02-28 22:22 ` [PATCH v2 01/11] perf debug: Avoid stack overflow in recursive error message Ian Rogers
2025-03-10 20:22   ` Arnaldo Carvalho de Melo
2025-03-10 20:22     ` Arnaldo Carvalho de Melo
2025-02-28 22:22 ` [PATCH v2 02/11] perf evlist: Add success path to evlist__create_syswide_maps Ian Rogers
2025-03-10 20:31   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 03/11] perf evsel: tp_format accessing improvements Ian Rogers
2025-03-10 20:43   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 04/11] perf python: Add evlist enable and disable methods Ian Rogers
2025-03-10 20:45   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 05/11] perf python: Add member access to a number of evsel variables Ian Rogers
2025-03-10 20:45   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 06/11] perf python: Add optional cpus and threads arguments to parse_events Ian Rogers
2025-03-10 20:46   ` Arnaldo Carvalho de Melo
2025-03-10 22:12   ` Namhyung Kim
2025-03-11  0:28     ` Ian Rogers
2025-03-12  1:51       ` Namhyung Kim
2025-02-28 22:23 ` [PATCH v2 07/11] perf python: Update ungrouped evsel leader in clone Ian Rogers
2025-03-10 20:53   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 08/11] perf python: Avoid duplicated code in get_tracepoint_field Ian Rogers
2025-03-10 20:55   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 09/11] perf python: Add evlist all_cpus accessor Ian Rogers
2025-03-10 20:56   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 10/11] perf python: Add evlist.config to set up record options Ian Rogers
2025-03-10 20:59   ` Arnaldo Carvalho de Melo
2025-02-28 22:23 ` [PATCH v2 11/11] perf python tracepoint: Switch to using parse_events Ian Rogers
2025-03-10 21:15   ` Arnaldo Carvalho de Melo
2025-03-10 21:16     ` Arnaldo Carvalho de Melo
2025-03-10 21:17       ` Ian Rogers
2025-03-10 21:28         ` Arnaldo Carvalho de Melo
2025-03-11 15:32           ` Arnaldo Carvalho de Melo [this message]
2025-03-11 17:06             ` Arnaldo Carvalho de Melo
2025-03-11 18:49               ` Arnaldo Carvalho de Melo
2025-03-11 21:52                 ` Arnaldo Carvalho de Melo
2025-03-12  1:54                   ` Namhyung Kim
2025-03-10 22:17   ` Namhyung Kim
2025-03-10 23:40     ` Ian Rogers
2025-03-12  1:53       ` Namhyung Kim
2025-03-07  2:07 ` [PATCH v2 00/11] Python improvements for a real use of parse_events Howard Chu
2025-03-12 19:53 ` Namhyung Kim

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=Z9BXdbWnX19ua5Mr@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=howardchu95@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=weilin.wang@intel.com \
    --cc=xu.yang_2@nxp.com \
    --cc=yangyicong@hisilicon.com \
    --cc=yeoreum.yun@arm.com \
    --cc=zegao2021@gmail.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;
as well as URLs for NNTP newsgroup(s).