From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932455AbcHITRf (ORCPT ); Tue, 9 Aug 2016 15:17:35 -0400 Received: from terminus.zytor.com ([198.137.202.10]:52934 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752504AbcHITRd (ORCPT ); Tue, 9 Aug 2016 15:17:33 -0400 Date: Tue, 9 Aug 2016 12:17:18 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, mingo@kernel.org, dsahern@gmail.com, namhyung@kernel.org, adrian.hunter@intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, wangnan0@huawei.com, jolsa@kernel.org, hpa@zytor.com Reply-To: jolsa@kernel.org, hpa@zytor.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, adrian.hunter@intel.com, namhyung@kernel.org, dsahern@gmail.com, mingo@kernel.org, acme@redhat.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf hists: Trim libtraceevent trace_seq buffers Git-Commit-ID: 887fa86d6fd7a45cee2d0f9d5f75026786d61df2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 887fa86d6fd7a45cee2d0f9d5f75026786d61df2 Gitweb: http://git.kernel.org/tip/887fa86d6fd7a45cee2d0f9d5f75026786d61df2 Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 5 Aug 2016 12:37:21 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 9 Aug 2016 10:46:56 -0300 perf hists: Trim libtraceevent trace_seq buffers 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 Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/n/tip-t3hl7uxmilrkigzmc90rlhk2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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 947d21f..3d3cb83 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