From: Namhyung Kim <namhyung@kernel.org>
To: Don Zickus <dzickus@redhat.com>
Cc: acme@redhat.com, jolsa@redhat.com, jmario@redhat.com,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] perf: Speed up thread map generation
Date: Mon, 17 Mar 2014 10:45:49 +0900 [thread overview]
Message-ID: <87ob15tx6a.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1394808224-113774-1-git-send-email-dzickus@redhat.com> (Don Zickus's message of "Fri, 14 Mar 2014 10:43:44 -0400")
Hi Don,
On Fri, 14 Mar 2014 10:43:44 -0400, Don Zickus wrote:
> When trying to capture perf data on a system running spejbb2013,
> perf hung for about 15 minutes. This is because it took that
> long to gather about 10,000 thread maps and process them.
>
> I don't think a user wants to wait that long.
>
> Instead, recognize that thread maps are roughly equivalent to
> pid maps and just quickly copy those instead.
>
> To do this, I synthesize 'fork' events, this eventually calls
> thread__fork() and copies the maps over.
>
> The overhead goes from 15 minutes down to about a few seconds.
[SNIP]
> @@ -416,6 +453,10 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
> if (mmap_event == NULL)
> goto out_free_comm;
>
> + fork_event = malloc(sizeof(fork_event->fork) + machine->id_hdr_size);
> + if (fork_event == NULL)
> + goto out_free_mmap;
> +
> if (machine__is_default_guest(machine))
> return 0;
Not related to this patch, but this will causes a memory leak..
So I think below patch is needed on top (not sure it's also needed for
perf_event__synthesize_thread_map() too).
>From 3c4b49b4f540c7d49ee78364b02faa0bfce59c67 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <namhyung@kernel.org>
Date: Mon, 17 Mar 2014 10:23:06 +0900
Subject: [PATCH] perf tools: Fix a possible memory leak
Checking default guest machine should be done before allocating event
structures otherwise it'll leak memory.
Cc: Don Zickus <dzickus@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/event.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 3e580be0f6fb..eab930d28159 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -445,6 +445,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
union perf_event *comm_event, *mmap_event, *fork_event;
int err = -1;
+ if (machine__is_default_guest(machine))
+ return 0;
+
comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
if (comm_event == NULL)
goto out;
@@ -457,9 +460,6 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
if (fork_event == NULL)
goto out_free_mmap;
- if (machine__is_default_guest(machine))
- return 0;
-
snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
proc = opendir(proc_path);
--
1.7.11.7
next prev parent reply other threads:[~2014-03-17 1:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 14:43 Don Zickus
2014-03-14 16:12 ` Jiri Olsa
2014-03-17 1:45 ` Namhyung Kim [this message]
2014-03-18 13:43 ` Arnaldo Carvalho de Melo
2014-03-18 14:20 ` Namhyung Kim
2014-03-19 13:07 ` [tip:perf/core] perf tools: Fix memory leak when synthesizing thread records tip-bot for Namhyung Kim
2014-03-18 8:31 ` [tip:perf/core] perf tools: Speed up thread map generation tip-bot for Don Zickus
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=87ob15tx6a.fsf@sejong.aot.lge.com \
--to=namhyung@kernel.org \
--cc=acme@redhat.com \
--cc=dzickus@redhat.com \
--cc=jmario@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome