Skip to content

Commit 0b3589b

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Don Zickus <[email protected] Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] # v3.16+ Fixes: f972eb6 ("perf: Pass protection and flags bits through mmap2 interface") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent a76a82a commit 0b3589b

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

kernel/events/core.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6632,6 +6632,27 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
66326632
char *buf = NULL;
66336633
char *name;
66346634

6635+
if (vma->vm_flags & VM_READ)
6636+
prot |= PROT_READ;
6637+
if (vma->vm_flags & VM_WRITE)
6638+
prot |= PROT_WRITE;
6639+
if (vma->vm_flags & VM_EXEC)
6640+
prot |= PROT_EXEC;
6641+
6642+
if (vma->vm_flags & VM_MAYSHARE)
6643+
flags = MAP_SHARED;
6644+
else
6645+
flags = MAP_PRIVATE;
6646+
6647+
if (vma->vm_flags & VM_DENYWRITE)
6648+
flags |= MAP_DENYWRITE;
6649+
if (vma->vm_flags & VM_MAYEXEC)
6650+
flags |= MAP_EXECUTABLE;
6651+
if (vma->vm_flags & VM_LOCKED)
6652+
flags |= MAP_LOCKED;
6653+
if (vma->vm_flags & VM_HUGETLB)
6654+
flags |= MAP_HUGETLB;
6655+
66356656
if (file) {
66366657
struct inode *inode;
66376658
dev_t dev;
@@ -6658,27 +6679,6 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
66586679
maj = MAJOR(dev);
66596680
min = MINOR(dev);
66606681

6661-
if (vma->vm_flags & VM_READ)
6662-
prot |= PROT_READ;
6663-
if (vma->vm_flags & VM_WRITE)
6664-
prot |= PROT_WRITE;
6665-
if (vma->vm_flags & VM_EXEC)
6666-
prot |= PROT_EXEC;
6667-
6668-
if (vma->vm_flags & VM_MAYSHARE)
6669-
flags = MAP_SHARED;
6670-
else
6671-
flags = MAP_PRIVATE;
6672-
6673-
if (vma->vm_flags & VM_DENYWRITE)
6674-
flags |= MAP_DENYWRITE;
6675-
if (vma->vm_flags & VM_MAYEXEC)
6676-
flags |= MAP_EXECUTABLE;
6677-
if (vma->vm_flags & VM_LOCKED)
6678-
flags |= MAP_LOCKED;
6679-
if (vma->vm_flags & VM_HUGETLB)
6680-
flags |= MAP_HUGETLB;
6681-
66826682
goto got_name;
66836683
} else {
66846684
if (vma->vm_ops && vma->vm_ops->name) {

0 commit comments

Comments
 (0)