From: Thomas Renninger <trenn@suse.de>
Cc: linux-perf-users@vger.kernel.org, mingo@elte.hu,
arjan@linux.intel.com, lenb@kernel.org, j-pihet@ti.com,
Thomas Renninger <trenn@suse.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH 9/9] perf: timechart: Fix memleak
Date: Fri, 7 Jan 2011 11:29:50 +0100 [thread overview]
Message-ID: <1294396190-23031-10-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1294396190-23031-1-git-send-email-trenn@suse.de>
There are others, but these are not worth it, e.g. built
up power event list which gets destroyed on program exit anyway or
some bytes when trace events get parsed.
This one showed by far the biggest memory waste, was easy to
fix and could help when parsing huge trace event records.
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Arjan van de Ven <arjan@linux.intel.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: linux-perf-users@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Found with valgrind, fixes:
==43509== 1,402 bytes in 251 blocks are definitely lost in loss record 61 of 74
==43509== at 0x4C261D7: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==43509== by 0x61573B1: strdup (in /lib64/libc-2.11.1.so)
==43509== by 0x41DD3D: draw_wakeups (builtin-timechart.c:706)
==43509== by 0x41E7C9: write_svg_file (builtin-timechart.c:957)
==43509== by 0x41E87E: __cmd_timechart (builtin-timechart.c:989)
==43509== by 0x41EB3C: cmd_timechart (builtin-timechart.c:1097)
==43509== by 0x40D776: run_builtin (perf.c:286)
==43509== by 0x40D993: handle_internal_command (perf.c:357)
==43509== by 0x40DAD2: run_argv (perf.c:401)
==43509== by 0x40DCB3: main (perf.c:487)
==43509==
==43509== 2,826 bytes in 429 blocks are definitely lost in loss record 63 of 74
==43509== at 0x4C261D7: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==43509== by 0x61573B1: strdup (in /lib64/libc-2.11.1.so)
==43509== by 0x41DD70: draw_wakeups (builtin-timechart.c:710)
==43509== by 0x41E7C9: write_svg_file (builtin-timechart.c:957)
==43509== by 0x41E87E: __cmd_timechart (builtin-timechart.c:989)
==43509== by 0x41EB3C: cmd_timechart (builtin-timechart.c:1097)
==43509== by 0x40D776: run_builtin (perf.c:286)
==43509== by 0x40D993: handle_internal_command (perf.c:357)
==43509== by 0x40DAD2: run_argv (perf.c:401)
==43509== by 0x40DCB3: main (perf.c:487)
---
tools/perf/builtin-timechart.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 54e9c37..63dc1fd 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -696,10 +696,14 @@ static void draw_wakeups(void)
if (c->Y && c->start_time <= we->time && c->end_time >= we->time) {
if (p->pid == we->waker && !from) {
from = c->Y;
+ if (task_from)
+ free(task_from);
task_from = strdup(c->comm);
}
if (p->pid == we->wakee && !to) {
to = c->Y;
+ if (task_to)
+ free(task_to);
task_to = strdup(c->comm);
}
}
@@ -709,10 +713,14 @@ static void draw_wakeups(void)
while (c) {
if (p->pid == we->waker && !from) {
from = c->Y;
+ if (task_from)
+ free(task_from);
task_from = strdup(c->comm);
}
if (p->pid == we->wakee && !to) {
to = c->Y;
+ if (task_to)
+ free(task_to);
task_to = strdup(c->comm);
}
c = c->next;
--
1.7.3.1
prev parent reply other threads:[~2011-01-07 10:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 10:29 [PATCH 0/9] Make cpu_idle events architecture independent Thomas Renninger
2011-01-07 10:29 ` [PATCH 1/9] acpi: Use ACPI C-state type instead of enumeration value to export cpuidle state name Thomas Renninger
2011-01-07 20:45 ` Len Brown
2011-01-09 12:30 ` Thomas Renninger
2011-01-12 6:36 ` Len Brown
2011-01-12 12:33 ` Thomas Renninger
2011-01-12 22:41 ` Len Brown
2011-01-07 10:29 ` [PATCH 2/9] cpuidle: Rename X86 specific idle poll state[0] from C0 to POLL Thomas Renninger
2011-01-12 6:37 ` Len Brown
2011-01-07 10:29 ` [PATCH 3/9] X86/perf: fix power:cpu_idle double end events and throw cpu_idle events from the cpuidle layer Thomas Renninger
2011-01-12 6:42 ` Len Brown
2011-01-12 15:16 ` Thomas Renninger
2011-01-12 23:12 ` Len Brown
2011-01-07 10:29 ` [PATCH 4/9] cpuidle: Introduce .abbr (abbrevation) for cpuidle states Thomas Renninger
2011-01-07 21:23 ` Kevin Hilman
2011-01-12 6:56 ` Len Brown
2011-01-12 13:37 ` Thomas Renninger
2011-01-12 22:25 ` Len Brown
2011-01-12 23:39 ` Thomas Renninger
2011-01-13 15:42 ` Valdis.Kletnieks
2011-01-07 10:29 ` [PATCH 5/9] acpi: processor->cpuidle: Only set cpuidle check_bm flag if pr->flags.bm_check is set Thomas Renninger
2011-01-12 7:17 ` Len Brown
2011-01-12 7:30 ` [PATCH] ACPI: processor_idle: delete use of NOP CPUIDLE_FLAGs Len Brown
2011-01-12 7:37 ` [PATCH] cpuidle: delete NOP CPUIDLE_FLAG_POLL Len Brown
2011-01-12 8:00 ` [PATCH] SH, cpuidle: delete use of NOP CPUIDLE_FLAGS_SHALLOW Len Brown
2011-01-12 8:01 ` [PATCH] cpuidle: delete unused CPUIDLE_FLAG_SHALLOW, BALANCED, DEEP definitions Len Brown
2011-01-12 8:02 ` [PATCH] cpuidle: CPUIDLE_FLAG_TLB_FLUSHED is specific to intel_idle Len Brown
2011-01-12 8:04 ` [PATCH] cpuidle: CPUIDLE_FLAG_CHECK_BM is omap3_idle specific Len Brown
2011-01-07 10:29 ` [PATCH 6/9] perf (userspace): Fix variable clash with glibc time() func Thomas Renninger
2011-01-07 10:29 ` [PATCH 7/9] perf (userspace): Introduce --verbose param for perf timechart Thomas Renninger
2011-01-07 10:29 ` [PATCH 8/9] perf timechart: Map power:cpu_idle events to the corresponding cpuidle state Thomas Renninger
2011-01-07 10:52 ` Thomas Renninger
2011-01-07 10:29 ` Thomas Renninger [this message]
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=1294396190-23031-10-git-send-email-trenn@suse.de \
--to=trenn@suse.de \
--cc=arjan@linux.intel.com \
--cc=j-pihet@ti.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@elte.hu \
/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).