linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 19/74] perf session: There is no need for a per session hists instance
Date: Thu, 24 Jan 2013 17:07:28 -0300	[thread overview]
Message-ID: <1359058103-31645-20-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1359058103-31645-1-git-send-email-acme@infradead.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

It was being used just for its stats member, so ditch session->hists and
use just what is needed, session->stats.

This completes the move support multiple events in the hists layer, the
last user of session->hists was 'perf diff' but Jiri Olsa has fixed that
some time ago.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-pimk92kek8kcp4dmb1jakoro@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-sched.c |  6 +++---
 tools/perf/builtin-top.c   |  4 ++--
 tools/perf/util/hist.c     |  9 +++++++--
 tools/perf/util/hist.h     |  1 +
 tools/perf/util/session.c  | 41 ++++++++++++++++++++---------------------
 tools/perf/util/session.h  |  6 +-----
 6 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index cc28b85..1382294 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1475,9 +1475,9 @@ static int perf_sched__read_events(struct perf_sched *sched, bool destroy,
 			goto out_delete;
 		}
 
-		sched->nr_events      = session->hists.stats.nr_events[0];
-		sched->nr_lost_events = session->hists.stats.total_lost;
-		sched->nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
+		sched->nr_events      = session->stats.nr_events[0];
+		sched->nr_lost_events = session->stats.total_lost;
+		sched->nr_lost_chunks = session->stats.nr_events[PERF_RECORD_LOST];
 	}
 
 	if (destroy)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index f5fd260..996b10c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -728,7 +728,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
 
 	if (!machine) {
 		pr_err("%u unprocessable samples recorded.\n",
-		       top->session->hists.stats.nr_unprocessable_samples++);
+		       top->session->stats.nr_unprocessable_samples++);
 		return;
 	}
 
@@ -878,7 +878,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 			hists__inc_nr_events(&evsel->hists, event->header.type);
 			machine__process_event(machine, event);
 		} else
-			++session->hists.stats.nr_unknown_events;
+			++session->stats.nr_unknown_events;
 	}
 }
 
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 37179af..965ebf9 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -717,10 +717,15 @@ int hist_entry__annotate(struct hist_entry *he, size_t privsize)
 	return symbol__annotate(he->ms.sym, he->ms.map, privsize);
 }
 
+void events_stats__inc(struct events_stats *stats, u32 type)
+{
+	++stats->nr_events[0];
+	++stats->nr_events[type];
+}
+
 void hists__inc_nr_events(struct hists *hists, u32 type)
 {
-	++hists->stats.nr_events[0];
-	++hists->stats.nr_events[type];
+	events_stats__inc(&hists->stats, type);
 }
 
 static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index cb6533b..3862468 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -98,6 +98,7 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows);
 
 void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);
 void hists__inc_nr_events(struct hists *self, u32 type);
+void events_stats__inc(struct events_stats *stats, u32 type);
 size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
 
 size_t hists__fprintf(struct hists *self, bool show_header, int max_rows,
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 6e8dd2a..b0bcc32 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -133,7 +133,6 @@ struct perf_session *perf_session__new(const char *filename, int mode,
 	INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
 	INIT_LIST_HEAD(&self->ordered_samples.to_free);
 	machine__init(&self->host_machine, "", HOST_KERNEL_ID);
-	hists__init(&self->hists);
 
 	if (mode == O_RDONLY) {
 		if (perf_session__open(self, force) < 0)
@@ -863,11 +862,11 @@ static int perf_session_deliver_event(struct perf_session *session,
 	case PERF_RECORD_SAMPLE:
 		dump_sample(evsel, event, sample);
 		if (evsel == NULL) {
-			++session->hists.stats.nr_unknown_id;
+			++session->stats.nr_unknown_id;
 			return 0;
 		}
 		if (machine == NULL) {
-			++session->hists.stats.nr_unprocessable_samples;
+			++session->stats.nr_unprocessable_samples;
 			return 0;
 		}
 		return tool->sample(tool, event, sample, evsel, machine);
@@ -881,7 +880,7 @@ static int perf_session_deliver_event(struct perf_session *session,
 		return tool->exit(tool, event, sample, machine);
 	case PERF_RECORD_LOST:
 		if (tool->lost == perf_event__process_lost)
-			session->hists.stats.total_lost += event->lost.lost;
+			session->stats.total_lost += event->lost.lost;
 		return tool->lost(tool, event, sample, machine);
 	case PERF_RECORD_READ:
 		return tool->read(tool, event, sample, evsel, machine);
@@ -890,7 +889,7 @@ static int perf_session_deliver_event(struct perf_session *session,
 	case PERF_RECORD_UNTHROTTLE:
 		return tool->unthrottle(tool, event, sample, machine);
 	default:
-		++session->hists.stats.nr_unknown_events;
+		++session->stats.nr_unknown_events;
 		return -1;
 	}
 }
@@ -904,8 +903,8 @@ static int perf_session__preprocess_sample(struct perf_session *session,
 
 	if (!ip_callchain__valid(sample->callchain, event)) {
 		pr_debug("call-chain problem with event, skipping it.\n");
-		++session->hists.stats.nr_invalid_chains;
-		session->hists.stats.total_invalid_chains += sample->period;
+		++session->stats.nr_invalid_chains;
+		session->stats.total_invalid_chains += sample->period;
 		return -EINVAL;
 	}
 	return 0;
@@ -963,7 +962,7 @@ static int perf_session__process_event(struct perf_session *session,
 	if (event->header.type >= PERF_RECORD_HEADER_MAX)
 		return -EINVAL;
 
-	hists__inc_nr_events(&session->hists, event->header.type);
+	events_stats__inc(&session->stats, event->header.type);
 
 	if (event->header.type >= PERF_RECORD_USER_TYPE_START)
 		return perf_session__process_user_event(session, event, tool, file_offset);
@@ -1018,39 +1017,39 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
 					    const struct perf_tool *tool)
 {
 	if (tool->lost == perf_event__process_lost &&
-	    session->hists.stats.nr_events[PERF_RECORD_LOST] != 0) {
+	    session->stats.nr_events[PERF_RECORD_LOST] != 0) {
 		ui__warning("Processed %d events and lost %d chunks!\n\n"
 			    "Check IO/CPU overload!\n\n",
-			    session->hists.stats.nr_events[0],
-			    session->hists.stats.nr_events[PERF_RECORD_LOST]);
+			    session->stats.nr_events[0],
+			    session->stats.nr_events[PERF_RECORD_LOST]);
 	}
 
-	if (session->hists.stats.nr_unknown_events != 0) {
+	if (session->stats.nr_unknown_events != 0) {
 		ui__warning("Found %u unknown events!\n\n"
 			    "Is this an older tool processing a perf.data "
 			    "file generated by a more recent tool?\n\n"
 			    "If that is not the case, consider "
 			    "reporting to linux-kernel@vger.kernel.org.\n\n",
-			    session->hists.stats.nr_unknown_events);
+			    session->stats.nr_unknown_events);
 	}
 
-	if (session->hists.stats.nr_unknown_id != 0) {
+	if (session->stats.nr_unknown_id != 0) {
 		ui__warning("%u samples with id not present in the header\n",
-			    session->hists.stats.nr_unknown_id);
+			    session->stats.nr_unknown_id);
 	}
 
- 	if (session->hists.stats.nr_invalid_chains != 0) {
+ 	if (session->stats.nr_invalid_chains != 0) {
  		ui__warning("Found invalid callchains!\n\n"
  			    "%u out of %u events were discarded for this reason.\n\n"
  			    "Consider reporting to linux-kernel@vger.kernel.org.\n\n",
- 			    session->hists.stats.nr_invalid_chains,
- 			    session->hists.stats.nr_events[PERF_RECORD_SAMPLE]);
+ 			    session->stats.nr_invalid_chains,
+ 			    session->stats.nr_events[PERF_RECORD_SAMPLE]);
  	}
 
-	if (session->hists.stats.nr_unprocessable_samples != 0) {
+	if (session->stats.nr_unprocessable_samples != 0) {
 		ui__warning("%u unprocessable samples recorded.\n"
 			    "Do you have a KVM guest running and not using 'perf kvm'?\n",
-			    session->hists.stats.nr_unprocessable_samples);
+			    session->stats.nr_unprocessable_samples);
 	}
 }
 
@@ -1353,7 +1352,7 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
 	struct perf_evsel *pos;
 	size_t ret = fprintf(fp, "Aggregated stats:\n");
 
-	ret += events_stats__fprintf(&session->hists.stats, fp);
+	ret += events_stats__fprintf(&session->stats, fp);
 
 	list_for_each_entry(pos, &session->evlist->entries, node) {
 		ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos));
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 426ca0c..57066cb 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -34,11 +34,7 @@ struct perf_session {
 	struct rb_root		machines;
 	struct perf_evlist	*evlist;
 	struct pevent		*pevent;
-	/*
-	 * FIXME: Need to split this up further, we need global
-	 *	  stats + per event stats.
-	 */
-	struct hists		hists;
+	struct events_stats	stats;
 	int			fd;
 	bool			fd_pipe;
 	bool			repipe;
-- 
1.8.1.1.361.gec3ae6e


  parent reply	other threads:[~2013-01-24 20:10 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1359058103-31645-1-git-send-email-acme@infradead.org>
2013-01-24 20:07 ` [PATCH 01/74] perf hists: Exchange order of comparing items when collapsing hists Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 02/74] perf hists: Link hist entries before inserting to an output tree Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 03/74] perf diff: Use internal rb tree for compute resort Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 04/74] perf test: Add a test case for hists__{match,link} Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 05/74] perf test: Remove leftover temp file left by one of the attr tests Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 06/74] perf tests: Adjust some message log levels to help diagnosing problems in " Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 07/74] perf evsel: Do missing feature fallbacks in just one place Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 08/74] perf evsel: Introduce event fallback method Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 09/74] perf evsel: Introduce perf_evsel__open_strerror method Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 10/74] perf test: Check for linking problems in the python binding Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 11/74] perf python: Fix breakage introduced by the test_attr infrastructure Arnaldo Carvalho de Melo
2013-01-29  4:06   ` Thomas Backlund
2013-01-24 20:07 ` [PATCH 12/74] perf tools: Add missing closedir in multi tracepoint processing Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 13/74] perf tools: Add support for wildcard in tracepoint system name Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 14/74] perf tests: Add event parsing test for '*:*' tracepoints Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 15/74] perf tests: Check python path on attr and binding test Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 16/74] perf header: Ensure read/write finished successfully Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 17/74] perf record: Don't pass host machine to guest synthesizer Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 18/74] perf hists: Rename hists__fprintf_nr_events to events_stats__fprintf Arnaldo Carvalho de Melo
2013-01-24 20:07 ` Arnaldo Carvalho de Melo [this message]
2013-01-24 20:07 ` [PATCH 20/74] perf machine: Introduce struct machines Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 21/74] perf tests: Fix PYTHONPATH for python-use test tracepoints Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 22/74] perf machine: Simplify accessing the host machine Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 23/74] perf kvm: Initialize file_name var to fix segfault Arnaldo Carvalho de Melo
2013-01-25  3:00   ` Xiao Guangrong
2013-01-24 20:07 ` [PATCH 24/74] perf tests: Add return states enum for tests Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 25/74] perf tests: Don't fail if a matching vmlinux isn't found, skip that test Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 26/74] perf tools: remove redundant checks from _sort__sym_cmp Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 27/74] perf kmem: use ARRAY_SIZE instead of reinventing it Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 28/74] perf script: " Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 29/74] uprobes: remove redundant check Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 30/74] perf ui/gtk: Factor out common browser routines Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 31/74] perf ui/gtk: Setup browser window early Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 32/74] tools lib traceevent: test correct variable after allocation Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 33/74] tools lib traceevent: Update FSF postal address to be URL's Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 34/74] tools lib traceevent: Add copyright header Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 35/74] perf tools: Fix GNU make v3.80 compatibility issue Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 36/74] perf tools: Fix possible (unlikely) buffer overflow Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 37/74] perf symbols: Include elf.h header regardless LIBELF_SUPPORT Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 38/74] perf bench: Flush stdout before starting bench suite Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 39/74] perf tools: Add anonymous huge page recognition Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 40/74] perf: Missing field in PERF_RECORD_SAMPLE documentation Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 41/74] perf probe: Allow of casting an array of char to string Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 42/74] perf sort: Move misplaced sort entry functions Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 43/74] perf sort: Get rid of unnecessary __maybe_unused Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 44/74] perf sort: Fix --sort pid output Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 45/74] perf sort: Align cpu column to right Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 46/74] perf sort: Calculate parent column width too Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 47/74] perf sort: Clean up sort__first_dimension setting Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 48/74] perf sort: Separate out branch stack specific sort keys Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 49/74] perf report: Update documentation for " Arnaldo Carvalho de Melo
2013-01-24 20:07 ` [PATCH 50/74] perf symbols: Move name malloc to when needed in dso__load Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 51/74] perf symbols: Mark vmlinux filename as allocated Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 52/74] perf tools: Move get_term_dimensions from top to util.c Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 53/74] perf annotate browser: Fix segfault when drawing out-of-bounds jumps Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 54/74] perf tools: Mark branch_info maps as referenced Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 55/74] perf tools: Remove unused 'unset' parameter from parse_events Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 56/74] tools lib traceevent: Fix warning on '>=' operator Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 57/74] perf tools: Get rid of unused include of config.mak Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 58/74] perf tools: Do not include PERF-VERSION-FILE to Makefile Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 59/74] perf tools: Fix PMU format parsing test failure Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 60/74] perf tools: Move ltrim() to util/string.c Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 61/74] perf tools: Fix usage of __ in parse_events_term struct Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 62/74] perf pmu: Fix usage of __ in struct names Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 63/74] perf ui browsers: " Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 64/74] perf tools: Fix usage of __ in event parsing " Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 65/74] perf tests: Use ARRAY_SIZE() were applicable Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 66/74] perf pmu: Privatize perf_pmu_{format,alias} structs Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 67/74] perf tools: Remove some needless die() calls from the main routine Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 68/74] perf tools: Reinstate 'signed' field flag for tracepoints Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 69/74] perf script: Don't display trace info when invoking scripts Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 70/74] perf script: hook up perf_scripting_context->pevent Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 71/74] perf script: Remove workqueue-stats script Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 72/74] perf tools: Allow passing NULL to intlist__find Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 73/74] perf tools: Allow passing a list to intlist__new Arnaldo Carvalho de Melo
2013-01-24 20:08 ` [PATCH 74/74] perf test: Allow skipping tests Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359058103-31645-20-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).