linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface
@ 2018-03-01 23:08 kan.liang
  2018-03-01 23:08 ` [PATCH 02/14] perf trace: " kan.liang
                   ` (13 more replies)
  0 siblings, 14 replies; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:08 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf kvm still use the legacy interface.

Apply the new perf_mmap__read_event() interface for perf kvm.
No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/builtin-kvm.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 55d919d..cc2b680 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -743,16 +743,24 @@ static bool verify_vcpu(int vcpu)
 static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 				   u64 *mmap_time)
 {
+	struct perf_evlist *evlist = kvm->evlist;
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	u64 timestamp;
 	s64 n = 0;
 	int err;
 
 	*mmap_time = ULLONG_MAX;
-	while ((event = perf_evlist__mmap_read(kvm->evlist, idx)) != NULL) {
-		err = perf_evlist__parse_sample_timestamp(kvm->evlist, event, &timestamp);
+	md = &evlist->mmap[idx];
+	err = perf_mmap__read_init(md, 0, &start, &end);
+	if (err < 0)
+		return (err == -EAGAIN) ? 0 : -1;
+
+	while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
+		err = perf_evlist__parse_sample_timestamp(evlist, event, &timestamp);
 		if (err) {
-			perf_evlist__mmap_consume(kvm->evlist, idx);
+			perf_mmap__consume(md, 0);
 			pr_err("Failed to parse sample\n");
 			return -1;
 		}
@@ -762,7 +770,7 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 		 * FIXME: Here we can't consume the event, as perf_session__queue_event will
 		 *        point to it, and it'll get possibly overwritten by the kernel.
 		 */
-		perf_evlist__mmap_consume(kvm->evlist, idx);
+		perf_mmap__consume(md, 0);
 
 		if (err) {
 			pr_err("Failed to enqueue sample: %d\n", err);
@@ -779,6 +787,7 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 			break;
 	}
 
+	perf_mmap__read_done(md);
 	return n;
 }
 
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
@ 2018-03-01 23:08 ` kan.liang
  2018-03-02 23:30   ` Jiri Olsa
                     ` (2 more replies)
  2018-03-01 23:09 ` [PATCH 03/14] perf python: Apply " kan.liang
                   ` (12 subsequent siblings)
  13 siblings, 3 replies; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:08 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf trace still use the legacy interface.

Apply the new perf_mmap__read_event() interface for perf trace.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/builtin-trace.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e7f1b18..a46644f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
 		union perf_event *event;
+		struct perf_mmap *md;
+		u64 end, start;
 
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			struct perf_sample sample;
 
 			++trace->nr_events;
@@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
 			trace__handle_event(trace, event, &sample);
 next_event:
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, 0);
 
 			if (interrupted)
 				goto out_disable;
@@ -2496,6 +2502,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 				draining = true;
 			}
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (trace->nr_events == before) {
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 03/14] perf python: Apply new perf_mmap__read_event() interface
  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-01 23:09 ` kan.liang
  2018-03-06  6:47   ` [tip:perf/core] perf python: Switch to " tip-bot for Kan Liang
  2018-03-01 23:09 ` [PATCH 04/14] perf test: Apply new perf_mmap__read_event() interface for bpf kan.liang
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf python still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.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 2918cac..62aed42 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, 0, &start, &end) < 0)
+		goto end;
+
+	event = perf_mmap__read_event(md, 0, &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, 0);
 
 		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;
 }
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 04/14] perf test: Apply new perf_mmap__read_event() interface for bpf
  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-01 23:09 ` [PATCH 03/14] perf python: Apply " kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'bpf' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/bpf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index e8399be..ab4715f 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -176,13 +176,20 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
 		union perf_event *event;
+		struct perf_mmap *md;
+		u64 end, start;
 
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			const u32 type = event->header.type;
 
 			if (type == PERF_RECORD_SAMPLE)
 				count ++;
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (count != expect) {
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 05/14] perf test: Apply new perf_mmap__read_event() interface for code reading
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (2 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 04/14] perf test: Apply new perf_mmap__read_event() interface for bpf kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'object code reading' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/code-reading.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index c7115d3..40bbec9 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -409,15 +409,22 @@ static int process_events(struct machine *machine, struct perf_evlist *evlist,
 			  struct state *state)
 {
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, ret;
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			ret = process_event(machine, evlist, event, state);
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, 0);
 			if (ret < 0)
 				return ret;
 		}
+		perf_mmap__read_done(md);
 	}
 	return 0;
 }
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 06/14] perf test: Apply new perf_mmap__read_event() interface for keep_tracking
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (3 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 05/14] perf test: Apply new perf_mmap__read_event() interface for code reading kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'keep_tracking' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/keep-tracking.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index c465309..98a3682 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -27,18 +27,24 @@
 static int find_comm(struct perf_evlist *evlist, const char *comm)
 {
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, found;
 
 	found = 0;
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			if (event->header.type == PERF_RECORD_COMM &&
 			    (pid_t)event->comm.pid == getpid() &&
 			    (pid_t)event->comm.tid == getpid() &&
 			    strcmp(event->comm.comm, comm) == 0)
 				found += 1;
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, 0);
 		}
+		perf_mmap__read_done(md);
 	}
 	return found;
 }
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 07/14] perf test: Apply new perf_mmap__read_event() interface for mmap-basic
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (4 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 06/14] perf test: Apply new perf_mmap__read_event() interface for keep_tracking kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'mmap-basic' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/mmap-basic.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index c0e971d..13aa59d 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -38,6 +38,8 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 		     expected_nr_events[nsyscalls], i, j;
 	struct perf_evsel *evsels[nsyscalls], *evsel;
 	char sbuf[STRERR_BUFSIZE];
+	struct perf_mmap *md;
+	u64 end, start;
 
 	threads = thread_map__new(-1, getpid(), UINT_MAX);
 	if (threads == NULL) {
@@ -106,7 +108,11 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 			++foo;
 		}
 
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 		struct perf_sample sample;
 
 		if (event->header.type != PERF_RECORD_SAMPLE) {
@@ -129,9 +135,11 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 			goto out_delete_evlist;
 		}
 		nr_events[evsel->idx]++;
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, 0);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	err = 0;
 	evlist__for_each_entry(evlist, evsel) {
 		if (nr_events[evsel->idx] != expected_nr_events[evsel->idx]) {
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 08/14] perf test: Apply new perf_mmap__read_event() interface for tp fields
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (5 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 07/14] perf test: Apply new perf_mmap__read_event() interface for mmap-basic kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'syscalls:sys_enter_openat event fields' still use the
legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/openat-syscall-tp-fields.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 4351926..596f329 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -86,8 +86,14 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 
 		for (i = 0; i < evlist->nr_mmaps; i++) {
 			union perf_event *event;
+			struct perf_mmap *md;
+			u64 end, start;
 
-			while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+			md = &evlist->mmap[i];
+			if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+				continue;
+
+			while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 				const u32 type = event->header.type;
 				int tp_flags;
 				struct perf_sample sample;
@@ -95,7 +101,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 				++nr_events;
 
 				if (type != PERF_RECORD_SAMPLE) {
-					perf_evlist__mmap_consume(evlist, i);
+					perf_mmap__consume(md, 0);
 					continue;
 				}
 
@@ -115,6 +121,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 
 				goto out_ok;
 			}
+			perf_mmap__read_done(md);
 		}
 
 		if (nr_events == before)
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 09/14] perf test: Apply new perf_mmap__read_event() interface for perf-record
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (6 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 08/14] perf test: Apply new perf_mmap__read_event() interface for tp fields kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'perf-record' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/perf-record.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 0afafab..4fdd1d4 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -164,8 +164,14 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
 
 		for (i = 0; i < evlist->nr_mmaps; i++) {
 			union perf_event *event;
+			struct perf_mmap *md;
+			u64 end, start;
 
-			while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+			md = &evlist->mmap[i];
+			if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+				continue;
+
+			while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 				const u32 type = event->header.type;
 				const char *name = perf_event__name(type);
 
@@ -266,8 +272,9 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
 					++errs;
 				}
 
-				perf_evlist__mmap_consume(evlist, i);
+				perf_mmap__consume(md, 0);
 			}
+			perf_mmap__read_done(md);
 		}
 
 		/*
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/14] perf test: Apply new perf_mmap__read_event() interface for time-to-tsc
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (7 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 09/14] perf test: Apply new perf_mmap__read_event() interface for perf-record kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'time-to-tsc' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/arch/x86/tests/perf-time-to-tsc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
index 06abe81..f4306f0 100644
--- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c
+++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
@@ -60,6 +60,8 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	union perf_event *event;
 	u64 test_tsc, comm1_tsc, comm2_tsc;
 	u64 test_time, comm1_time = 0, comm2_time = 0;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	threads = thread_map__new(-1, getpid(), UINT_MAX);
 	CHECK_NOT_NULL__(threads);
@@ -109,7 +111,11 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	perf_evlist__disable(evlist);
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			struct perf_sample sample;
 
 			if (event->header.type != PERF_RECORD_COMM ||
@@ -128,8 +134,9 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 				comm2_time = sample.time;
 			}
 next_event:
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, 0);
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (!comm1_time || !comm2_time)
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/14] perf test: Apply new perf_mmap__read_event() interface for sw-clock
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (8 preceding siblings ...)
  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-01 23:09 ` 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
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'sw-clock' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/sw-clock.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index f6c72f9..206a111 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -39,6 +39,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 	};
 	struct cpu_map *cpus;
 	struct thread_map *threads;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	attr.sample_freq = 500;
 
@@ -93,7 +95,11 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 
 	perf_evlist__disable(evlist);
 
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 		struct perf_sample sample;
 
 		if (event->header.type != PERF_RECORD_SAMPLE)
@@ -108,9 +114,11 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 		total_periods += sample.period;
 		nr_samples++;
 next_event:
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, 0);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	if ((u64) nr_samples == total_periods) {
 		pr_debug("All (%d) samples have period value of 1!\n",
 			 nr_samples);
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/14] perf test: Apply new perf_mmap__read_event() interface for switch-tracking
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (9 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 11/14] perf test: Apply new perf_mmap__read_event() interface for sw-clock kan.liang
@ 2018-03-01 23:09 ` 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
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'switch-tracking' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/switch-tracking.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 33e0029..b01277c 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -258,16 +258,23 @@ static int process_events(struct perf_evlist *evlist,
 	unsigned pos, cnt = 0;
 	LIST_HEAD(events);
 	struct event_node *events_array, *node;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, ret;
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 			cnt += 1;
 			ret = add_event(evlist, &events, event);
-			perf_evlist__mmap_consume(evlist, i);
+			 perf_mmap__consume(md, 0);
 			if (ret < 0)
 				goto out_free_nodes;
 		}
+		perf_mmap__read_done(md);
 	}
 
 	events_array = calloc(cnt, sizeof(struct event_node));
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 13/14] perf test: Apply new perf_mmap__read_event() interface for task-exit
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (10 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 12/14] perf test: Apply new perf_mmap__read_event() interface for switch-tracking kan.liang
@ 2018-03-01 23:09 ` 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:47 ` [tip:perf/core] perf kvm: Switch to new perf_mmap__read_event() interface tip-bot for Kan Liang
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

The perf test 'task-exit' still use the legacy interface.

No functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/task-exit.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 01b62b8..20884bc 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -47,6 +47,8 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	char sbuf[STRERR_BUFSIZE];
 	struct cpu_map *cpus;
 	struct thread_map *threads;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -110,13 +112,19 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	perf_evlist__start_workload(evlist);
 
 retry:
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, 0, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
 		if (event->header.type == PERF_RECORD_EXIT)
 			nr_exit++;
 
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, 0);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	if (!exited || !nr_exit) {
 		perf_evlist__poll(evlist, -1);
 		goto retry;
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 14/14] perf tools: Discard legacy interfaces for mmap read forward
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (11 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 13/14] perf test: Apply new perf_mmap__read_event() interface for task-exit kan.liang
@ 2018-03-01 23:09 ` 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
  13 siblings, 1 reply; 35+ messages in thread
From: kan.liang @ 2018-03-01 23:09 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, namhyung, wangnan0, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

Discards legacy interfaces perf_evlist__mmap_read_forward(),
perf_evlist__mmap_read() and perf_evlist__mmap_consume().

No tools use them.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/util/evlist.c | 25 +------------------------
 tools/perf/util/evlist.h |  4 ----
 tools/perf/util/mmap.c   | 21 +--------------------
 3 files changed, 2 insertions(+), 48 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7b7d535..41a4666 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -702,29 +702,6 @@ static int perf_evlist__resume(struct perf_evlist *evlist)
 	return perf_evlist__set_paused(evlist, false);
 }
 
-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
-{
-	struct perf_mmap *md = &evlist->mmap[idx];
-
-	/*
-	 * Check messup is required for forward overwritable ring buffer:
-	 * memory pointed by md->prev can be overwritten in this case.
-	 * No need for read-write ring buffer: kernel stop outputting when
-	 * it hit md->prev (perf_mmap__consume()).
-	 */
-	return perf_mmap__read_forward(md);
-}
-
-union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
-{
-	return perf_evlist__mmap_read_forward(evlist, idx);
-}
-
-void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
-{
-	perf_mmap__consume(&evlist->mmap[idx], false);
-}
-
 static void perf_evlist__munmap_nofree(struct perf_evlist *evlist)
 {
 	int i;
@@ -761,7 +738,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 		map[i].fd = -1;
 		/*
 		 * When the perf_mmap() call is made we grab one refcount, plus
-		 * one extra to let perf_evlist__mmap_consume() get the last
+		 * one extra to let perf_mmap__consume() get the last
 		 * events after all real references (perf_mmap__get()) are
 		 * dropped.
 		 *
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 336b838..6c41b2f 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -129,10 +129,6 @@ struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
 
 void perf_evlist__toggle_bkw_mmap(struct perf_evlist *evlist, enum bkw_mmap_state state);
 
-union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
-
-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist,
-						 int idx);
 void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
 
 int perf_evlist__open(struct perf_evlist *evlist);
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 91531a7..4f27c46 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -64,25 +64,6 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map,
 }
 
 /*
- * legacy interface for mmap read.
- * Don't use it. Use perf_mmap__read_event().
- */
-union perf_event *perf_mmap__read_forward(struct perf_mmap *map)
-{
-	u64 head;
-
-	/*
-	 * Check if event was unmapped due to a POLLHUP/POLLERR.
-	 */
-	if (!refcount_read(&map->refcnt))
-		return NULL;
-
-	head = perf_mmap__read_head(map);
-
-	return perf_mmap__read(map, &map->prev, head);
-}
-
-/*
  * Read event from ring buffer one by one.
  * Return one event for each call.
  *
@@ -191,7 +172,7 @@ void perf_mmap__munmap(struct perf_mmap *map)
 int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
 {
 	/*
-	 * The last one will be done at perf_evlist__mmap_consume(), so that we
+	 * The last one will be done at perf_mmap__consume(), so that we
 	 * make sure we don't prevent tools from consuming every last event in
 	 * the ring buffer.
 	 *
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  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-06  6:47   ` [tip:perf/core] perf trace: Switch to " tip-bot for Kan Liang
  2 siblings, 1 reply; 35+ messages in thread
From: Jiri Olsa @ 2018-03-02 23:30 UTC (permalink / raw)
  To: kan.liang; +Cc: acme, mingo, linux-kernel, namhyung, wangnan0, ak

On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> The perf trace still use the legacy interface.
> 
> Apply the new perf_mmap__read_event() interface for perf trace.
> 
> No functional change.
> 
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
>  tools/perf/builtin-trace.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index e7f1b18..a46644f 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>  
>  	for (i = 0; i < evlist->nr_mmaps; i++) {
>  		union perf_event *event;
> +		struct perf_mmap *md;
> +		u64 end, start;
>  
> -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
> +		md = &evlist->mmap[i];
> +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
> +			continue;

should we break the loop if this returns -EINVAL?

jirka

> +
> +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
>  			struct perf_sample sample;
>  
>  			++trace->nr_events;
> @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>  
>  			trace__handle_event(trace, event, &sample);
>  next_event:
> -			perf_evlist__mmap_consume(evlist, i);
> +			perf_mmap__consume(md, 0);
>  
>  			if (interrupted)
>  				goto out_disable;
> @@ -2496,6 +2502,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>  				draining = true;
>  			}
>  		}
> +		perf_mmap__read_done(md);
>  	}
>  
>  	if (trace->nr_events == before) {
> -- 
> 2.4.11
> 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  2018-03-01 23:08 ` [PATCH 02/14] perf trace: " kan.liang
  2018-03-02 23:30   ` Jiri Olsa
@ 2018-03-02 23:30   ` Jiri Olsa
  2018-03-05 13:03     ` Arnaldo Carvalho de Melo
  2018-03-06  6:47   ` [tip:perf/core] perf trace: Switch to " tip-bot for Kan Liang
  2 siblings, 1 reply; 35+ messages in thread
From: Jiri Olsa @ 2018-03-02 23:30 UTC (permalink / raw)
  To: kan.liang; +Cc: acme, mingo, linux-kernel, namhyung, wangnan0, ak

On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> The perf trace still use the legacy interface.
> 
> Apply the new perf_mmap__read_event() interface for perf trace.
> 
> No functional change.
> 
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
>  tools/perf/builtin-trace.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index e7f1b18..a46644f 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>  
>  	for (i = 0; i < evlist->nr_mmaps; i++) {
>  		union perf_event *event;
> +		struct perf_mmap *md;
> +		u64 end, start;
>  
> -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
> +		md = &evlist->mmap[i];
> +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
> +			continue;
> +
> +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
>  			struct perf_sample sample;
>  
>  			++trace->nr_events;
> @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>  
>  			trace__handle_event(trace, event, &sample);
>  next_event:
> -			perf_evlist__mmap_consume(evlist, i);
> +			perf_mmap__consume(md, 0);

could you call this with 'false' instead of 0, it's 'bool overwrite'
applies also to the rest of the patchset

thanks,
jirka

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-05 13:03 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: kan.liang, mingo, linux-kernel, namhyung, wangnan0, ak

Em Sat, Mar 03, 2018 at 12:30:22AM +0100, Jiri Olsa escreveu:
> On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
> > From: Kan Liang <kan.liang@linux.intel.com>
> > 
> > The perf trace still use the legacy interface.
> > 
> > Apply the new perf_mmap__read_event() interface for perf trace.
> > 
> > No functional change.
> > 
> > Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> > ---
> >  tools/perf/builtin-trace.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index e7f1b18..a46644f 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> >  
> >  	for (i = 0; i < evlist->nr_mmaps; i++) {
> >  		union perf_event *event;
> > +		struct perf_mmap *md;
> > +		u64 end, start;
> >  
> > -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
> > +		md = &evlist->mmap[i];
> > +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
> > +			continue;
> > +
> > +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
> >  			struct perf_sample sample;
> >  
> >  			++trace->nr_events;
> > @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> >  
> >  			trace__handle_event(trace, event, &sample);
> >  next_event:
> > -			perf_evlist__mmap_consume(evlist, i);
> > +			perf_mmap__consume(md, 0);
> 
> could you call this with 'false' instead of 0, it's 'bool overwrite'
> applies also to the rest of the patchset

I'm doing this, the argument is 'bool', so the value should be false or
true, even '0' being way shorter...

- Arnaldo

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-05 13:46 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: kan.liang, Ingo Molnar, linux-kernel, namhyung, wangnan0, ak

Em Mon, Mar 05, 2018 at 10:03:39AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sat, Mar 03, 2018 at 12:30:22AM +0100, Jiri Olsa escreveu:
> > On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
> > > From: Kan Liang <kan.liang@linux.intel.com>
> > > The perf trace still use the legacy interface.
> > > +++ b/tools/perf/builtin-trace.c
> > > @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> > >  
> > >  	for (i = 0; i < evlist->nr_mmaps; i++) {
> > >  		union perf_event *event;
> > > +		struct perf_mmap *md;
> > > +		u64 end, start;
> > >  
> > > -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
> > > +		md = &evlist->mmap[i];
> > > +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
> > > +			continue;
> > > +
> > > +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
> > >  			struct perf_sample sample;
> > >  
> > >  			++trace->nr_events;
> > > @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> > >  
> > >  			trace__handle_event(trace, event, &sample);
> > >  next_event:
> > > -			perf_evlist__mmap_consume(evlist, i);
> > > +			perf_mmap__consume(md, 0);
> > 
> > could you call this with 'false' instead of 0, it's 'bool overwrite'
> > applies also to the rest of the patchset
> 
> I'm doing this, the argument is 'bool', so the value should be false or
> true, even '0' being way shorter...

While doing that I wonder why is that we can't do it without those
explicit start/end variables in all the call sites and passing
overwrite, start and end as parameters...

Can't we just add 'overwrite, 'start' and 'end' to struct perf_mmap,
then have perf_mmap__read_init() with just 'md' and 'overwrite' as
parameters, initialize md->{start,end} and set md->overwrite to the
'overwrite' parameter in 'perf_mmap__read_init()' and then use just
md as parameters for both perf_mmap__read_event() and
perf_mmap__consume()?

What am I missing to have this much simpler without all this
boilerplate?

Anyway, finishing the s/0/false/g, will leave this for later, but please
comment on it.

- Arnaldo

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  2018-03-02 23:30   ` Jiri Olsa
@ 2018-03-05 14:28     ` Liang, Kan
  0 siblings, 0 replies; 35+ messages in thread
From: Liang, Kan @ 2018-03-05 14:28 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: acme, mingo, linux-kernel, namhyung, wangnan0, ak



On 3/2/2018 6:30 PM, Jiri Olsa wrote:
> On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
>> From: Kan Liang <kan.liang@linux.intel.com>
>>
>> The perf trace still use the legacy interface.
>>
>> Apply the new perf_mmap__read_event() interface for perf trace.
>>
>> No functional change.
>>
>> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>> ---
>>   tools/perf/builtin-trace.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
>> index e7f1b18..a46644f 100644
>> --- a/tools/perf/builtin-trace.c
>> +++ b/tools/perf/builtin-trace.c
>> @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>>   
>>   	for (i = 0; i < evlist->nr_mmaps; i++) {
>>   		union perf_event *event;
>> +		struct perf_mmap *md;
>> +		u64 end, start;
>>   
>> -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
>> +		md = &evlist->mmap[i];
>> +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
>> +			continue;
> 
> should we break the loop if this returns -EINVAL?
>

It only means the ring buffer is broken for current mmaps.
For others, the data should still be good.
I don't think we should drop them by breaking the loop.

Also, the -EINVAL is only valid for overwrite mode. It is impossible to 
return -EINVAL in current code.

Thanks,
Kan

> jirka
> 
>> +
>> +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
>>   			struct perf_sample sample;
>>   
>>   			++trace->nr_events;
>> @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>>   
>>   			trace__handle_event(trace, event, &sample);
>>   next_event:
>> -			perf_evlist__mmap_consume(evlist, i);
>> +			perf_mmap__consume(md, 0);
>>   
>>   			if (interrupted)
>>   				goto out_disable;
>> @@ -2496,6 +2502,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>>   				draining = true;
>>   			}
>>   		}
>> +		perf_mmap__read_done(md);
>>   	}
>>   
>>   	if (trace->nr_events == before) {
>> -- 
>> 2.4.11
>>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Liang, Kan @ 2018-03-05 14:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, linux-kernel, namhyung, wangnan0, ak



On 3/5/2018 8:46 AM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Mar 05, 2018 at 10:03:39AM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Sat, Mar 03, 2018 at 12:30:22AM +0100, Jiri Olsa escreveu:
>>> On Thu, Mar 01, 2018 at 06:08:59PM -0500, kan.liang@linux.intel.com wrote:
>>>> From: Kan Liang <kan.liang@linux.intel.com>
>>>> The perf trace still use the legacy interface.
>>>> +++ b/tools/perf/builtin-trace.c
>>>> @@ -2472,8 +2472,14 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>>>>   
>>>>   	for (i = 0; i < evlist->nr_mmaps; i++) {
>>>>   		union perf_event *event;
>>>> +		struct perf_mmap *md;
>>>> +		u64 end, start;
>>>>   
>>>> -		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
>>>> +		md = &evlist->mmap[i];
>>>> +		if (perf_mmap__read_init(md, 0, &start, &end) < 0)
>>>> +			continue;
>>>> +
>>>> +		while ((event = perf_mmap__read_event(md, 0, &start, end)) != NULL) {
>>>>   			struct perf_sample sample;
>>>>   
>>>>   			++trace->nr_events;
>>>> @@ -2486,7 +2492,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>>>>   
>>>>   			trace__handle_event(trace, event, &sample);
>>>>   next_event:
>>>> -			perf_evlist__mmap_consume(evlist, i);
>>>> +			perf_mmap__consume(md, 0);
>>>
>>> could you call this with 'false' instead of 0, it's 'bool overwrite'
>>> applies also to the rest of the patchset
>>
>> I'm doing this, the argument is 'bool', so the value should be false or
>> true, even '0' being way shorter...
> 
> While doing that I wonder why is that we can't do it without those
> explicit start/end variables in all the call sites and passing
> overwrite, start and end as parameters...
> 
> Can't we just add 'overwrite, 'start' and 'end' to struct perf_mmap,
> then have perf_mmap__read_init() with just 'md' and 'overwrite' as
> parameters, initialize md->{start,end} and set md->overwrite to the
> 'overwrite' parameter in 'perf_mmap__read_init()' and then use just
> md as parameters for both perf_mmap__read_event() and
> perf_mmap__consume()?
>

I don't see any reason we cannot do this.
I will do some test. If it works well, I will submit the follow-up patch 
to clean up the interface.

Thanks,
Kan

> What am I missing to have this much simpler without all this
> boilerplate?
> 
> Anyway, finishing the s/0/false/g, will leave this for later, but please
> comment on it.
> 
> - Arnaldo
> 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 02/14] perf trace: Apply new perf_mmap__read_event() interface
  2018-03-05 14:50         ` Liang, Kan
@ 2018-03-05 15:04           ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 35+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-05 15:04 UTC (permalink / raw)
  To: Liang, Kan; +Cc: Jiri Olsa, Ingo Molnar, linux-kernel, namhyung, wangnan0, ak

Em Mon, Mar 05, 2018 at 09:50:10AM -0500, Liang, Kan escreveu:
> 
> 
> On 3/5/2018 8:46 AM, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Mar 05, 2018 at 10:03:39AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > I'm doing this, the argument is 'bool', so the value should be false or
> > > true, even '0' being way shorter...

> > While doing that I wonder why is that we can't do it without those
> > explicit start/end variables in all the call sites and passing
> > overwrite, start and end as parameters...

> > Can't we just add 'overwrite, 'start' and 'end' to struct perf_mmap,
> > then have perf_mmap__read_init() with just 'md' and 'overwrite' as
> > parameters, initialize md->{start,end} and set md->overwrite to the
> > 'overwrite' parameter in 'perf_mmap__read_init()' and then use just
> > md as parameters for both perf_mmap__read_event() and
> > perf_mmap__consume()?
 
> I don't see any reason we cannot do this.
> I will do some test. If it works well, I will submit the follow-up patch to
> clean up the interface.

Thanks a lot! The less boilerplate we have in such functions, making
them easier to use for new people contributing to tools/perf/, the
better.

- Arnaldo

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf kvm: Switch to new perf_mmap__read_event() interface
  2018-03-01 23:08 [PATCH 01/14] perf kvm: Apply new perf_mmap__read_event() interface kan.liang
                   ` (12 preceding siblings ...)
  2018-03-01 23:09 ` [PATCH 14/14] perf tools: Discard legacy interfaces for mmap read forward kan.liang
@ 2018-03-06  6:47 ` tip-bot for Kan Liang
  13 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, kan.liang, mingo, linux-kernel, hpa, jolsa, namhyung, tglx,
	ak, wangnan0

Commit-ID:  53172f9057e92c9b27f0bbf2a46827d87f12b0d2
Gitweb:     https://git.kernel.org/tip/53172f9057e92c9b27f0bbf2a46827d87f12b0d2
Author:     Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Thu, 1 Mar 2018 18:08:58 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 5 Mar 2018 10:41:36 -0300

perf kvm: Switch to new perf_mmap__read_event() interface

The perf kvm still use the legacy interface.

Switch to the new perf_mmap__read_event() interface for perf kvm.

No functional change.

Committer notes:

Tested before and after running:

  # perf kvm stat record

On a machine with a kvm guest, then used:

  # perf kvm stat report

Before/after results match and look like:

  # perf kvm stat record -a sleep 5
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 2.132 MB perf.data.guest (1828 samples) ]
  # perf kvm stat report

  Analyze events for all VMs, all VCPUs:

             VM-EXIT Samples Samples%  Time% Min Time    Max Time    Avg time

      IO_INSTRUCTION     258   40.06%  0.08%   3.51us    122.54us     14.87us (+- 6.76%)
           MSR_WRITE     178   27.64%  0.01%   0.47us      6.34us      2.18us (+- 4.80%)
       EPT_MISCONFIG     148   22.98%  0.03%   3.76us     65.60us     11.22us (+- 8.14%)
                 HLT      47    7.30% 99.88% 181.69us 249988.06us 102061.36us (+-13.49%)
   PAUSE_INSTRUCTION       5    0.78%  0.00%   0.38us      0.79us      0.47us (+-17.05%)
            MSR_READ       4    0.62%  0.00%   1.14us      3.33us      2.67us (+-19.35%)
  EXTERNAL_INTERRUPT       2    0.31%  0.00%   2.15us      2.17us      2.16us (+- 0.30%)
   PENDING_INTERRUPT       1    0.16%  0.00%   2.56us      2.56us      2.56us (+- 0.00%)
    PREEMPTION_TIMER       1    0.16%  0.00%   3.21us      3.21us      3.21us (+- 0.00%)

  Total Samples:644, Total events handled time:4802790.72us.

  #

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-1-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/builtin-kvm.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 55d919dc5bc6..d2703d3b8366 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -743,16 +743,24 @@ static bool verify_vcpu(int vcpu)
 static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 				   u64 *mmap_time)
 {
+	struct perf_evlist *evlist = kvm->evlist;
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	u64 timestamp;
 	s64 n = 0;
 	int err;
 
 	*mmap_time = ULLONG_MAX;
-	while ((event = perf_evlist__mmap_read(kvm->evlist, idx)) != NULL) {
-		err = perf_evlist__parse_sample_timestamp(kvm->evlist, event, &timestamp);
+	md = &evlist->mmap[idx];
+	err = perf_mmap__read_init(md, false, &start, &end);
+	if (err < 0)
+		return (err == -EAGAIN) ? 0 : -1;
+
+	while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
+		err = perf_evlist__parse_sample_timestamp(evlist, event, &timestamp);
 		if (err) {
-			perf_evlist__mmap_consume(kvm->evlist, idx);
+			perf_mmap__consume(md, false);
 			pr_err("Failed to parse sample\n");
 			return -1;
 		}
@@ -762,7 +770,7 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 		 * FIXME: Here we can't consume the event, as perf_session__queue_event will
 		 *        point to it, and it'll get possibly overwritten by the kernel.
 		 */
-		perf_evlist__mmap_consume(kvm->evlist, idx);
+		perf_mmap__consume(md, false);
 
 		if (err) {
 			pr_err("Failed to enqueue sample: %d\n", err);
@@ -779,6 +787,7 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
 			break;
 	}
 
+	perf_mmap__read_done(md);
 	return n;
 }
 

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf trace: Switch to new perf_mmap__read_event() interface
  2018-03-01 23:08 ` [PATCH 02/14] perf trace: " kan.liang
  2018-03-02 23:30   ` Jiri Olsa
  2018-03-02 23:30   ` Jiri Olsa
@ 2018-03-06  6:47   ` tip-bot for Kan Liang
  2 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, tglx, acme, wangnan0, jolsa, namhyung, ak,
	mingo, kan.liang

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

perf trace: Switch to new perf_mmap__read_event() interface

The 'perf trace' utility still use the legacy interface.

Switch to the new perf_mmap__read_event() interface.

No functional change.

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-2-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/builtin-trace.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e7f1b182fc15..1a93debc1e8d 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2472,8 +2472,14 @@ again:
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
 		union perf_event *event;
+		struct perf_mmap *md;
+		u64 end, start;
 
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			struct perf_sample sample;
 
 			++trace->nr_events;
@@ -2486,7 +2492,7 @@ again:
 
 			trace__handle_event(trace, event, &sample);
 next_event:
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, false);
 
 			if (interrupted)
 				goto out_disable;
@@ -2496,6 +2502,7 @@ next_event:
 				draining = true;
 			}
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (trace->nr_events == before) {

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf python: Switch to new perf_mmap__read_event() interface
  2018-03-01 23:09 ` [PATCH 03/14] perf python: Apply " kan.liang
@ 2018-03-06  6:47   ` tip-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kan.liang, linux-kernel, jolsa, wangnan0, tglx, namhyung, mingo,
	acme, hpa, ak

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;
 }

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for bpf
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: ak, hpa, acme, kan.liang, namhyung, jolsa, wangnan0, mingo,
	linux-kernel, tglx

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

perf test: Switch to new perf_mmap__read_event() interface for bpf

The perf test 'bpf' still use the legacy interface.

No functional change.

Committer notes:

Tested with:

  # perf test bpf
  39: BPF filter                                            :
  39.1: Basic BPF filtering                                 : Ok
  39.2: BPF pinning                                         : Ok
  39.3: BPF prologue generation                             : Ok
  39.4: BPF relocation checker                              : Ok
  #

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-4-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/tests/bpf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index e8399beca62b..09c9c9f9e827 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -176,13 +176,20 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
 		union perf_event *event;
+		struct perf_mmap *md;
+		u64 end, start;
 
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			const u32 type = event->header.type;
 
 			if (type == PERF_RECORD_SAMPLE)
 				count ++;
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (count != expect) {

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for 'code reading' test
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, tglx, linux-kernel, jolsa, wangnan0, hpa, namhyung,
	ak, kan.liang

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

perf test: Switch to new perf_mmap__read_event() interface for 'code reading' test

The perf test 'object code reading' still use the legacy interface.

No functional change.

Committer notes:

Testing:

  # perf test reading
  23: Object code reading: Ok
  #

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-5-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/tests/code-reading.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index c7115d369511..03ed8c77b1bb 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -409,15 +409,22 @@ static int process_events(struct machine *machine, struct perf_evlist *evlist,
 			  struct state *state)
 {
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, ret;
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			ret = process_event(machine, evlist, event, state);
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, false);
 			if (ret < 0)
 				return ret;
 		}
+		perf_mmap__read_done(md);
 	}
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for "keep tracking" test
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, wangnan0, kan.liang, tglx, linux-kernel, namhyung, mingo,
	acme, hpa, ak

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

perf test: Switch to new perf_mmap__read_event() interface for "keep tracking" test

The perf test 'keep tracking' still use the legacy interface.

No functional change.

Committer testing:

  # perf test tracking
  25: Use a dummy software event to keep tracking           : Ok
  #

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-6-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/tests/keep-tracking.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index c46530918938..4590d8fb91ab 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -27,18 +27,24 @@
 static int find_comm(struct perf_evlist *evlist, const char *comm)
 {
 	union perf_event *event;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, found;
 
 	found = 0;
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			if (event->header.type == PERF_RECORD_COMM &&
 			    (pid_t)event->comm.pid == getpid() &&
 			    (pid_t)event->comm.tid == getpid() &&
 			    strcmp(event->comm.comm, comm) == 0)
 				found += 1;
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, false);
 		}
+		perf_mmap__read_done(md);
 	}
 	return found;
 }

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for mmap-basic
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: ak, acme, tglx, namhyung, wangnan0, kan.liang, mingo, hpa, jolsa,
	linux-kernel

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

perf test: Switch to new perf_mmap__read_event() interface for mmap-basic

The perf test 'mmap-basic' still use the legacy interface.

No functional change.

Committer notes:

Testing it:

  # perf test "mmap interface"
   4: Read samples using the mmap interface                 : Ok
  #

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-7-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/tests/mmap-basic.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index c0e971da965c..44c58d69cd87 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -38,6 +38,8 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 		     expected_nr_events[nsyscalls], i, j;
 	struct perf_evsel *evsels[nsyscalls], *evsel;
 	char sbuf[STRERR_BUFSIZE];
+	struct perf_mmap *md;
+	u64 end, start;
 
 	threads = thread_map__new(-1, getpid(), UINT_MAX);
 	if (threads == NULL) {
@@ -106,7 +108,11 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 			++foo;
 		}
 
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, false, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 		struct perf_sample sample;
 
 		if (event->header.type != PERF_RECORD_SAMPLE) {
@@ -129,9 +135,11 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 			goto out_delete_evlist;
 		}
 		nr_events[evsel->idx]++;
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, false);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	err = 0;
 	evlist__for_each_entry(evlist, evsel) {
 		if (nr_events[evsel->idx] != expected_nr_events[evsel->idx]) {

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for tp fields
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, namhyung, linux-kernel, kan.liang, jolsa, ak, tglx, mingo,
	hpa, wangnan0

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

perf test: Switch to new perf_mmap__read_event() interface for tp fields

The perf test 'syscalls:sys_enter_openat event fields' still use the
legacy interface.

No functional change.

Committer notes:

Testing it:

  # perf test sys_enter_openat
  15: syscalls:sys_enter_openat event fields                : Ok
  #

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-8-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/tests/openat-syscall-tp-fields.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 43519267b93b..620b21023f72 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -86,8 +86,14 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 
 		for (i = 0; i < evlist->nr_mmaps; i++) {
 			union perf_event *event;
+			struct perf_mmap *md;
+			u64 end, start;
 
-			while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+			md = &evlist->mmap[i];
+			if (perf_mmap__read_init(md, false, &start, &end) < 0)
+				continue;
+
+			while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 				const u32 type = event->header.type;
 				int tp_flags;
 				struct perf_sample sample;
@@ -95,7 +101,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 				++nr_events;
 
 				if (type != PERF_RECORD_SAMPLE) {
-					perf_evlist__mmap_consume(evlist, i);
+					perf_mmap__consume(md, false);
 					continue;
 				}
 
@@ -115,6 +121,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
 
 				goto out_ok;
 			}
+			perf_mmap__read_done(md);
 		}
 
 		if (nr_events == before)

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for perf-record
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kan.liang, mingo, jolsa, acme, wangnan0, hpa, ak, linux-kernel,
	tglx, namhyung

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

perf test: Switch to new perf_mmap__read_event() interface for perf-record

The perf test 'perf-record' still use the legacy interface.

No functional change.

Committer notes:

Testing it:

  # perf test PERF_RECORD
   8: PERF_RECORD_* events & perf_sample fields             : Ok
  #

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-9-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/tests/perf-record.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 0afafab85238..31f3f70adca6 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -164,8 +164,14 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
 
 		for (i = 0; i < evlist->nr_mmaps; i++) {
 			union perf_event *event;
+			struct perf_mmap *md;
+			u64 end, start;
 
-			while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+			md = &evlist->mmap[i];
+			if (perf_mmap__read_init(md, false, &start, &end) < 0)
+				continue;
+
+			while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 				const u32 type = event->header.type;
 				const char *name = perf_event__name(type);
 
@@ -266,8 +272,9 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
 					++errs;
 				}
 
-				perf_evlist__mmap_consume(evlist, i);
+				perf_mmap__consume(md, false);
 			}
+			perf_mmap__read_done(md);
 		}
 
 		/*

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for time-to-tsc
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: wangnan0, tglx, mingo, kan.liang, hpa, linux-kernel, ak, jolsa,
	acme, namhyung

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

perf test: Switch to new perf_mmap__read_event() interface for time-to-tsc

The perf test 'time-to-tsc' still use the legacy interface.

No functional change.

Commiter notes:

Testing it:

  # perf test tsc
  57: Convert perf time to TSC                              : Ok
  #

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-10-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/arch/x86/tests/perf-time-to-tsc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
index 06abe8108b33..7f82d91ef473 100644
--- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c
+++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
@@ -60,6 +60,8 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	union perf_event *event;
 	u64 test_tsc, comm1_tsc, comm2_tsc;
 	u64 test_time, comm1_time = 0, comm2_time = 0;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	threads = thread_map__new(-1, getpid(), UINT_MAX);
 	CHECK_NOT_NULL__(threads);
@@ -109,7 +111,11 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	perf_evlist__disable(evlist);
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			struct perf_sample sample;
 
 			if (event->header.type != PERF_RECORD_COMM ||
@@ -128,8 +134,9 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 				comm2_time = sample.time;
 			}
 next_event:
-			perf_evlist__mmap_consume(evlist, i);
+			perf_mmap__consume(md, false);
 		}
+		perf_mmap__read_done(md);
 	}
 
 	if (!comm1_time || !comm2_time)

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for sw-clock
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, kan.liang, jolsa, tglx, namhyung, wangnan0,
	ak, hpa, mingo

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

perf test: Switch to new perf_mmap__read_event() interface for sw-clock

The perf test 'sw-clock' still use the legacy interface.

No functional change.

Committer testing:

  # perf test clock
  22: Software clock events period values                   : Ok
  #

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-11-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/tests/sw-clock.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index f6c72f915d48..e6320e267ba5 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -39,6 +39,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 	};
 	struct cpu_map *cpus;
 	struct thread_map *threads;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	attr.sample_freq = 500;
 
@@ -93,7 +95,11 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 
 	perf_evlist__disable(evlist);
 
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, false, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 		struct perf_sample sample;
 
 		if (event->header.type != PERF_RECORD_SAMPLE)
@@ -108,9 +114,11 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 		total_periods += sample.period;
 		nr_samples++;
 next_event:
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, false);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	if ((u64) nr_samples == total_periods) {
 		pr_debug("All (%d) samples have period value of 1!\n",
 			 nr_samples);

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for switch-tracking
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, jolsa, acme, linux-kernel, ak, namhyung, mingo,
	kan.liang, wangnan0

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

perf test: Switch to new perf_mmap__read_event() interface for switch-tracking

The perf test 'switch-tracking' still use the legacy interface.

No functional change.

Committer testing:

  # perf test switch
  32: Track with sched_switch                               : Ok
  #

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-12-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/tests/switch-tracking.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 33e00295a972..10c4dcdc2324 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -258,16 +258,23 @@ static int process_events(struct perf_evlist *evlist,
 	unsigned pos, cnt = 0;
 	LIST_HEAD(events);
 	struct event_node *events_array, *node;
+	struct perf_mmap *md;
+	u64 end, start;
 	int i, ret;
 
 	for (i = 0; i < evlist->nr_mmaps; i++) {
-		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+		md = &evlist->mmap[i];
+		if (perf_mmap__read_init(md, false, &start, &end) < 0)
+			continue;
+
+		while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 			cnt += 1;
 			ret = add_event(evlist, &events, event);
-			perf_evlist__mmap_consume(evlist, i);
+			 perf_mmap__consume(md, false);
 			if (ret < 0)
 				goto out_free_nodes;
 		}
+		perf_mmap__read_done(md);
 	}
 
 	events_array = calloc(cnt, sizeof(struct event_node));

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf test: Switch to new perf_mmap__read_event() interface for task-exit
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, ak, acme, mingo, jolsa, namhyung, kan.liang,
	linux-kernel, wangnan0

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

perf test: Switch to new perf_mmap__read_event() interface for task-exit

The perf test 'task-exit' still use the legacy interface.

No functional change.

Committer notes:

Testing it:

  # perf test exit
  21: Number of exit events of a simple workload            : Ok
  #

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-13-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/tests/task-exit.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 01b62b81751b..02b0888b72a3 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -47,6 +47,8 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	char sbuf[STRERR_BUFSIZE];
 	struct cpu_map *cpus;
 	struct thread_map *threads;
+	struct perf_mmap *md;
+	u64 end, start;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -110,13 +112,19 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
 	perf_evlist__start_workload(evlist);
 
 retry:
-	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
+	md = &evlist->mmap[0];
+	if (perf_mmap__read_init(md, false, &start, &end) < 0)
+		goto out_init;
+
+	while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) {
 		if (event->header.type == PERF_RECORD_EXIT)
 			nr_exit++;
 
-		perf_evlist__mmap_consume(evlist, 0);
+		perf_mmap__consume(md, false);
 	}
+	perf_mmap__read_done(md);
 
+out_init:
 	if (!exited || !nr_exit) {
 		perf_evlist__poll(evlist, -1);
 		goto retry;

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [tip:perf/core] perf mmap: Discard legacy interfaces for mmap read forward
  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-bot for Kan Liang
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Kan Liang @ 2018-03-06  6:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, acme, wangnan0, kan.liang, namhyung, tglx, ak,
	linux-kernel, jolsa, hpa

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

perf mmap: Discard legacy interfaces for mmap read forward

Discards legacy interfaces perf_evlist__mmap_read_forward(),
perf_evlist__mmap_read() and perf_evlist__mmap_consume().

No tools use them.

Signed-off-by: Kan Liang <kan.liang@linux.intel.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-14-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 25 +------------------------
 tools/perf/util/evlist.h |  4 ----
 tools/perf/util/mmap.c   | 21 +--------------------
 3 files changed, 2 insertions(+), 48 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7b7d535396f7..41a4666f1519 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -702,29 +702,6 @@ static int perf_evlist__resume(struct perf_evlist *evlist)
 	return perf_evlist__set_paused(evlist, false);
 }
 
-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
-{
-	struct perf_mmap *md = &evlist->mmap[idx];
-
-	/*
-	 * Check messup is required for forward overwritable ring buffer:
-	 * memory pointed by md->prev can be overwritten in this case.
-	 * No need for read-write ring buffer: kernel stop outputting when
-	 * it hit md->prev (perf_mmap__consume()).
-	 */
-	return perf_mmap__read_forward(md);
-}
-
-union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
-{
-	return perf_evlist__mmap_read_forward(evlist, idx);
-}
-
-void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
-{
-	perf_mmap__consume(&evlist->mmap[idx], false);
-}
-
 static void perf_evlist__munmap_nofree(struct perf_evlist *evlist)
 {
 	int i;
@@ -761,7 +738,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 		map[i].fd = -1;
 		/*
 		 * When the perf_mmap() call is made we grab one refcount, plus
-		 * one extra to let perf_evlist__mmap_consume() get the last
+		 * one extra to let perf_mmap__consume() get the last
 		 * events after all real references (perf_mmap__get()) are
 		 * dropped.
 		 *
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 336b838e6957..6c41b2f78713 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -129,10 +129,6 @@ struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
 
 void perf_evlist__toggle_bkw_mmap(struct perf_evlist *evlist, enum bkw_mmap_state state);
 
-union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
-
-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist,
-						 int idx);
 void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
 
 int perf_evlist__open(struct perf_evlist *evlist);
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 91531a7c8fbf..4f27c464ce0b 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -63,25 +63,6 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map,
 	return event;
 }
 
-/*
- * legacy interface for mmap read.
- * Don't use it. Use perf_mmap__read_event().
- */
-union perf_event *perf_mmap__read_forward(struct perf_mmap *map)
-{
-	u64 head;
-
-	/*
-	 * Check if event was unmapped due to a POLLHUP/POLLERR.
-	 */
-	if (!refcount_read(&map->refcnt))
-		return NULL;
-
-	head = perf_mmap__read_head(map);
-
-	return perf_mmap__read(map, &map->prev, head);
-}
-
 /*
  * Read event from ring buffer one by one.
  * Return one event for each call.
@@ -191,7 +172,7 @@ void perf_mmap__munmap(struct perf_mmap *map)
 int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
 {
 	/*
-	 * The last one will be done at perf_evlist__mmap_consume(), so that we
+	 * The last one will be done at perf_mmap__consume(), so that we
 	 * make sure we don't prevent tools from consuming every last event in
 	 * the ring buffer.
 	 *

^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2018-03-06  6:53 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:perf/core] perf python: Switch to " tip-bot for Kan Liang
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

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).