All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH 02/11] perf hists: Trim libtraceevent trace_seq buffers
Date: Tue,  9 Aug 2016 13:01:25 -0300	[thread overview]
Message-ID: <1470758494-32127-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1470758494-32127-1-git-send-email-acme@kernel.org>

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

When we use libtraceevent to format trace event fields into printable
strings to use in hist entries it is important to trim it from the
default 4 KiB it starts with to what is really used, to reduce the
memory footprint, so use realloc(seq.buffer, seq.len + 1) when returning
the seq.buffer formatted with the fields contents.

Reported-and-Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-t3hl7uxmilrkigzmc90rlhk2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 947d21f38398..3d3cb8392c86 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -588,7 +588,11 @@ static char *get_trace_output(struct hist_entry *he)
 	} else {
 		pevent_event_info(&seq, evsel->tp_format, &rec);
 	}
-	return seq.buffer;
+	/*
+	 * Trim the buffer, it starts at 4KB and we're not going to
+	 * add anything more to this buffer.
+	 */
+	return realloc(seq.buffer, seq.len + 1);
 }
 
 static int64_t
-- 
2.7.4

  parent reply	other threads:[~2016-08-09 16:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 16:01 [GIT PULL 00/11] perf/urgent fixes Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 01/11] perf script: Add 'bpf-output' field to usage message Arnaldo Carvalho de Melo
2016-08-09 16:01 ` Arnaldo Carvalho de Melo [this message]
2016-08-09 16:01 ` [PATCH 03/11] perf probe: Adjust map->reloc offset when finding kernel symbol from map Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 04/11] perf probe: Fix module name matching Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 05/11] perf stat: Avoid skew when reading events Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 06/11] perf probe: Support signedness casting Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 07/11] tools: Sync cpufeatures.h and vmx.h with the kernel Arnaldo Carvalho de Melo
2016-08-09 16:57   ` Ross Zwisler
2016-08-09 16:01 ` [PATCH 08/11] toops: Sync tools/include/uapi/linux/bpf.h " Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 09/11] tools: Sync cpufeatures headers " Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 10/11] perf probe: Add function to post process kernel trace events Arnaldo Carvalho de Melo
2016-08-09 16:01 ` [PATCH 11/11] perf probe ppc64le: Fix probe location when using DWARF Arnaldo Carvalho de Melo
2016-08-09 19:12 ` [GIT PULL 00/11] perf/urgent fixes 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=1470758494-32127-3-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.