Commit 7728fa0c authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

libperf: Adopt perf_mmap__consume() function from tools/perf



Move perf_mmap__consume() vrom tools/perf to libperf and export it in
the perf/mmap.h header.

Move also the needed helpers perf_mmap__write_tail(),
perf_mmap__read_head() and perf_mmap__empty().

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191007125344.14268-10-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1d40ae4e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <sys/prctl.h>
#include <perf/cpumap.h>
#include <perf/evlist.h>
#include <perf/mmap.h>

#include "debug.h"
#include "parse-events.h"
@@ -139,7 +140,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
				comm2_time = sample.time;
			}
next_event:
			perf_mmap__consume(md);
			perf_mmap__consume(&md->core);
		}
		perf_mmap__read_done(md);
	}
+3 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include <semaphore.h>
#include <signal.h>
#include <math.h>
#include <perf/mmap.h>

static const char *get_filename_for_perf_kvm(void)
{
@@ -766,7 +767,7 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
	while ((event = perf_mmap__read_event(md)) != NULL) {
		err = perf_evlist__parse_sample_timestamp(evlist, event, &timestamp);
		if (err) {
			perf_mmap__consume(md);
			perf_mmap__consume(&md->core);
			pr_err("Failed to parse sample\n");
			return -1;
		}
@@ -776,7 +777,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_mmap__consume(md);
		perf_mmap__consume(&md->core);

		if (err) {
			pr_err("Failed to enqueue sample: %d\n", err);
+2 −1
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@
#include <linux/err.h>

#include <linux/ctype.h>
#include <perf/mmap.h>

static volatile int done;
static volatile int resize;
@@ -883,7 +884,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
		if (ret)
			break;

		perf_mmap__consume(md);
		perf_mmap__consume(&md->core);

		if (top->qe.rotate) {
			pthread_mutex_lock(&top->qe.mutex);
+2 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@
#include <sys/sysmacros.h>

#include <linux/ctype.h>
#include <perf/mmap.h>

#ifndef O_CLOEXEC
# define O_CLOEXEC		02000000
@@ -3810,7 +3811,7 @@ again:
			if (err)
				goto out_disable;

			perf_mmap__consume(md);
			perf_mmap__consume(&md->core);

			if (interrupted)
				goto out_disable;
+3 −2
Original line number Diff line number Diff line
@@ -172,8 +172,9 @@ install_headers:
		$(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \
		$(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \
		$(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \
		$(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644);
		$(call do_install,include/perf/event.h,$(prefix)/include/perf,644);
		$(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); \
		$(call do_install,include/perf/event.h,$(prefix)/include/perf,644); \
		$(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644);

install_pkgconfig: $(LIBPERF_PC)
	$(call QUIET_INSTALL, $(LIBPERF_PC)) \
Loading