Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

+5 -1
+5 -1
tools/perf/util/sort.c
··· 588 588 } else { 589 589 pevent_event_info(&seq, evsel->tp_format, &rec); 590 590 } 591 - return seq.buffer; 591 + /* 592 + * Trim the buffer, it starts at 4KB and we're not going to 593 + * add anything more to this buffer. 594 + */ 595 + return realloc(seq.buffer, seq.len + 1); 592 596 } 593 597 594 598 static int64_t