From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
mingo@kernel.org, jolsa@redhat.com, andres@anarazel.de,
acme@redhat.com, tglx@linutronix.de, peterz@infradead.org,
alexander.shishkin@linux.intel.com, eranian@google.com,
hpa@zytor.com, eranian@gmail.com
Subject: [tip:perf/core] perf/core: Fix PERF_RECORD_MMAP2 prot/flags for anonymous memory
Date: Mon, 30 Jan 2017 03:52:44 -0800 [thread overview]
Message-ID: <tip-0b3589be9b98994ce3d5aeca52445d1f5627c4ba@git.kernel.org> (raw)
In-Reply-To: <20170126221508.GF6536@twins.programming.kicks-ass.net>
Commit-ID: 0b3589be9b98994ce3d5aeca52445d1f5627c4ba
Gitweb: http://git.kernel.org/tip/0b3589be9b98994ce3d5aeca52445d1f5627c4ba
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 26 Jan 2017 23:15:08 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 30 Jan 2017 11:41:26 +0100
perf/core: Fix PERF_RECORD_MMAP2 prot/flags for anonymous memory
Andres reported that MMAP2 records for anonymous memory always have
their protection field 0.
Turns out, someone daft put the prot/flags generation code in the file
branch, leaving them unset for anonymous memory.
Reported-by: Andres Freund <andres@anarazel.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Don Zickus <dzickus@redhat.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@kernel.org
Cc: anton@ozlabs.org
Cc: namhyung@kernel.org
Cc: stable@vger.kernel.org # v3.16+
Fixes: f972eb63b100 ("perf: Pass protection and flags bits through mmap2 interface")
Link: http://lkml.kernel.org/r/20170126221508.GF6536@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/events/core.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4e1f4c0..e5aaa80 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6632,6 +6632,27 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
char *buf = NULL;
char *name;
+ if (vma->vm_flags & VM_READ)
+ prot |= PROT_READ;
+ if (vma->vm_flags & VM_WRITE)
+ prot |= PROT_WRITE;
+ if (vma->vm_flags & VM_EXEC)
+ prot |= PROT_EXEC;
+
+ if (vma->vm_flags & VM_MAYSHARE)
+ flags = MAP_SHARED;
+ else
+ flags = MAP_PRIVATE;
+
+ if (vma->vm_flags & VM_DENYWRITE)
+ flags |= MAP_DENYWRITE;
+ if (vma->vm_flags & VM_MAYEXEC)
+ flags |= MAP_EXECUTABLE;
+ if (vma->vm_flags & VM_LOCKED)
+ flags |= MAP_LOCKED;
+ if (vma->vm_flags & VM_HUGETLB)
+ flags |= MAP_HUGETLB;
+
if (file) {
struct inode *inode;
dev_t dev;
@@ -6658,27 +6679,6 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
maj = MAJOR(dev);
min = MINOR(dev);
- if (vma->vm_flags & VM_READ)
- prot |= PROT_READ;
- if (vma->vm_flags & VM_WRITE)
- prot |= PROT_WRITE;
- if (vma->vm_flags & VM_EXEC)
- prot |= PROT_EXEC;
-
- if (vma->vm_flags & VM_MAYSHARE)
- flags = MAP_SHARED;
- else
- flags = MAP_PRIVATE;
-
- if (vma->vm_flags & VM_DENYWRITE)
- flags |= MAP_DENYWRITE;
- if (vma->vm_flags & VM_MAYEXEC)
- flags |= MAP_EXECUTABLE;
- if (vma->vm_flags & VM_LOCKED)
- flags |= MAP_LOCKED;
- if (vma->vm_flags & VM_HUGETLB)
- flags |= MAP_HUGETLB;
-
goto got_name;
} else {
if (vma->vm_ops && vma->vm_ops->name) {
next prev parent reply other threads:[~2017-01-30 11:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-10 5:02 perf/jit doesn't cope well with mprotect() to jit containing pages Andres Freund
2016-12-12 8:49 ` Peter Zijlstra
2016-12-12 9:01 ` Andres Freund
2016-12-12 9:28 ` Peter Zijlstra
2017-01-26 1:25 ` Andres Freund
2017-01-26 22:15 ` Peter Zijlstra
2017-01-26 23:04 ` Andres Freund
2017-01-30 11:52 ` tip-bot for Peter Zijlstra [this message]
2017-01-26 20:32 ` Stephane Eranian
2017-01-26 21:00 ` Andres Freund
2017-01-26 21:17 ` Stephane Eranian
2017-01-26 21:22 ` Andres Freund
2017-01-26 21:34 ` Stephane Eranian
2017-01-26 21:51 ` Andres Freund
2017-01-26 22:19 ` Peter Zijlstra
2017-01-26 22:26 ` Stephane Eranian
2017-01-26 22:38 ` Andres Freund
2017-01-26 22:51 ` Stephane Eranian
2017-01-26 23:09 ` Andres Freund
2017-01-26 23:16 ` Stephane Eranian
2017-01-27 13:07 ` Peter Zijlstra
2017-01-27 15:43 ` Arnaldo Carvalho de Melo
2017-01-27 17:35 ` Stephane Eranian
2017-01-27 17:38 ` [PATCH] handle munmap records in tools/perf was: " Arnaldo Carvalho de Melo
2017-01-27 17:46 ` Stephane Eranian
2017-01-27 18:05 ` Arnaldo Carvalho de Melo
2017-01-27 18:10 ` Stephane Eranian
2017-01-27 19:18 ` Arnaldo Carvalho de Melo
2017-01-27 19:26 ` Stephane Eranian
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-0b3589be9b98994ce3d5aeca52445d1f5627c4ba@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andres@anarazel.de \
--cc=eranian@gmail.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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