mirror of https://lore.kernel.org/lkml/
 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 09/20] perf evsel: Carve out event modifier formatting
Date: Tue, 19 Jun 2012 14:50:10 -0300	[thread overview]
Message-ID: <1340128221-17348-10-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1340128221-17348-1-git-send-email-acme@infradead.org>

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

>From perf_evsel__hw_name, so that we can use it for the other kinds of
events (tracepoints, software, hw cache, etc).

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-9gmd5wewsrvtny8tzxjfp471@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 9f6cebd..dab8938 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -86,16 +86,15 @@ const char *__perf_evsel__hw_name(u64 config)
 	return "unknown-hardware";
 }
 
-static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size)
+static int perf_evsel__add_modifiers(struct perf_evsel *evsel, char *bf, size_t size)
 {
-	int colon = 0;
+	int colon = 0, r = 0;
 	struct perf_event_attr *attr = &evsel->attr;
-	int r = scnprintf(bf, size, "%s", __perf_evsel__hw_name(attr->config));
 	bool exclude_guest_default = false;
 
 #define MOD_PRINT(context, mod)	do {					\
 		if (!attr->exclude_##context) {				\
-			if (!colon) colon = r++;			\
+			if (!colon) colon = ++r;			\
 			r += scnprintf(bf + r, size - r, "%c", mod);	\
 		} } while(0)
 
@@ -108,7 +107,7 @@ static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size)
 
 	if (attr->precise_ip) {
 		if (!colon)
-			colon = r++;
+			colon = ++r;
 		r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp");
 		exclude_guest_default = true;
 	}
@@ -119,10 +118,16 @@ static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size)
 	}
 #undef MOD_PRINT
 	if (colon)
-		bf[colon] = ':';
+		bf[colon - 1] = ':';
 	return r;
 }
 
+static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size)
+{
+	int r = scnprintf(bf, size, "%s", __perf_evsel__hw_name(evsel->attr.config));
+	return r + perf_evsel__add_modifiers(evsel, bf + r, size - r);
+}
+
 int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size)
 {
 	int ret;
-- 
1.7.1


  parent reply	other threads:[~2012-06-19 18:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19 17:50 [GIT PULL 00/20] perf/core improvements Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 01/20] perf tools: Add sort by src line/number Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 02/20] perf ui: Introduce struct perf_error_ops Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 03/20] perf ui/gtk: Introduce struct perf_gtk_context Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 04/20] perf ui/gtk: Add GTK statusbar widget to browser window Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 05/20] perf ui/gtk: Add GTK info_bar " Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 06/20] perf ui/gtk: Use struct perf_error_ops Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 07/20] perf lib: Introduce rtrim Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 08/20] perf hists browser: Implement printing snapshots to files Arnaldo Carvalho de Melo
2012-06-19 17:50 ` Arnaldo Carvalho de Melo [this message]
2012-06-19 17:50 ` [PATCH 10/20] perf tools: Reconstruct hw cache event with modifiers from perf_event_attr Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 11/20] perf tools: Reconstruct sw " Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 12/20] perf evsel: Handle all event types in perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 13/20] perf tools: Move all users of event_name to perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 14/20] perf script: Replace __event_name uses with perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 15/20] perf tools: Don't access evsel->name directly Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 16/20] perf tools: Remove __event_name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 17/20] perf evsel: Reconstruct raw event with modifiers from perf_event_attr Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 18/20] perf tools: Remove unused evsel parameter from machine__resolve_callchain Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 19/20] perf evsel: Make some methods private Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 20/20] perf annotate: Check null of sym pointer before using it Arnaldo Carvalho de Melo
2012-06-20 12:01 ` [GIT PULL 00/20] perf/core improvements Ingo Molnar
2012-06-20 14:07   ` Namhyung Kim
2012-06-20 14:49     ` Ingo Molnar
2012-06-22  4:16       ` Namhyung Kim
2012-06-25  8:22         ` Ingo Molnar

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=1340128221-17348-10-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

all inboxes | Powered by JetHome®