From: tip-bot for Konstantin Khlebnikov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: alexander.shishkin@linux.intel.com, khlebnikov@yandex-team.ru,
peterz@infradead.org, linux-kernel@vger.kernel.org,
namhyung@kernel.org, hpa@zytor.com, tglx@linutronix.de,
acme@redhat.com, jolsa@kernel.org, mingo@kernel.org
Subject: [tip:perf/urgent] perf map: Synthesize maps only for thread group leader
Date: Sat, 18 Aug 2018 04:41:55 -0700 [thread overview]
Message-ID: <tip-e5adfc3e7e774ba86f7bb725c6eef5f32df8630e@git.kernel.org> (raw)
In-Reply-To: <153363294102.396323.6277944760215058174.stgit@buzz>
Commit-ID: e5adfc3e7e774ba86f7bb725c6eef5f32df8630e
Gitweb: https://git.kernel.org/tip/e5adfc3e7e774ba86f7bb725c6eef5f32df8630e
Author: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
AuthorDate: Tue, 7 Aug 2018 12:09:01 +0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Aug 2018 15:55:59 -0300
perf map: Synthesize maps only for thread group leader
Threads share map_groups, all map events are merged into it.
Thus we could send mmaps only for thread group leader. Otherwise it
took ages to attach and record something from processes with many vmas
and threads.
Thread group leader could be already dead, but it seems perf cannot
handle this case anyway.
Testing dummy:
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <pthread.h>
#include <unistd.h>
void *thread(void *arg) {
pause();
}
int main(int argc, char **argv) {
int threads = 10000;
int vmas = 50000;
pthread_t th;
for (int i = 0; i < threads; i++)
pthread_create(&th, NULL, thread, NULL);
for (int i = 0; i < vmas; i++)
mmap(NULL, 4096, (i & 1) ? PROT_READ : PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
sleep(60);
return 0;
}
Comment by Jiri Olsa:
We actualy synthesize the group leader (if we found one) for the thread
even if it's not present in the thread_map, so the process maps are
always in data.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/153363294102.396323.6277944760215058174.stgit@buzz
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/event.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 0c8ecf0c78a4..0cd42150f712 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -541,10 +541,17 @@ static int __event__synthesize_thread(union perf_event *comm_event,
tgid, process, machine) < 0)
return -1;
+ /*
+ * send mmap only for thread group leader
+ * see thread__init_map_groups
+ */
+ if (pid == tgid &&
+ perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
+ process, machine, mmap_data,
+ proc_map_timeout))
+ return -1;
- return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
- process, machine, mmap_data,
- proc_map_timeout);
+ return 0;
}
if (machine__is_default_guest(machine))
prev parent reply other threads:[~2018-08-18 11:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 9:09 [PATCH 1/2] perf map: synthesize maps only for thread group leader Konstantin Khlebnikov
2018-08-07 9:09 ` [PATCH 2/2] perf map: optimize maps__fixup_overlappings() Konstantin Khlebnikov
2018-08-07 12:55 ` Jiri Olsa
2018-08-07 13:15 ` Arnaldo Carvalho de Melo
2018-08-07 14:24 ` [PATCH v2] " Konstantin Khlebnikov
2018-08-07 20:02 ` Arnaldo Carvalho de Melo
2018-08-07 23:03 ` Jiri Olsa
2018-08-08 12:40 ` Arnaldo Carvalho de Melo
2018-08-18 11:42 ` [tip:perf/urgent] perf map: Optimize maps__fixup_overlappings() tip-bot for Konstantin Khlebnikov
2018-08-07 12:43 ` [PATCH 1/2] perf map: synthesize maps only for thread group leader Jiri Olsa
2018-08-07 13:15 ` Arnaldo Carvalho de Melo
2018-08-18 11:41 ` tip-bot for Konstantin Khlebnikov [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=tip-e5adfc3e7e774ba86f7bb725c6eef5f32df8630e@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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