lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9DotccYb6WuhKJY@google.com>
Date: Tue, 11 Mar 2025 18:51:49 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	Yicong Yang <yangyicong@...ilicon.com>,
	James Clark <james.clark@...aro.org>,
	"Dr. David Alan Gilbert" <linux@...blig.org>,
	Levi Yun <yeoreum.yun@....com>, Ze Gao <zegao2021@...il.com>,
	Weilin Wang <weilin.wang@...el.com>, Xu Yang <xu.yang_2@....com>,
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
	Howard Chu <howardchu95@...il.com>
Subject: Re: [PATCH v2 06/11] perf python: Add optional cpus and threads
 arguments to parse_events

Hi Ian,

On Mon, Mar 10, 2025 at 05:28:48PM -0700, Ian Rogers wrote:
> On Mon, Mar 10, 2025 at 3:12 PM Namhyung Kim <namhyung@...nel.org> wrote:
> >
> > On Fri, Feb 28, 2025 at 02:23:03PM -0800, Ian Rogers wrote:
> > > Used for the evlist initialization.
> > >
> > > Reviewed-by: Howard Chu <howardchu95@...il.com>
> > > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > > ---
> > >  tools/perf/util/python.c | 10 ++++++++--
> > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> > > index b600b6379b4e..4a3015e7dc83 100644
> > > --- a/tools/perf/util/python.c
> > > +++ b/tools/perf/util/python.c
> > > @@ -1339,12 +1339,18 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
> > >       struct evlist evlist = {};
> > >       struct parse_events_error err;
> > >       PyObject *result;
> > > +     PyObject *pcpus = NULL, *pthreads = NULL;
> > > +     struct perf_cpu_map *cpus;
> > > +     struct perf_thread_map *threads;
> > >
> > > -     if (!PyArg_ParseTuple(args, "s", &input))
> > > +     if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads))
> > >               return NULL;
> > >
> > > +     threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NULL;
> > > +     cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL;
> >
> > I wonder if it needs any type checks before accessing them.
> 
> Agreed. We don't do it yet elsewhere:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/python.c?h=perf-tools-next#n769
> although there keywords potentially avoid ambiguity. Given this I
> think improving the typing is follow up work.

Sounds good.

Thanks,
Namhyung

> >
> > > +
> > >       parse_events_error__init(&err);
> > > -     evlist__init(&evlist, NULL, NULL);
> > > +     evlist__init(&evlist, cpus, threads);
> > >       if (parse_events(&evlist, input, &err)) {
> > >               parse_events_error__print(&err, input);
> > >               PyErr_SetFromErrno(PyExc_OSError);
> > > --
> > > 2.48.1.711.g2feabab25a-goog
> > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ