powerpc/syscalls/trace: Fix mmap in syscalls_trace
PATCH 1/1 powerpc/syscalls/trace: Fix mmap in syscalls_trace
This patch uses SYSCALL_DEFINE6 for sys_mmap and sys_mmap2 so that the meta-data associated with these syscalls is visible to the syscall tracer. In the absence of this generic syscalls (defined outside arch) like munmap,etc. are visible in available_events, syscall_enter_mmap and syscall_exit_mmap is not.
A side-effect of this change is that the return type has changed from unsigned long to long.
Prior to these changes, we had, under /sys/kernel/tracing
cat available_events | grep syscalls | grep map syscalls:sys_exit_remap_file_pages syscalls:sys_enter_remap_file_pages syscalls:sys_exit_munmap syscalls:sys_enter_munmap syscalls:sys_exit_mremap syscalls:sys_enter_mremap
After these changes we have mmap in available_events.
cat available_events | grep syscalls | grep map syscalls:sys_exit_mmap
syscalls:sys_enter_mmap syscalls:sys_exit_remap_file_pages syscalls:sys_enter_remap_file_pages syscalls:sys_exit_munmap syscalls:sys_enter_munmap syscalls:sys_exit_mremap syscalls:sys_enter_mremap
Sample trace:
cat-3399 [001] .... 196.542410: sys_mmap(addr: 7fff922a0000, len: 20000, prot: 3, flags: 812, fd: 3, offset: 1b0000)
cat-3399 [001] .... 196.542443: sys_mmap -> 0x7fff922a0000
cat-3399 [001] .... 196.542668: sys_munmap(addr: 7fff922c0000, len: 6d2c)
cat-3399 [001] .... 196.542677: sys_munmap -> 0x0---
Changelog:
Removed RFC
Fixed len from unsigned long to size_t
Added some examples of use of mmap trace
arch/powerpc/include/asm/syscalls.h | 4 ++-- arch/powerpc/kernel/syscalls.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/syscalls.h +2 -2
@@ -8,10 +8,10 @@struct rtas_args ; -asmlinkage unsigned long sys_mmap (unsigned long addr,size_t len, +asmlinkage long sys_mmap (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,off_t offset); -asmlinkage unsigned long sys_mmap2 (unsigned long addr,size_t len, +asmlinkage long sys_mmap2 (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long pgoff);asmlinkage long ppc64_personality (unsigned long personality);
arch/powerpc/kernel/syscalls.c +8 -8
@@ -42,11 +42,11 @@#include <asm/unistd.h> #include <asm/asm-prototypes.h> -static inline unsigned long do_mmap2 (unsigned long addr,size_t len, +static inline long do_mmap2 (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long off,int shift) { -unsigned long ret = -EINVAL ; +long ret = -EINVAL ;if (!arch_validate_prot (prot)) goto out;
@@ -62,16 +62,16 @@ static inline unsigned long do_mmap2(unsigned long addr, size_t len,return ret; } -unsigned long sys_mmap2 (unsigned long addr,size_t len, -unsigned long prot,unsigned long flags, -unsigned long fd,unsigned long pgoff) +SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len, + unsigned long, prot, unsigned long, flags, + unsigned long, fd, unsigned long, pgoff) {return do_mmap2 (addr, len, prot, flags, fd, pgoff,PAGE_SHIFT -12 ); } -unsigned long sys_mmap (unsigned long addr,size_t len, -unsigned long prot,unsigned long flags, -unsigned long fd,off_t offset) +SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len, + unsigned long, prot, unsigned long, flags, + unsigned long, fd, off_t, offset) {return do_mmap2 (addr, len, prot, flags, fd, offset,PAGE_SHIFT ); }
Signature · 1 line
2.9.3
Michael Ellerman
AppliedQuoted 9 lines · Balbir Singh
This patch uses
SYSCALL_DEFINE6forsys_mmapandsys_mmap2so that the meta-data associated with these syscalls is visible to the syscall tracer. In the absence of this generic syscalls (defined outside arch) like munmap,etc. are visible inavailable_events,syscall_enter_mmapandsyscall_exit_mmapis not.A side-effect of this change is that the return type has changed from unsigned long to long.
...
Quoted 2 lines
Signed-off-by Balbir Singh <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/9c355917fcf006af47ffaa5ae43a1a
cheers