All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Kan Liang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: kan.liang@linux.intel.com, linux-kernel@vger.kernel.org,
	jolsa@redhat.com, wangnan0@huawei.com, tglx@linutronix.de,
	namhyung@kernel.org, mingo@kernel.org, acme@redhat.com,
	hpa@zytor.com, ak@linux.intel.com
Subject: [tip:perf/core] perf python: Switch to new perf_mmap__read_event() interface
Date: Mon, 5 Mar 2018 22:47:59 -0800	[thread overview]
Message-ID: <tip-35b7cdc6379ea8300161f0f80fe8aad083a1c5d0@git.kernel.org> (raw)
In-Reply-To: <1519945751-37786-3-git-send-email-kan.liang@linux.intel.com>

Commit-ID:  35b7cdc6379ea8300161f0f80fe8aad083a1c5d0
Gitweb:     https://git.kernel.org/tip/35b7cdc6379ea8300161f0f80fe8aad083a1c5d0
Author:     Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Thu, 1 Mar 2018 18:09:00 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 5 Mar 2018 10:47:07 -0300

perf python: Switch to new perf_mmap__read_event() interface

The perf python binding still use the legacy interface.

No functional change.

Committer notes:

Tested before and after with:

  [root@jouet perf]# export PYTHONPATH=/tmp/build/perf/python
  [root@jouet perf]# tools/perf/python/twatch.py
  cpu: 0, pid: 1183, tid: 6293 { type: exit, pid: 1183, ppid: 1183, tid: 6293, ptid: 6293, time: 17886646588257}
  cpu: 2, pid: 13820, tid: 13820 { type: fork, pid: 13820, ppid: 13820, tid: 6306, ptid: 13820, time: 17886869099529}
  cpu: 1, pid: 13820, tid: 6306 { type: comm, pid: 13820, tid: 6306, comm: TaskSchedulerFo }
  ^CTraceback (most recent call last):
    File "tools/perf/python/twatch.py", line 68, in <module>
      main()
    File "tools/perf/python/twatch.py", line 40, in main
      evlist.poll(timeout = -1)
  KeyboardInterrupt
  [root@jouet perf]#

No problems found.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1519945751-37786-3-git-send-email-kan.liang@linux.intel.com
[ Changed bool parameters from 0 to 'false', as per Jiri comment ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/python.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 2918cac7a142..35fb5ef7d290 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -983,13 +983,19 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 	union perf_event *event;
 	int sample_id_all = 1, cpu;
 	static char *kwlist[] = { "cpu", "sample_id_all", NULL };
+	struct perf_mmap *md;
+	u64 end, start;
 	int err;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist,
 					 &cpu, &sample_id_all))
 		return NULL;
 
-	event = perf_evlist__mmap_read(evlist, cpu);
+	md = &evlist->mmap[cpu];
+	if (perf_mmap__read_init(md, false, &start, &end) < 0)
+		goto end;
+
+	event = perf_mmap__read_event(md, false, &start, end);
 	if (event != NULL) {
 		PyObject *pyevent = pyrf_event__new(event);
 		struct pyrf_event *pevent = (struct pyrf_event *)pyevent;
@@ -1007,14 +1013,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 		err = perf_evsel__parse_sample(evsel, event, &pevent->sample);
 
 		/* Consume the even only after we parsed it out. */
-		perf_evlist__mmap_consume(evlist, cpu);
+		perf_mmap__consume(md, false);
 
 		if (err)
 			return PyErr_Format(PyExc_OSError,
 					    "perf: can't parse sample, err=%d", err);
 		return pyevent;
 	}
-
+end:
 	Py_INCREF(Py_None);
 	return Py_None;
 }

  reply	other threads:[~2018-03-06  6:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
2018-03-01 23:08 ` [PATCH 02/14] perf trace: " kan.liang
2018-03-02 23:30   ` Jiri Olsa
2018-03-05 14:28     ` Liang, Kan
2018-03-02 23:30   ` Jiri Olsa
2018-03-05 13:03     ` Arnaldo Carvalho de Melo
2018-03-05 13:46       ` Arnaldo Carvalho de Melo
2018-03-05 14:50         ` Liang, Kan
2018-03-05 15:04           ` Arnaldo Carvalho de Melo
2018-03-06  6:47   ` [tip:perf/core] perf trace: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 03/14] perf python: Apply " kan.liang
2018-03-06  6:47   ` tip-bot for Kan Liang [this message]
2018-03-01 23:09 ` [PATCH 04/14] perf test: Apply new perf_mmap__read_event() interface for bpf kan.liang
2018-03-06  6:48   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 05/14] perf test: Apply new perf_mmap__read_event() interface for code reading kan.liang
2018-03-06  6:48   ` [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for 'code reading' test tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 06/14] perf test: Apply new perf_mmap__read_event() interface for keep_tracking kan.liang
2018-03-06  6:49   ` [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for "keep tracking" test tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 07/14] perf test: Apply new perf_mmap__read_event() interface for mmap-basic kan.liang
2018-03-06  6:49   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 08/14] perf test: Apply new perf_mmap__read_event() interface for tp fields kan.liang
2018-03-06  6:50   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 09/14] perf test: Apply new perf_mmap__read_event() interface for perf-record kan.liang
2018-03-06  6:50   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 10/14] perf test: Apply new perf_mmap__read_event() interface for time-to-tsc kan.liang
2018-03-06  6:51   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 11/14] perf test: Apply new perf_mmap__read_event() interface for sw-clock kan.liang
2018-03-06  6:51   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 12/14] perf test: Apply new perf_mmap__read_event() interface for switch-tracking kan.liang
2018-03-06  6:52   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 13/14] perf test: Apply new perf_mmap__read_event() interface for task-exit kan.liang
2018-03-06  6:52   ` [tip:perf/core] perf test: Switch to " tip-bot for Kan Liang
2018-03-01 23:09 ` [PATCH 14/14] perf tools: Discard legacy interfaces for mmap read forward kan.liang
2018-03-06  6:52   ` [tip:perf/core] perf mmap: " tip-bot for Kan Liang
2018-03-06  6:47 ` [tip:perf/core] perf kvm: Switch to new perf_mmap__read_event() interface tip-bot for Kan Liang

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=tip-35b7cdc6379ea8300161f0f80fe8aad083a1c5d0@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.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.