All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@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 18:53:01 -0700	[thread overview]
Message-ID: <Z9Do_ZSHuuZde4eZ@google.com> (raw)
In-Reply-To: <CAP-5=fUV5yt4c-PrvTFqW6ehuudwkqdO7QuQpvbUBDm6aT6+dQ@mail.gmail.com>

On Mon, Mar 10, 2025 at 04:40:36PM -0700, Ian Rogers wrote:
> On Mon, Mar 10, 2025 at 3:17 PM Namhyung Kim <namhyung@kernel.org> 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>
> > > ---
> > >  tools/perf/python/tracepoint.py | 23 +++++++++++------------
> > >  1 file changed, 11 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/tools/perf/python/tracepoint.py b/tools/perf/python/tracepoint.py
> > > index bba68a6d4515..38b2b6d11f64 100755
> > > --- a/tools/perf/python/tracepoint.py
> > > +++ b/tools/perf/python/tracepoint.py
> > > @@ -5,24 +5,23 @@
> > >
> > >  import perf
> > >
> > > -class tracepoint(perf.evsel):
> > > -    def __init__(self, sys, name):
> > > -        config = perf.tracepoint(sys, name)
> > > -        perf.evsel.__init__(self,
> > > -                            type   = perf.TYPE_TRACEPOINT,
> > > -                            config = config,
> > > -                            freq = 0, sample_period = 1, wakeup_events = 1,
> > > -                            sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_RAW | perf.SAMPLE_TIME)
> > > -
> > >  def main():
> > > -    tp      = tracepoint("sched", "sched_switch")
> > >      cpus    = perf.cpu_map()
> > >      threads = perf.thread_map(-1)
> > > +    evlist = perf.parse_events("sched:sched_switch", cpus, threads)
> > > +    # Disable tracking of mmaps and similar that are unnecessary.
> > > +    for ev in evlist:
> > > +        ev.tracking = False
> > > +    # Configure evsels with default record options.
> > > +    evlist.config()
> >
> > I think the default option uses frequency of 4000 but tracepoints want
> > to use period of 1.  Also I'm not sure if it sets the proper sample type
> > bits namely PERF_SAMPLE_RAW.
> 
> I used trace to ensure they matched. Fwiw, the sample_period for a
> tracepoint is set to 1 in evsel__newtp_idx:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/evsel.c?h=perf-tools-next#n621
> and the evsel__config won't overwrite an already set sample_period:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/evsel.c?h=perf-tools-next#n1341

Ok, it only sets the default value and it will use the attr from
evsel__newtp_idx().  Thanks for checking this.

Thanks,
Namhyung

> >
> >
> > > +    # Simplify the sample_type and read_format of evsels
> > > +    for ev in evlist:
> > > +        ev.sample_type = ev.sample_type & ~perf.SAMPLE_IP
> > > +        ev.read_format = 0
> > >
> > > -    evlist = perf.evlist(cpus, threads)
> > > -    evlist.add(tp)
> > >      evlist.open()
> > >      evlist.mmap()
> > > +    evlist.enable();
> > >
> > >      while True:
> > >          evlist.poll(timeout = -1)
> > > --
> > > 2.48.1.711.g2feabab25a-goog
> > >

  reply	other threads:[~2025-03-12  1:53 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
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 [this message]
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=Z9Do_ZSHuuZde4eZ@google.com \
    --to=namhyung@kernel.org \
    --cc=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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.