Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1445640
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Mathieu Poirier <mathieu.poirier@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH V2 2/3] perf/core: Update filter only on executable mmap |
| Date | Mon, 18 Jul 2016 18:50:02 +0200 |
| Message-ID | <rWjTY-fe-37@gated-at.bofh.it> (permalink) |
| References | <rWjTY-fe-25@gated-at.bofh.it> |
| X-Original-To | alexander.shishkin@linux.intel.com |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0YKHKNNsrKlBEQGhMpSNuTmgfA4jiNi2zdQ8bg+5fF0=; b=jBngjJqAPzlZVeJihuhGUiyfRfF/X4v6ozL3jR8IRUVAKGVfrCF5dSGm/M7WnUMQHp 4i4fUJO4GSLIHFy97hLW5IE008DIFqHPnRqFHkxV7Y+O/6lTTxVLgtsthRfJjLN2yMj1 CMzZDt6kkRNoruwaiNwN5DdwURd/0dIlmcA2k= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0YKHKNNsrKlBEQGhMpSNuTmgfA4jiNi2zdQ8bg+5fF0=; b=Ky0XliLNevfXtNUv5BEjnFVihscPZ7CFkYZEgmqQYf48+YJ+30knZ6D5rl+daQi4uc vw9DhO7cvAjS97zte5LylN3E1pgnZ0aNoFn94tX5xF3rvp8KbSypt35G4tUFtfPg3A+F q/qIP/aicYZSIBp/jH7x93xNGjIgNPo7ukOMeM1Y7qfXk9LZ2KBMhKFmNGf3Ofj8A377 RGsiR5OTnjg1JwqKe1khjjunTDyi22f05uD+k+cU8W4zGZRU3Z785myiKTXDwxTQh8OH iR6GFYUlr/wziz+eSgJ913XEBGyrYM3OQlM/TW7ScrEN/V8UfTDN5/HS1NYKWJ+nJtHA ne3Q== |
| X-Gm-Message-State | ALyK8tJXxQamXD94hbDdv9vjrihZtpPMqVW4lz3IoYFua8wWCvVRUW2OKyznsvcTK8dJilDM |
| X-Received | by 10.36.125.70 with SMTP id b67mr46985051itc.24.1468860237377; Mon, 18 Jul 2016 09:43:57 -0700 (PDT) |
| X-Mailer | git-send-email 2.7.4 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 83 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, Mathieu Poirier <mathieu.poirier@linaro.org>, "# 4 . 7" <stable@vger.kernel.org> |
| X-Original-Date | Mon, 18 Jul 2016 10:43:06 -0600 |
| X-Original-Message-ID | <1468860187-318-3-git-send-email-mathieu.poirier@linaro.org> |
| X-Original-References | <1468860187-318-1-git-send-email-mathieu.poirier@linaro.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1445640 |
Show key headers only | View raw
Function perf_event_mmap() is called by the MM subsystem each time
part of a binary is loaded in memory. There can be several mapping
for a binary, many times unrelated to the code section.
Each time a section of a binary is mapped address filters are
updated, event when the map doesn't pertain to the code section.
The end result is that filters are configured based on the last map
event that was received rather than the last mapping of the code
segment.
For example if we have an executable 'main' that calls library
'libcstest.so.1.0', and that we want to collect traces on code
that is in that library. The perf cmd line for this scenario
would be:
perf record -e cs_etm// --filter 'filter 0x72c/0x40@/opt/lib/libcstest.so.1.0' --per-thread ./main
Resulting in binaries being mapped this way:
root@linaro-nano:~# cat /proc/1950/maps
00400000-00401000 r-xp 00000000 08:02 33169 /home/linaro/main
00410000-00411000 r--p 00000000 08:02 33169 /home/linaro/main
00411000-00412000 rw-p 00001000 08:02 33169 /home/linaro/main
7fa2464000-7fa2474000 rw-p 00000000 00:00 0
7fa2474000-7fa25a4000 r-xp 00000000 08:02 543 /lib/aarch64-linux-gnu/libc-2.21.so
7fa25a4000-7fa25b3000 ---p 00130000 08:02 543 /lib/aarch64-linux-gnu/libc-2.21.so
7fa25b3000-7fa25b7000 r--p 0012f000 08:02 543 /lib/aarch64-linux-gnu/libc-2.21.so
7fa25b7000-7fa25b9000 rw-p 00133000 08:02 543 /lib/aarch64-linux-gnu/libc-2.21.so
7fa25b9000-7fa25bd000 rw-p 00000000 00:00 0
7fa25bd000-7fa25be000 r-xp 00000000 08:02 38308 /opt/lib/libcstest.so.1.0
7fa25be000-7fa25cd000 ---p 00001000 08:02 38308 /opt/lib/libcstest.so.1.0
7fa25cd000-7fa25ce000 r--p 00000000 08:02 38308 /opt/lib/libcstest.so.1.0
7fa25ce000-7fa25cf000 rw-p 00001000 08:02 38308 /opt/lib/libcstest.so.1.0
7fa25cf000-7fa25eb000 r-xp 00000000 08:02 574 /lib/aarch64-linux-gnu/ld-2.21.so
7fa25ef000-7fa25f2000 rw-p 00000000 00:00 0
7fa25f7000-7fa25f9000 rw-p 00000000 00:00 0
7fa25f9000-7fa25fa000 r--p 00000000 00:00 0 [vvar]
7fa25fa000-7fa25fb000 r-xp 00000000 00:00 0 [vdso]
7fa25fb000-7fa25fc000 r--p 0001c000 08:02 574 /lib/aarch64-linux-gnu/ld-2.21.so
7fa25fc000-7fa25fe000 rw-p 0001d000 08:02 574 /lib/aarch64-linux-gnu/ld-2.21.so
7ff2ea8000-7ff2ec9000 rw-p 00000000 00:00 0 [stack]
root@linaro-nano:~#
Before 'main' can execute 'libcstest.so.1.0' has to be loaded in
memory. Once that has been done perf_event_mmap() has been called
4 times, with the last map starting at address 0x7fa25ce000 and
the address filter configured to start filtering when the
IP has passed over address 0x0x7fa25ce72c (0x7fa25ce000 + 0x72c).
But that is wrong since the code segment for library 'libcstest.so.1.0'
as been mapped at 0x7fa25bd000, resulting in traces not being
collected.
This patch corrects the situation by requesting that address
filters be updated only if the mapped event is for a code
segment.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: <stable@vger.kernel.org> # 4.7
---
kernel/events/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a8371814dbf4..f2bb2a0fae2b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6562,6 +6562,13 @@ static void perf_addr_filters_adjust(struct vm_area_struct *vma)
struct perf_event_context *ctx;
int ctxn;
+ /*
+ * Data tracing isn't supported yet and as such there is no need
+ * to keep track of anything that isn't related to executable code.
+ */
+ if (!(vma->vm_flags & VM_EXEC))
+ return;
+
rcu_read_lock();
for_each_task_context_nr(ctxn) {
ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V2 0/3] perf/core: Miscellaneous fix for address filtering Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-07-18 18:50 +0200 [PATCH V2 2/3] perf/core: Update filter only on executable mmap Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-07-18 18:50 +0200 Re: [PATCH V2 0/3] perf/core: Miscellaneous fix for address filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-07-19 09:40 +0200
csiph-web