Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1237913 > unrolled thread

[RFC/PATCH 00/38] perf tools: Speed-up perf report by using multi thread (v5)

Started byNamhyung Kim <namhyung@kernel.org>
First post2015-10-02 07:30 +0200
Last post2015-10-12 16:40 +0200
Articles 17 on this page of 57 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [RFC/PATCH 00/38] perf tools: Speed-up perf report by using multi thread (v5) Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 20:50 +0200
    [RFC/PATCH 27/38] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 06/38] perf tools: Extend perf_evlist__mmap_ex() to use track mmap Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 18/38] perf tools: Introduce thread__find_addr_location_by_time() and friends Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 18/38] perf tools: Introduce  thread__find_addr_location_by_time() and friends Jiri Olsa <jolsa@redhat.com> - 2015-10-12 15:40 +0200
    [RFC/PATCH 21/38] perf tools: Save timestamp of a map creation Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 15/38] perf tools: Introduce machine__find*_thread_by_time() Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 15/38] perf tools: Introduce  machine__find*_thread_by_time() Jiri Olsa <jolsa@redhat.com> - 2015-10-08 14:30 +0200
        Re: [RFC/PATCH 15/38] perf tools: Introduce  machine__find*_thread_by_time() Namhyung Kim <namhyung@kernel.org> - 2015-10-09 08:10 +0200
    [RFC/PATCH 01/38] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 01/38] perf tools: Use a software dummy event to  track task/mmap events Jiri Olsa <jolsa@redhat.com> - 2015-10-05 15:00 +0200
        Re: [RFC/PATCH 01/38] perf tools: Use a software dummy event to  track task/mmap events Namhyung Kim <namhyung@kernel.org> - 2015-10-06 10:40 +0200
    [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 13/38] perf tools: Use thread__comm_by_time() when adding hist entries Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 14/38] perf tools: Convert dead thread list into rbtree Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 22/38] perf tools: Introduce map_groups__{insert,find}_by_time() Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 26/38] perf session: Pass struct events stats to event processing functions Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 09/38] perf record: Add --index option for building index table Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 09/38] perf record: Add --index option for building  index table Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 21:00 +0200
      Re: [RFC/PATCH 09/38] perf record: Add --index option for building  index table Jiri Olsa <jolsa@redhat.com> - 2015-10-05 15:50 +0200
        Re: [RFC/PATCH 09/38] perf record: Add --index option for building  index table Namhyung Kim <namhyung@kernel.org> - 2015-10-07 10:30 +0200
          Re: [RFC/PATCH 09/38] perf record: Add --index option for building  index table Jiri Olsa <jolsa@redhat.com> - 2015-10-07 14:20 +0200
    [RFC/PATCH 23/38] perf tools: Use map_groups__find_addr_by_time() Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 24/38] perf tools: Add testcase for managing maps with time Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 11/38] perf tools: Introduce thread__comm(_str)_by_time() helpers Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
    [RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:30 +0200
      Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a  leader thread Jiri Olsa <jolsa@redhat.com> - 2015-10-08 15:00 +0200
        Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a  leader thread Namhyung Kim <namhyung@kernel.org> - 2015-10-09 09:10 +0200
          Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a  leader thread Jiri Olsa <jolsa@redhat.com> - 2015-10-12 14:50 +0200
      Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a  leader thread Jiri Olsa <jolsa@redhat.com> - 2015-10-08 15:00 +0200
        Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a  leader thread Namhyung Kim <namhyung@kernel.org> - 2015-10-09 08:30 +0200
    [RFC/PATCH 08/38] perf tools: Handle indexed data file properly Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
    [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
      Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 20:50 +0200
        Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Namhyung Kim <namhyung@kernel.org> - 2015-10-06 10:40 +0200
      Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Jiri Olsa <jolsa@redhat.com> - 2015-10-08 12:20 +0200
        Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Namhyung Kim <namhyung@kernel.org> - 2015-10-09 08:10 +0200
          Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Jiri Olsa <jolsa@redhat.com> - 2015-10-12 14:50 +0200
    [RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
    [RFC/PATCH 10/38] perf report: Skip dummy tracking event Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
    [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
      Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 20:50 +0200
        Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Adrian Hunter <adrian.hunter@intel.com> - 2015-10-05 13:40 +0200
          Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-06 11:10 +0200
            Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Adrian Hunter <adrian.hunter@intel.com> - 2015-10-06 11:30 +0200
              Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-07 11:10 +0200
                Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Adrian Hunter <adrian.hunter@intel.com> - 2015-10-08 18:10 +0200
                  Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-09 10:00 +0200
        Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-06 11:00 +0200
      Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Jiri Olsa <jolsa@redhat.com> - 2015-10-05 15:20 +0200
        Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Namhyung Kim <namhyung@kernel.org> - 2015-10-06 10:50 +0200
      Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct  perf_evlist Jiri Olsa <jolsa@redhat.com> - 2015-10-08 12:20 +0200
    [RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event Namhyung Kim <namhyung@kernel.org> - 2015-10-02 07:40 +0200
    Re: [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to  perf.h Jiri Olsa <jolsa@redhat.com> - 2015-10-12 16:40 +0200

Page 3 of 3 — ← Prev page 1 2 [3]


#1244660 — Re: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask

FromJiri Olsa <jolsa@redhat.com>
Date2015-10-12 14:50 +0200
SubjectRe: [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask
Message-ID<qiKIb-7EQ-31@gated-at.bofh.it>
In reply to#1243048
On Fri, Oct 09, 2015 at 03:03:33PM +0900, Namhyung Kim wrote:
> Hi Jiri,
> 
> On Thu, Oct 08, 2015 at 12:17:11PM +0200, Jiri Olsa wrote:
> > On Fri, Oct 02, 2015 at 02:18:43PM +0900, Namhyung Kim wrote:
> > > It is more convenient saving mmap length rather than (bit) mask.  With
> > > this patch, we can eliminate dependency to perf_evlist other than
> > > getting mmap_desc for dealing with mmaps.  The mask and length can be
> > > converted using perf_evlist__mmap_mask/len().
> > > 
> > > Cc: Jiri Olsa <jolsa@redhat.com>
> > > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > 
> > after this patch I'm hitting:
> > 
> > [jolsa@krava perf]$ ./perf record  kill
> > kill: not enough arguments
> > perf: util/evlist.c:1003: perf_evlist__mmap_len: Assertion `!((mask & page_size) != 0)' failed.
> > Aborted (core dumped)
> > [jolsa@krava perf]$ 
> 
> This is strange..  I think I fixed it already.  And the expression in
> the assertion is different than the code in the patch:
> 
>   static size_t perf_evlist__mmap_len(size_t mask)
>   {
>          BUG_ON(((mask + 1) % page_size) != 0);
>   
>          return mask + 1 + page_size;
>   }
> 
> Could you please double check?

yep, that one still works.. I probably forked some older version
of your perf/threaded-v5.. the current one has it fixed already

will check the new one

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237937 — [RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-02 07:40 +0200
Subject[RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature
Message-ID<qf1ex-2v1-5@gated-at.bofh.it>
In reply to#1237913
The HEADER_DATA_INDEX feature is to record index table for sample data
so that they can be processed by multiple thread concurrently.  Each
item is a struct perf_file_section which consists of an offset and size.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-record.c |  2 ++
 tools/perf/util/header.c    | 64 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h    |  3 +++
 3 files changed, 69 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 90b1237d2525..623984c81478 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -451,6 +451,8 @@ static void record__init_features(struct record *rec)
 
 	if (!rec->opts.full_auxtrace)
 		perf_header__clear_feat(&session->header, HEADER_AUXTRACE);
+
+	perf_header__clear_feat(&session->header, HEADER_DATA_INDEX);
 }
 
 static volatile int workload_exec_errno;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 43838003c1a1..c357f7f47d32 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -868,6 +868,24 @@ static int write_auxtrace(int fd, struct perf_header *h,
 	return err;
 }
 
+static int write_data_index(int fd, struct perf_header *h,
+			    struct perf_evlist *evlist __maybe_unused)
+{
+	int ret;
+	unsigned i;
+
+	ret = do_write(fd, &h->nr_index, sizeof(h->nr_index));
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < h->nr_index; i++) {
+		ret = do_write(fd, &h->index[i], sizeof(*h->index));
+		if (ret < 0)
+			return ret;
+	}
+	return 0;
+}
+
 static void print_hostname(struct perf_header *ph, int fd __maybe_unused,
 			   FILE *fp)
 {
@@ -1221,6 +1239,12 @@ static void print_group_desc(struct perf_header *ph, int fd __maybe_unused,
 	}
 }
 
+static void print_data_index(struct perf_header *ph __maybe_unused,
+			     int fd __maybe_unused, FILE *fp)
+{
+	fprintf(fp, "# contains data index for parallel processing\n");
+}
+
 static int __event_process_build_id(struct build_id_event *bev,
 				    char *filename,
 				    struct perf_session *session)
@@ -1891,6 +1915,7 @@ out_free:
 	return ret;
 }
 
+
 static int process_auxtrace(struct perf_file_section *section,
 			    struct perf_header *ph, int fd,
 			    void *data __maybe_unused)
@@ -1907,6 +1932,44 @@ static int process_auxtrace(struct perf_file_section *section,
 	return err;
 }
 
+static int process_data_index(struct perf_file_section *section __maybe_unused,
+			      struct perf_header *ph, int fd,
+			      void *data __maybe_unused)
+{
+	ssize_t ret;
+	u64 nr_idx;
+	unsigned i;
+	struct perf_file_section *idx;
+
+	ret = readn(fd, &nr_idx, sizeof(nr_idx));
+	if (ret != sizeof(nr_idx))
+		return -1;
+
+	if (ph->needs_swap)
+		nr_idx = bswap_64(nr_idx);
+
+	idx = calloc(nr_idx, sizeof(*idx));
+	if (idx == NULL)
+		return -1;
+
+	for (i = 0; i < nr_idx; i++) {
+		ret = readn(fd, &idx[i], sizeof(*idx));
+		if (ret != sizeof(*idx)) {
+			free(idx);
+			return -1;
+		}
+
+		if (ph->needs_swap) {
+			idx[i].offset = bswap_64(idx[i].offset);
+			idx[i].size   = bswap_64(idx[i].size);
+		}
+	}
+
+	ph->index = idx;
+	ph->nr_index = nr_idx;
+	return 0;
+}
+
 struct feature_ops {
 	int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
 	void (*print)(struct perf_header *h, int fd, FILE *fp);
@@ -1948,6 +2011,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
 	FEAT_OPP(HEADER_PMU_MAPPINGS,	pmu_mappings),
 	FEAT_OPP(HEADER_GROUP_DESC,	group_desc),
 	FEAT_OPP(HEADER_AUXTRACE,	auxtrace),
+	FEAT_OPP(HEADER_DATA_INDEX,	data_index),
 };
 
 struct header_print_data {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 05f27cb6b7e3..add455a7abff 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -31,6 +31,7 @@ enum {
 	HEADER_PMU_MAPPINGS,
 	HEADER_GROUP_DESC,
 	HEADER_AUXTRACE,
+	HEADER_DATA_INDEX,
 	HEADER_LAST_FEATURE,
 	HEADER_FEAT_BITS	= 256,
 };
@@ -71,6 +72,8 @@ struct perf_header {
 	bool				needs_swap;
 	u64				data_offset;
 	u64				data_size;
+	struct perf_file_section	*index;
+	u64				nr_index;
 	u64				feat_offset;
 	DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
 	struct perf_env 	env;
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237939 — [RFC/PATCH 10/38] perf report: Skip dummy tracking event

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-02 07:40 +0200
Subject[RFC/PATCH 10/38] perf report: Skip dummy tracking event
Message-ID<qf1ey-2v1-15@gated-at.bofh.it>
In reply to#1237913
The dummy tracking event is only for tracking task/comom/mmap events
and has no sample data for itself.  So no need to report, just skip it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-report.c    |  3 +++
 tools/perf/ui/browsers/hists.c | 30 ++++++++++++++++++++++++------
 tools/perf/ui/gtk/hists.c      |  3 +++
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b5623639f67d..aeced4fa27e8 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -362,6 +362,9 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 		struct hists *hists = evsel__hists(pos);
 		const char *evname = perf_evsel__name(pos);
 
+		if (perf_evsel__is_dummy_tracking(pos))
+			continue;
+
 		if (symbol_conf.event_group &&
 		    !perf_evsel__is_group_leader(pos))
 			continue;
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a4e9b370c037..c8227dbb0fcc 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2219,14 +2219,17 @@ out:
 	return key;
 }
 
-static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
-				 void *entry)
+static bool filter_entries(struct ui_browser *browser __maybe_unused,
+			   void *entry)
 {
 	struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
 
 	if (symbol_conf.event_group && !perf_evsel__is_group_leader(evsel))
 		return true;
 
+	if (perf_evsel__is_dummy_tracking(evsel))
+		return true;
+
 	return false;
 }
 
@@ -2243,7 +2246,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
 			.refresh    = ui_browser__list_head_refresh,
 			.seek	    = ui_browser__list_head_seek,
 			.write	    = perf_evsel_menu__write,
-			.filter	    = filter_group_entries,
+			.filter	    = filter_entries,
 			.nr_entries = nr_entries,
 			.priv	    = evlist,
 		},
@@ -2270,21 +2273,22 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
 				  struct perf_env *env)
 {
 	int nr_entries = evlist->nr_entries;
+	struct perf_evsel *first = perf_evlist__first(evlist);
+	struct perf_evsel *pos;
 
 single_entry:
 	if (nr_entries == 1) {
-		struct perf_evsel *first = perf_evlist__first(evlist);
-
 		return perf_evsel__hists_browse(first, nr_entries, help,
 						false, hbt, min_pcnt,
 						env);
 	}
 
 	if (symbol_conf.event_group) {
-		struct perf_evsel *pos;
 
 		nr_entries = 0;
 		evlist__for_each(evlist, pos) {
+			if (perf_evsel__is_dummy_tracking(pos))
+				continue;
 			if (perf_evsel__is_group_leader(pos))
 				nr_entries++;
 		}
@@ -2293,6 +2297,20 @@ single_entry:
 			goto single_entry;
 	}
 
+	evlist__for_each(evlist, pos) {
+		if (perf_evsel__is_dummy_tracking(pos))
+			nr_entries--;
+	}
+
+	if (nr_entries == 1) {
+		evlist__for_each(evlist, pos) {
+			if (!perf_evsel__is_dummy_tracking(pos)) {
+				first = pos;
+				goto single_entry;
+			}
+		}
+	}
+
 	return __perf_evlist__tui_browse_hists(evlist, nr_entries, help,
 					       hbt, min_pcnt, env);
 }
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 4b3585eed1e8..83a7ecd5cda8 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -317,6 +317,9 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,
 		char buf[512];
 		size_t size = sizeof(buf);
 
+		if (perf_evsel__is_dummy_tracking(pos))
+			continue;
+
 		if (symbol_conf.event_group) {
 			if (!perf_evsel__is_group_leader(pos))
 				continue;
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237940 — [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-02 07:40 +0200
Subject[RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qf1ey-2v1-17@gated-at.bofh.it>
In reply to#1237913
Since it's gonna share struct mmap with dummy tracking evsel to track
meta events only, let's move auxtrace out of struct perf_mmap.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-record.c |  4 ++--
 tools/perf/util/evlist.c    | 30 +++++++++++++++++++++---------
 tools/perf/util/evlist.h    |  2 +-
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5e01c070dbf2..0accac6e0812 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -220,7 +220,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec)
 
 	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
 		struct auxtrace_mmap *mm =
-				&rec->evlist->mmap[i].auxtrace_mmap;
+				&rec->evlist->auxtrace_mmap[i];
 
 		if (!mm->base)
 			continue;
@@ -405,7 +405,7 @@ static int record__mmap_read_all(struct record *rec)
 	int rc = 0;
 
 	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
-		struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap;
+		struct auxtrace_mmap *mm = &rec->evlist->auxtrace_mmap[i];
 
 		if (rec->evlist->mmap[i].base) {
 			if (record__mmap_read(rec, i) != 0) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e46adcd5b408..042dffc67986 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -810,9 +810,12 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 	return event;
 }
 
-static bool perf_mmap__empty(struct perf_mmap *md)
+static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
 {
-	return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
+	struct perf_mmap *md = &evlist->mmap[idx];
+
+	return perf_mmap__read_head(md) == md->prev &&
+		evlist->auxtrace_mmap[idx].base == NULL;
 }
 
 static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
@@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
 		perf_mmap__write_tail(md, old);
 	}
 
-	if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
+	if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
 		perf_evlist__mmap_put(evlist, idx);
 }
 
@@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
 		evlist->mmap[idx].base = NULL;
 		atomic_set(&evlist->mmap[idx].refcnt, 0);
 	}
-	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
+	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
 }
 
 void perf_evlist__munmap(struct perf_evlist *evlist)
@@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 	if (cpu_map__empty(evlist->cpus))
 		evlist->nr_mmaps = thread_map__nr(evlist->threads);
 	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
-	return evlist->mmap != NULL ? 0 : -ENOMEM;
+	if (evlist->mmap == NULL)
+		return -ENOMEM;
+	evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
+				       sizeof(struct auxtrace_mmap));
+	if (evlist->auxtrace_mmap == NULL) {
+		zfree(&evlist->mmap);
+		return -ENOMEM;
+	}
+	return 0;
 }
 
 struct mmap_params {
@@ -938,10 +949,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 		return -1;
 	}
 
-	if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
-				&mp->auxtrace_mp, evlist->mmap[idx].base, fd))
-		return -1;
-
 	return 0;
 }
 
@@ -963,6 +970,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 			*output = fd;
 			if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
 				return -1;
+
+			if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx],
+						&mp->auxtrace_mp,
+						evlist->mmap[idx].base, fd))
+				return -1;
 		} else {
 			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
 				return -1;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 414e383885f5..51574ce8ac69 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -30,7 +30,6 @@ struct perf_mmap {
 	int		 mask;
 	atomic_t	 refcnt;
 	u64		 prev;
-	struct auxtrace_mmap auxtrace_mmap;
 	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
 };
 
@@ -53,6 +52,7 @@ struct perf_evlist {
 	} workload;
 	struct fdarray	 pollfd;
 	struct perf_mmap *mmap;
+	struct auxtrace_mmap *auxtrace_mmap;
 	struct thread_map *threads;
 	struct cpu_map	  *cpus;
 	struct perf_evsel *selected;
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1238523 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-10-02 20:50 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qfdz4-3iS-17@gated-at.bofh.it>
In reply to#1237940
Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
> Since it's gonna share struct mmap with dummy tracking evsel to track
> meta events only, let's move auxtrace out of struct perf_mmap.

Is this moving around _strictly_ needed?

- Arnaldo
 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-record.c |  4 ++--
>  tools/perf/util/evlist.c    | 30 +++++++++++++++++++++---------
>  tools/perf/util/evlist.h    |  2 +-
>  3 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 5e01c070dbf2..0accac6e0812 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -220,7 +220,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec)
>  
>  	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
>  		struct auxtrace_mmap *mm =
> -				&rec->evlist->mmap[i].auxtrace_mmap;
> +				&rec->evlist->auxtrace_mmap[i];
>  
>  		if (!mm->base)
>  			continue;
> @@ -405,7 +405,7 @@ static int record__mmap_read_all(struct record *rec)
>  	int rc = 0;
>  
>  	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
> -		struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap;
> +		struct auxtrace_mmap *mm = &rec->evlist->auxtrace_mmap[i];
>  
>  		if (rec->evlist->mmap[i].base) {
>  			if (record__mmap_read(rec, i) != 0) {
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index e46adcd5b408..042dffc67986 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -810,9 +810,12 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
>  	return event;
>  }
>  
> -static bool perf_mmap__empty(struct perf_mmap *md)
> +static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
>  {
> -	return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
> +	struct perf_mmap *md = &evlist->mmap[idx];
> +
> +	return perf_mmap__read_head(md) == md->prev &&
> +		evlist->auxtrace_mmap[idx].base == NULL;
>  }
>  
>  static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
> @@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
>  		perf_mmap__write_tail(md, old);
>  	}
>  
> -	if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
> +	if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
>  		perf_evlist__mmap_put(evlist, idx);
>  }
>  
> @@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
>  		evlist->mmap[idx].base = NULL;
>  		atomic_set(&evlist->mmap[idx].refcnt, 0);
>  	}
> -	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
> +	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
>  }
>  
>  void perf_evlist__munmap(struct perf_evlist *evlist)
> @@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
>  	if (cpu_map__empty(evlist->cpus))
>  		evlist->nr_mmaps = thread_map__nr(evlist->threads);
>  	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
> -	return evlist->mmap != NULL ? 0 : -ENOMEM;
> +	if (evlist->mmap == NULL)
> +		return -ENOMEM;
> +	evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
> +				       sizeof(struct auxtrace_mmap));
> +	if (evlist->auxtrace_mmap == NULL) {
> +		zfree(&evlist->mmap);
> +		return -ENOMEM;
> +	}
> +	return 0;
>  }
>  
>  struct mmap_params {
> @@ -938,10 +949,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
>  		return -1;
>  	}
>  
> -	if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
> -				&mp->auxtrace_mp, evlist->mmap[idx].base, fd))
> -		return -1;
> -
>  	return 0;
>  }
>  
> @@ -963,6 +970,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
>  			*output = fd;
>  			if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
>  				return -1;
> +
> +			if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx],
> +						&mp->auxtrace_mp,
> +						evlist->mmap[idx].base, fd))
> +				return -1;
>  		} else {
>  			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
>  				return -1;
> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
> index 414e383885f5..51574ce8ac69 100644
> --- a/tools/perf/util/evlist.h
> +++ b/tools/perf/util/evlist.h
> @@ -30,7 +30,6 @@ struct perf_mmap {
>  	int		 mask;
>  	atomic_t	 refcnt;
>  	u64		 prev;
> -	struct auxtrace_mmap auxtrace_mmap;
>  	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
>  };
>  
> @@ -53,6 +52,7 @@ struct perf_evlist {
>  	} workload;
>  	struct fdarray	 pollfd;
>  	struct perf_mmap *mmap;
> +	struct auxtrace_mmap *auxtrace_mmap;
>  	struct thread_map *threads;
>  	struct cpu_map	  *cpus;
>  	struct perf_evsel *selected;
> -- 
> 2.6.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1239478 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-10-05 13:40 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgchz-64T-1@gated-at.bofh.it>
In reply to#1238523
On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>> Since it's gonna share struct mmap with dummy tracking evsel to track
>> meta events only, let's move auxtrace out of struct perf_mmap.
> Is this moving around _strictly_ needed?

Also, what if you wanted to capture AUX data and tracking together.

In addition, currently Intel PT can have either 1 dummy event for tracking
plus sched_switch
or 2 dummy events to allow for system-wide tracking of context switches.
i.e. there
are multiple tracking events.

>
> - Arnaldo
>  
>> Cc: Adrian Hunter <adrian.hunter@intel.com>
>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>> ---
>>  tools/perf/builtin-record.c |  4 ++--
>>  tools/perf/util/evlist.c    | 30 +++++++++++++++++++++---------
>>  tools/perf/util/evlist.h    |  2 +-
>>  3 files changed, 24 insertions(+), 12 deletions(-)
>>
>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>> index 5e01c070dbf2..0accac6e0812 100644
>> --- a/tools/perf/builtin-record.c
>> +++ b/tools/perf/builtin-record.c
>> @@ -220,7 +220,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec)
>>  
>>  	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
>>  		struct auxtrace_mmap *mm =
>> -				&rec->evlist->mmap[i].auxtrace_mmap;
>> +				&rec->evlist->auxtrace_mmap[i];
>>  
>>  		if (!mm->base)
>>  			continue;
>> @@ -405,7 +405,7 @@ static int record__mmap_read_all(struct record *rec)
>>  	int rc = 0;
>>  
>>  	for (i = 0; i < rec->evlist->nr_mmaps; i++) {
>> -		struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap;
>> +		struct auxtrace_mmap *mm = &rec->evlist->auxtrace_mmap[i];
>>  
>>  		if (rec->evlist->mmap[i].base) {
>>  			if (record__mmap_read(rec, i) != 0) {
>> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
>> index e46adcd5b408..042dffc67986 100644
>> --- a/tools/perf/util/evlist.c
>> +++ b/tools/perf/util/evlist.c
>> @@ -810,9 +810,12 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
>>  	return event;
>>  }
>>  
>> -static bool perf_mmap__empty(struct perf_mmap *md)
>> +static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
>>  {
>> -	return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
>> +	struct perf_mmap *md = &evlist->mmap[idx];
>> +
>> +	return perf_mmap__read_head(md) == md->prev &&
>> +		evlist->auxtrace_mmap[idx].base == NULL;
>>  }
>>  
>>  static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
>> @@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
>>  		perf_mmap__write_tail(md, old);
>>  	}
>>  
>> -	if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
>> +	if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
>>  		perf_evlist__mmap_put(evlist, idx);
>>  }
>>  
>> @@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
>>  		evlist->mmap[idx].base = NULL;
>>  		atomic_set(&evlist->mmap[idx].refcnt, 0);
>>  	}
>> -	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
>> +	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
>>  }
>>  
>>  void perf_evlist__munmap(struct perf_evlist *evlist)
>> @@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
>>  	if (cpu_map__empty(evlist->cpus))
>>  		evlist->nr_mmaps = thread_map__nr(evlist->threads);
>>  	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
>> -	return evlist->mmap != NULL ? 0 : -ENOMEM;
>> +	if (evlist->mmap == NULL)
>> +		return -ENOMEM;
>> +	evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
>> +				       sizeof(struct auxtrace_mmap));
>> +	if (evlist->auxtrace_mmap == NULL) {
>> +		zfree(&evlist->mmap);
>> +		return -ENOMEM;
>> +	}
>> +	return 0;
>>  }
>>  
>>  struct mmap_params {
>> @@ -938,10 +949,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
>>  		return -1;
>>  	}
>>  
>> -	if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
>> -				&mp->auxtrace_mp, evlist->mmap[idx].base, fd))
>> -		return -1;
>> -
>>  	return 0;
>>  }
>>  
>> @@ -963,6 +970,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
>>  			*output = fd;
>>  			if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
>>  				return -1;
>> +
>> +			if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx],
>> +						&mp->auxtrace_mp,
>> +						evlist->mmap[idx].base, fd))
>> +				return -1;
>>  		} else {
>>  			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
>>  				return -1;
>> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
>> index 414e383885f5..51574ce8ac69 100644
>> --- a/tools/perf/util/evlist.h
>> +++ b/tools/perf/util/evlist.h
>> @@ -30,7 +30,6 @@ struct perf_mmap {
>>  	int		 mask;
>>  	atomic_t	 refcnt;
>>  	u64		 prev;
>> -	struct auxtrace_mmap auxtrace_mmap;
>>  	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
>>  };
>>  
>> @@ -53,6 +52,7 @@ struct perf_evlist {
>>  	} workload;
>>  	struct fdarray	 pollfd;
>>  	struct perf_mmap *mmap;
>> +	struct auxtrace_mmap *auxtrace_mmap;
>>  	struct thread_map *threads;
>>  	struct cpu_map	  *cpus;
>>  	struct perf_evsel *selected;
>> -- 
>> 2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1240280 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-06 11:10 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgwpX-1Fi-9@gated-at.bofh.it>
In reply to#1239478
Hi Adrian,

On Mon, Oct 5, 2015 at 8:29 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
>> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>>> Since it's gonna share struct mmap with dummy tracking evsel to track
>>> meta events only, let's move auxtrace out of struct perf_mmap.
>> Is this moving around _strictly_ needed?
>
> Also, what if you wanted to capture AUX data and tracking together.

Hmm.. I don't know what's the problem.  It should be orthogonal and
support doing that together IMHO.  Maybe I'm missing something about
the aux data processing and Intel PT.  I'll take a look at it..


>
> In addition, currently Intel PT can have either 1 dummy event for tracking
> plus sched_switch
> or 2 dummy events to allow for system-wide tracking of context switches.
> i.e. there
> are multiple tracking events.

Again, I don't have an idea what's going on this area. I need to look
at the code and think about what I can do.

Thanks for your review!
Namhyung



>
>>
>> - Arnaldo
>>
>>> Cc: Adrian Hunter <adrian.hunter@intel.com>
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>> ---
>>>  tools/perf/builtin-record.c |  4 ++--
>>>  tools/perf/util/evlist.c    | 30 +++++++++++++++++++++---------
>>>  tools/perf/util/evlist.h    |  2 +-
>>>  3 files changed, 24 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>>> index 5e01c070dbf2..0accac6e0812 100644
>>> --- a/tools/perf/builtin-record.c
>>> +++ b/tools/perf/builtin-record.c
>>> @@ -220,7 +220,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec)
>>>
>>>      for (i = 0; i < rec->evlist->nr_mmaps; i++) {
>>>              struct auxtrace_mmap *mm =
>>> -                            &rec->evlist->mmap[i].auxtrace_mmap;
>>> +                            &rec->evlist->auxtrace_mmap[i];
>>>
>>>              if (!mm->base)
>>>                      continue;
>>> @@ -405,7 +405,7 @@ static int record__mmap_read_all(struct record *rec)
>>>      int rc = 0;
>>>
>>>      for (i = 0; i < rec->evlist->nr_mmaps; i++) {
>>> -            struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap;
>>> +            struct auxtrace_mmap *mm = &rec->evlist->auxtrace_mmap[i];
>>>
>>>              if (rec->evlist->mmap[i].base) {
>>>                      if (record__mmap_read(rec, i) != 0) {
>>> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
>>> index e46adcd5b408..042dffc67986 100644
>>> --- a/tools/perf/util/evlist.c
>>> +++ b/tools/perf/util/evlist.c
>>> @@ -810,9 +810,12 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
>>>      return event;
>>>  }
>>>
>>> -static bool perf_mmap__empty(struct perf_mmap *md)
>>> +static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
>>>  {
>>> -    return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
>>> +    struct perf_mmap *md = &evlist->mmap[idx];
>>> +
>>> +    return perf_mmap__read_head(md) == md->prev &&
>>> +            evlist->auxtrace_mmap[idx].base == NULL;
>>>  }
>>>
>>>  static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
>>> @@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
>>>              perf_mmap__write_tail(md, old);
>>>      }
>>>
>>> -    if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
>>> +    if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
>>>              perf_evlist__mmap_put(evlist, idx);
>>>  }
>>>
>>> @@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
>>>              evlist->mmap[idx].base = NULL;
>>>              atomic_set(&evlist->mmap[idx].refcnt, 0);
>>>      }
>>> -    auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
>>> +    auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
>>>  }
>>>
>>>  void perf_evlist__munmap(struct perf_evlist *evlist)
>>> @@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
>>>      if (cpu_map__empty(evlist->cpus))
>>>              evlist->nr_mmaps = thread_map__nr(evlist->threads);
>>>      evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
>>> -    return evlist->mmap != NULL ? 0 : -ENOMEM;
>>> +    if (evlist->mmap == NULL)
>>> +            return -ENOMEM;
>>> +    evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
>>> +                                   sizeof(struct auxtrace_mmap));
>>> +    if (evlist->auxtrace_mmap == NULL) {
>>> +            zfree(&evlist->mmap);
>>> +            return -ENOMEM;
>>> +    }
>>> +    return 0;
>>>  }
>>>
>>>  struct mmap_params {
>>> @@ -938,10 +949,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
>>>              return -1;
>>>      }
>>>
>>> -    if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
>>> -                            &mp->auxtrace_mp, evlist->mmap[idx].base, fd))
>>> -            return -1;
>>> -
>>>      return 0;
>>>  }
>>>
>>> @@ -963,6 +970,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
>>>                      *output = fd;
>>>                      if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
>>>                              return -1;
>>> +
>>> +                    if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx],
>>> +                                            &mp->auxtrace_mp,
>>> +                                            evlist->mmap[idx].base, fd))
>>> +                            return -1;
>>>              } else {
>>>                      if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
>>>                              return -1;
>>> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
>>> index 414e383885f5..51574ce8ac69 100644
>>> --- a/tools/perf/util/evlist.h
>>> +++ b/tools/perf/util/evlist.h
>>> @@ -30,7 +30,6 @@ struct perf_mmap {
>>>      int              mask;
>>>      atomic_t         refcnt;
>>>      u64              prev;
>>> -    struct auxtrace_mmap auxtrace_mmap;
>>>      char             event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
>>>  };
>>>
>>> @@ -53,6 +52,7 @@ struct perf_evlist {
>>>      } workload;
>>>      struct fdarray   pollfd;
>>>      struct perf_mmap *mmap;
>>> +    struct auxtrace_mmap *auxtrace_mmap;
>>>      struct thread_map *threads;
>>>      struct cpu_map    *cpus;
>>>      struct perf_evsel *selected;
>>> --
>>> 2.6.0
>



-- 
Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1240310 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-10-06 11:30 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgwJl-21W-41@gated-at.bofh.it>
In reply to#1240280
On 06/10/15 12:03, Namhyung Kim wrote:
> Hi Adrian,
> 
> On Mon, Oct 5, 2015 at 8:29 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
>>> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>>>> Since it's gonna share struct mmap with dummy tracking evsel to track
>>>> meta events only, let's move auxtrace out of struct perf_mmap.
>>> Is this moving around _strictly_ needed?
>>
>> Also, what if you wanted to capture AUX data and tracking together.
> 
> Hmm.. I don't know what's the problem.  It should be orthogonal and
> support doing that together IMHO.  Maybe I'm missing something about
> the aux data processing and Intel PT.  I'll take a look at it..
> 

It is only orthogonal if you assume we will never want to support parallel
processing with Intel PT.

The only change that needs to be made is not to assume there is only 1
tracking event.

IMHO there could be separate mmap_params also, which would allow for
different mmap sizes for the tracking and main mmaps.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241248 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-07 11:10 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgSTw-gt-3@gated-at.bofh.it>
In reply to#1240310
Hi Adrian,

On Tue, Oct 6, 2015 at 6:26 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> On 06/10/15 12:03, Namhyung Kim wrote:
>> Hi Adrian,
>>
>> On Mon, Oct 5, 2015 at 8:29 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>> On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
>>>> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>>>>> Since it's gonna share struct mmap with dummy tracking evsel to track
>>>>> meta events only, let's move auxtrace out of struct perf_mmap.
>>>> Is this moving around _strictly_ needed?
>>>
>>> Also, what if you wanted to capture AUX data and tracking together.
>>
>> Hmm.. I don't know what's the problem.  It should be orthogonal and
>> support doing that together IMHO.  Maybe I'm missing something about
>> the aux data processing and Intel PT.  I'll take a look at it..
>>
>
> It is only orthogonal if you assume we will never want to support parallel
> processing with Intel PT.

We'll definitely want it. :)

>
> The only change that needs to be made is not to assume there is only 1
> tracking event.

IIUC Intel PT (and BTS?) needs maximum 2 dummy events - one is to
track task/mmap and another is to track context switches.  The latter
is basically a light-weight version of the sched_switch event, right?

For parallel processing, each cpu needs to keep current thread to
synthesize events from auxtrace data.  So if it processed the switch
events before processing samples, it'd need to build long lists of
current thread per cpu.  IMHO it'd be better to process the switch
events with samples using multi-thread rather than processing them
prior to samples.

So how about this?  It'd use *always* 2 dummy (or 1 dummy + 1
sched_switch) events.  The tracking dummy events would be recorded on
the tracking mmaps and switch (dummy) event would be recorded on the
main mmaps.  This way we can parallelize the auxtrace processing
without the list of current thread IMHO.

Do I miss something?

>
> IMHO there could be separate mmap_params also, which would allow for
> different mmap sizes for the tracking and main mmaps.

Currently, the tracking mmap size is fixed at an arbitrary size
(128KiB) regardless of the main mmaps.  I can add an option to change
the tracking mmap size too.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1242583 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-10-08 18:10 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qhlVw-8s5-41@gated-at.bofh.it>
In reply to#1241248
On 7/10/2015 12:06 p.m., Namhyung Kim wrote:
> Hi Adrian,
>
> On Tue, Oct 6, 2015 at 6:26 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> On 06/10/15 12:03, Namhyung Kim wrote:
>>> Hi Adrian,
>>>
>>> On Mon, Oct 5, 2015 at 8:29 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>>> On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
>>>>> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>>>>>> Since it's gonna share struct mmap with dummy tracking evsel to track
>>>>>> meta events only, let's move auxtrace out of struct perf_mmap.
>>>>> Is this moving around _strictly_ needed?
>>>>
>>>> Also, what if you wanted to capture AUX data and tracking together.
>>>
>>> Hmm.. I don't know what's the problem.  It should be orthogonal and
>>> support doing that together IMHO.  Maybe I'm missing something about
>>> the aux data processing and Intel PT.  I'll take a look at it..
>>>
>>
>> It is only orthogonal if you assume we will never want to support parallel
>> processing with Intel PT.
>
> We'll definitely want it. :)
>
>>
>> The only change that needs to be made is not to assume there is only 1
>> tracking event.

Sorry for the slow reply.

>
> IIUC Intel PT (and BTS?) needs maximum 2 dummy events - one is to
> track task/mmap and another is to track context switches.  The latter
> is basically a light-weight version of the sched_switch event, right?

Yes

>
> For parallel processing, each cpu needs to keep current thread to
> synthesize events from auxtrace data.  So if it processed the switch
> events before processing samples, it'd need to build long lists of
> current thread per cpu.  IMHO it'd be better to process the switch
> events with samples using multi-thread rather than processing them
> prior to samples.

That is a good point.

But that would be limited to dividing the data by cpu.  It would be more
useful to divide it any which way.  Does 'perf report' care if the
data is not in order?

> So how about this?  It'd use *always* 2 dummy (or 1 dummy + 1
> sched_switch) events.  The tracking dummy events would be recorded on
> the tracking mmaps and switch (dummy) event would be recorded on the
> main mmaps.  This way we can parallelize the auxtrace processing
> without the list of current thread IMHO.
>
> Do I miss something?

Thinking about it now, it would probably make sense to put the AUX
event with the tracking events as well, so the data can be queued up
ready for processing, then the AUX index would not be needed.  But of
course, if there were no other events, then there would be no main
mmap at all.

 From that point of view, I guess I don't need to worry about splitting
up the mmaps at all, just process them more than once if need be.

>
>>
>> IMHO there could be separate mmap_params also, which would allow for
>> different mmap sizes for the tracking and main mmaps.
>
> Currently, the tracking mmap size is fixed at an arbitrary size
> (128KiB) regardless of the main mmaps.  I can add an option to change
> the tracking mmap size too.

I meant more from the program point of view, to allow different parameters.
Such as allowing one mmap to be PROT_READ and the other PROT_READ|PROT_WRITE
i.e. collect all the tracking events but let the other events overwrite
- perhaps as some kind of snapshot mode like we do with Intel PT.

It seemed to me that it would be more flexible to put evsels into mmap
groups.  Then those groups could have any events or be used in various ways.
I also thought it might make the mmap code more readable, instead of having
lots of "if tracking event do something different".

On the other hand, it is just a thought.  As I mentioned above, I realized
I could probably manage without splitting the mmaps.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1243098 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-09 10:00 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qhAKS-4hU-13@gated-at.bofh.it>
In reply to#1242583
Hi Adrian,

On Thu, Oct 08, 2015 at 07:07:43PM +0300, Adrian Hunter wrote:
> On 7/10/2015 12:06 p.m., Namhyung Kim wrote:
> >Hi Adrian,
> >
> >On Tue, Oct 6, 2015 at 6:26 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>On 06/10/15 12:03, Namhyung Kim wrote:
> >>>Hi Adrian,
> >>>
> >>>On Mon, Oct 5, 2015 at 8:29 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> >>>>On 02/10/15 21:45, Arnaldo Carvalho de Melo wrote:
> >>>>>Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
> >>>>>>Since it's gonna share struct mmap with dummy tracking evsel to track
> >>>>>>meta events only, let's move auxtrace out of struct perf_mmap.
> >>>>>Is this moving around _strictly_ needed?
> >>>>
> >>>>Also, what if you wanted to capture AUX data and tracking together.
> >>>
> >>>Hmm.. I don't know what's the problem.  It should be orthogonal and
> >>>support doing that together IMHO.  Maybe I'm missing something about
> >>>the aux data processing and Intel PT.  I'll take a look at it..
> >>>
> >>
> >>It is only orthogonal if you assume we will never want to support parallel
> >>processing with Intel PT.
> >
> >We'll definitely want it. :)
> >
> >>
> >>The only change that needs to be made is not to assume there is only 1
> >>tracking event.
> 
> Sorry for the slow reply.

No problem at all.  JFYI I'm travelling now.. :)


> 
> >
> >IIUC Intel PT (and BTS?) needs maximum 2 dummy events - one is to
> >track task/mmap and another is to track context switches.  The latter
> >is basically a light-weight version of the sched_switch event, right?
> 
> Yes
> 
> >
> >For parallel processing, each cpu needs to keep current thread to
> >synthesize events from auxtrace data.  So if it processed the switch
> >events before processing samples, it'd need to build long lists of
> >current thread per cpu.  IMHO it'd be better to process the switch
> >events with samples using multi-thread rather than processing them
> >prior to samples.
> 
> That is a good point.
> 
> But that would be limited to dividing the data by cpu.  It would be more
> useful to divide it any which way.  Does 'perf report' care if the
> data is not in order?

It doesn't as long as it could find a correct thread/dso/symbol ...

Btw I thought it'd also work if the targets are tasks since it'd still
be able to follow context switches of the tasks as switch events are
recorded along with the auxtrace events per task, no?

> 
> >So how about this?  It'd use *always* 2 dummy (or 1 dummy + 1
> >sched_switch) events.  The tracking dummy events would be recorded on
> >the tracking mmaps and switch (dummy) event would be recorded on the
> >main mmaps.  This way we can parallelize the auxtrace processing
> >without the list of current thread IMHO.
> >
> >Do I miss something?
> 
> Thinking about it now, it would probably make sense to put the AUX
> event with the tracking events as well, so the data can be queued up
> ready for processing, then the AUX index would not be needed.  But of
> course, if there were no other events, then there would be no main
> mmap at all.

Hmm.. let me try to follow. :)

So we can have 3 types of mmap in this case:

  1. track mmap for task/mmap events - it'll be saved in a separate
     file (in the meantime).
  2. main mmap for samples - it'll be saved in per-index (cpu or task)
     file.  For Intel PT, the switch events will be saved here too.
  3. auxtrace mmap - it'll be saved in per-index file (with switch events).

> 
> From that point of view, I guess I don't need to worry about splitting
> up the mmaps at all, just process them more than once if need be.

OK. I don't follow.. Can you elaborate it more?  Do you think it's not
necessary to use two dummy events?  What can be processed more than
once?

> 
> >
> >>
> >>IMHO there could be separate mmap_params also, which would allow for
> >>different mmap sizes for the tracking and main mmaps.
> >
> >Currently, the tracking mmap size is fixed at an arbitrary size
> >(128KiB) regardless of the main mmaps.  I can add an option to change
> >the tracking mmap size too.
> 
> I meant more from the program point of view, to allow different parameters.
> Such as allowing one mmap to be PROT_READ and the other PROT_READ|PROT_WRITE
> i.e. collect all the tracking events but let the other events overwrite
> - perhaps as some kind of snapshot mode like we do with Intel PT.

Ah, I see.

> 
> It seemed to me that it would be more flexible to put evsels into mmap
> groups.  Then those groups could have any events or be used in various ways.
> I also thought it might make the mmap code more readable, instead of having
> lots of "if tracking event do something different".

Hmm.. good idea.  I'll think about it.

> 
> On the other hand, it is just a thought.  As I mentioned above, I realized
> I could probably manage without splitting the mmaps.

It'd be nice if you'd explain your thoughts in more detail.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1240270 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-06 11:00 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgwgh-1eJ-5@gated-at.bofh.it>
In reply to#1238523
On Sat, Oct 3, 2015 at 3:45 AM, Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
> Em Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim escreveu:
>> Since it's gonna share struct mmap with dummy tracking evsel to track
>> meta events only, let's move auxtrace out of struct perf_mmap.
>
> Is this moving around _strictly_ needed?

In the later patch, I added another perf_mmap instance for dummy
tracking events. So keeping auxtrace_mmap in the perf_mmap is a
duplication.  It's not strictly needed but will waste some memory.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1239542 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromJiri Olsa <jolsa@redhat.com>
Date2015-10-05 15:20 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgdQm-8oB-9@gated-at.bofh.it>
In reply to#1237940
On Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim wrote:

SNIP

> @@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
>  		perf_mmap__write_tail(md, old);
>  	}
>  
> -	if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
> +	if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
>  		perf_evlist__mmap_put(evlist, idx);
>  }
>  
> @@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
>  		evlist->mmap[idx].base = NULL;
>  		atomic_set(&evlist->mmap[idx].refcnt, 0);
>  	}
> -	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
> +	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
>  }
>  
>  void perf_evlist__munmap(struct perf_evlist *evlist)
> @@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
>  	if (cpu_map__empty(evlist->cpus))
>  		evlist->nr_mmaps = thread_map__nr(evlist->threads);
>  	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
> -	return evlist->mmap != NULL ? 0 : -ENOMEM;
> +	if (evlist->mmap == NULL)
> +		return -ENOMEM;
> +	evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
> +				       sizeof(struct auxtrace_mmap));
> +	if (evlist->auxtrace_mmap == NULL) {
> +		zfree(&evlist->mmap);
> +		return -ENOMEM;
> +	}

can't see evlist->auxtrace_mmap being freed 

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1240269 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-06 10:50 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qgw6C-13i-41@gated-at.bofh.it>
In reply to#1239542
On Mon, Oct 05, 2015 at 03:14:34PM +0200, Jiri Olsa wrote:
> On Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> > @@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
> >  		perf_mmap__write_tail(md, old);
> >  	}
> >  
> > -	if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
> > +	if (atomic_read(&md->refcnt) == 1 && perf_evlist__mmap_empty(evlist, idx))
> >  		perf_evlist__mmap_put(evlist, idx);
> >  }
> >  
> > @@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
> >  		evlist->mmap[idx].base = NULL;
> >  		atomic_set(&evlist->mmap[idx].refcnt, 0);
> >  	}
> > -	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
> > +	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
> >  }
> >  
> >  void perf_evlist__munmap(struct perf_evlist *evlist)
> > @@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
> >  	if (cpu_map__empty(evlist->cpus))
> >  		evlist->nr_mmaps = thread_map__nr(evlist->threads);
> >  	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
> > -	return evlist->mmap != NULL ? 0 : -ENOMEM;
> > +	if (evlist->mmap == NULL)
> > +		return -ENOMEM;
> > +	evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
> > +				       sizeof(struct auxtrace_mmap));
> > +	if (evlist->auxtrace_mmap == NULL) {
> > +		zfree(&evlist->mmap);
> > +		return -ENOMEM;
> > +	}
> 
> can't see evlist->auxtrace_mmap being freed 

Ooops, will add.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1242159 — Re: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

FromJiri Olsa <jolsa@redhat.com>
Date2015-10-08 12:20 +0200
SubjectRe: [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist
Message-ID<qhgsP-u9-25@gated-at.bofh.it>
In reply to#1237940
On Fri, Oct 02, 2015 at 02:18:44PM +0900, Namhyung Kim wrote:
> Since it's gonna share struct mmap with dummy tracking evsel to track
> meta events only, let's move auxtrace out of struct perf_mmap.

after applying this one I got:

[jolsa@krava perf]$ ./perf record  kill
failed to mmap with 13 (Permission denied)

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237941 — [RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-02 07:40 +0200
Subject[RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event
Message-ID<qf1ey-2v1-19@gated-at.bofh.it>
In reply to#1237913
When indexed data file support is enabled, a dummy tracking event will
be used to track metadata (like task, comm and mmap events) for a
session and actual samples will be recorded in separate (intermediate)
files and then merged (with index table).

Provide separate mmap to the dummy tracking event.  The size is fixed
to 128KiB (+ 1 page) as the event rate will be lower than samples.  I
originally wanted to use a single mmap for this but cross-cpu sharing
is prohibited so it's per-cpu (or per-task) like normal mmaps.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-record.c |   2 +-
 tools/perf/util/evlist.c    | 106 ++++++++++++++++++++++++++++++++++----------
 tools/perf/util/evlist.h    |   9 ++++
 3 files changed, 93 insertions(+), 24 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0accac6e0812..33dc2eafe2b5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -74,7 +74,7 @@ static int process_synthesized_event(struct perf_tool *tool,
 
 static int record__mmap_read(struct record *rec, int idx)
 {
-	struct perf_mmap *md = &rec->evlist->mmap[idx];
+	struct perf_mmap *md = perf_evlist__mmap_desc(rec->evlist, idx);
 	u64 head = perf_mmap__read_head(md);
 	u64 old = md->prev;
 	unsigned char *data = md->base + page_size;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 8d31883cbeb8..25a9c3b5f473 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -743,7 +743,7 @@ static struct perf_evsel *perf_evlist__event2evsel(struct perf_evlist *evlist,
 
 union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 {
-	struct perf_mmap *md = &evlist->mmap[idx];
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
 	u64 head;
 	u64 old = md->prev;
 	unsigned char *data = md->base + page_size;
@@ -812,28 +812,38 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 
 static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
 {
-	struct perf_mmap *md = &evlist->mmap[idx];
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
 
-	return perf_mmap__read_head(md) == md->prev &&
-		evlist->auxtrace_mmap[idx].base == NULL;
+	if (perf_mmap__read_head(md) != md->prev)
+		return false;
+
+	if (idx >= 0)
+		return !evlist->auxtrace_mmap[idx].base;
+	return true;
 }
 
 static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
 {
-	atomic_inc(&evlist->mmap[idx].refcnt);
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+	atomic_inc(&md->refcnt);
 }
 
 static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx)
 {
-	BUG_ON(atomic_read(&evlist->mmap[idx].refcnt) == 0);
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+	BUG_ON(atomic_read(&md->refcnt) == 0);
 
-	if (atomic_dec_and_test(&evlist->mmap[idx].refcnt))
-		__perf_evlist__munmap(evlist, idx);
+	if (!atomic_dec_and_test(&md->refcnt))
+		return;
+
+	__perf_evlist__munmap(evlist, idx);
 }
 
 void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
 {
-	struct perf_mmap *md = &evlist->mmap[idx];
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
 
 	if (!evlist->overwrite) {
 		u64 old = md->prev;
@@ -875,14 +885,15 @@ void __weak auxtrace_mmap_params__set_idx(
 
 static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
 {
-	if (evlist->mmap[idx].base != NULL) {
-		size_t mmap_len = perf_evlist__mmap_len(evlist->mmap[idx].mask);
+	struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+	if (md->base != NULL) {
+		size_t mmap_len = perf_evlist__mmap_len(md->mask);
 
-		munmap(evlist->mmap[idx].base, mmap_len);
-		evlist->mmap[idx].base = NULL;
-		atomic_set(&evlist->mmap[idx].refcnt, 0);
+		munmap(md->base, mmap_len);
+		md->base = NULL;
+		atomic_set(&md->refcnt, 0);
 	}
-	auxtrace_mmap__munmap(&evlist->auxtrace_mmap[idx]);
 }
 
 void perf_evlist__munmap(struct perf_evlist *evlist)
@@ -892,13 +903,17 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
 	if (evlist->mmap == NULL)
 		return;
 
-	for (i = 0; i < evlist->nr_mmaps; i++)
+	for (i = 0; i < evlist->nr_mmaps; i++) {
 		__perf_evlist__munmap(evlist, i);
+		auxtrace_mmap__munmap(&evlist->auxtrace_mmap[i]);
+		if (evlist->track_mmap)
+			__perf_evlist__munmap(evlist, track_mmap_idx(i));
+	}
 
 	zfree(&evlist->mmap);
 }
 
-static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
+static int perf_evlist__alloc_mmap(struct perf_evlist *evlist, bool track_mmap)
 {
 	evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
 	if (cpu_map__empty(evlist->cpus))
@@ -912,12 +927,22 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 		zfree(&evlist->mmap);
 		return -ENOMEM;
 	}
+	if (track_mmap) {
+		evlist->track_mmap = calloc(evlist->nr_mmaps,
+					    sizeof(struct perf_mmap));
+		if (evlist->track_mmap == NULL) {
+			zfree(&evlist->mmap);
+			zfree(&evlist->auxtrace_mmap);
+			return -ENOMEM;
+		}
+	}
 	return 0;
 }
 
 struct mmap_params {
 	int	prot;
 	size_t	len;
+	bool	track_mmap;
 	struct auxtrace_mmap_params auxtrace_mp;
 };
 
@@ -954,12 +979,16 @@ static int perf_mmap__mmap(struct perf_mmap *desc,
 
 struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx)
 {
-	return &evlist->mmap[idx];
+	if (idx >= 0)
+		return &evlist->mmap[idx];
+	else
+		return &evlist->track_mmap[track_mmap_idx(idx)];
 }
 
 static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 				       struct mmap_params *mp, int cpu,
-				       int thread, int *output)
+				       int thread, int *output,
+				       int *track_output)
 {
 	struct perf_evsel *evsel;
 
@@ -972,7 +1001,30 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 
 		fd = FD(evsel, cpu, thread);
 
-		if (*output == -1) {
+		if (mp->track_mmap && perf_evsel__is_dummy_tracking(evsel)) {
+			size_t old_len = mp->len;
+
+			/* mark idx as track mmap idx (negative) */
+			idx = track_mmap_idx(idx);
+
+			desc = perf_evlist__mmap_desc(evlist, idx);
+			mp->len = TRACK_MMAP_SIZE;
+
+			if (*track_output == -1) {
+				*track_output = fd;
+				if (perf_mmap__mmap(desc, mp, fd) < 0)
+					return -1;
+			} else {
+				if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT,
+					  *track_output) != 0)
+					return -1;
+
+				perf_evlist__mmap_get(evlist, idx);
+			}
+
+			mp->len = old_len;
+
+		} else if (*output == -1) {
 			*output = fd;
 			if (perf_mmap__mmap(desc, mp, *output) < 0)
 				return -1;
@@ -1008,6 +1060,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 			perf_evlist__set_sid_idx(evlist, evsel, idx, cpu,
 						 thread);
 		}
+
+		if (mp->track_mmap && perf_evsel__is_dummy_tracking(evsel)) {
+			/* restore idx as normal mmap idx (positive) */
+			idx = track_mmap_idx(idx);
+		}
 	}
 
 	return 0;
@@ -1023,13 +1080,15 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist,
 	pr_debug2("perf event ring buffer mmapped per cpu\n");
 	for (cpu = 0; cpu < nr_cpus; cpu++) {
 		int output = -1;
+		int track_output = -1;
 
 		auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, cpu,
 					      true);
 
 		for (thread = 0; thread < nr_threads; thread++) {
 			if (perf_evlist__mmap_per_evsel(evlist, cpu, mp, cpu,
-							thread, &output))
+							thread, &output,
+							&track_output))
 				goto out_unmap;
 		}
 	}
@@ -1051,12 +1110,13 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist,
 	pr_debug2("perf event ring buffer mmapped per thread\n");
 	for (thread = 0; thread < nr_threads; thread++) {
 		int output = -1;
+		int track_output = -1;
 
 		auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, thread,
 					      false);
 
 		if (perf_evlist__mmap_per_evsel(evlist, thread, mp, 0, thread,
-						&output))
+						&output, &track_output))
 			goto out_unmap;
 	}
 
@@ -1204,7 +1264,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 		.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
 	};
 
-	if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0)
+	if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist, mp.track_mmap) < 0)
 		return -ENOMEM;
 
 	if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 79f8245300ad..fc53eb817c51 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -33,6 +33,8 @@ struct perf_mmap {
 	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
 };
 
+#define TRACK_MMAP_SIZE  (((128 * 1024 / page_size) + 1) * page_size)
+
 struct perf_evlist {
 	struct list_head entries;
 	struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
@@ -52,6 +54,7 @@ struct perf_evlist {
 	} workload;
 	struct fdarray	 pollfd;
 	struct perf_mmap *mmap;
+	struct perf_mmap *track_mmap;
 	struct auxtrace_mmap *auxtrace_mmap;
 	struct thread_map *threads;
 	struct cpu_map	  *cpus;
@@ -224,6 +227,12 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str);
 void perf_evlist__to_front(struct perf_evlist *evlist,
 			   struct perf_evsel *move_evsel);
 
+/* convert from/to negative idx for track mmap */
+static inline int track_mmap_idx(int idx)
+{
+	return -idx - 1;
+}
+
 /**
  * __evlist__for_each - iterate thru all the evsels
  * @list: list_head instance to iterate
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1244754 — Re: [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h

FromJiri Olsa <jolsa@redhat.com>
Date2015-10-12 16:40 +0200
SubjectRe: [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h
Message-ID<qiMqB-1Ld-11@gated-at.bofh.it>
In reply to#1237913
On Fri, Oct 02, 2015 at 03:58:49PM +0900, Namhyung Kim wrote:
> The util/event.h includes util/build-id.h only for BUILD_ID_SIZE.
> This is a problem when I include util/event.h from util/tool.h which
> is also included by util/build-id.h since it now makes a circular
> dependency resulting in incomplete type error.

BUILD_ID_SIZE is build-id.h specific though.. ;-)

how about removing tool.h include from build-id.h
and add just 'struct perf_tool;' declaration

or some other similar fix..

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | linux.kernel


csiph-web