* [PATCH] powerpc/syscalls/trace: Fix mmap in syscalls_trace
@ 2017-04-12 6:35 Balbir Singh
2017-04-13 11:23 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Balbir Singh @ 2017-04-12 6:35 UTC (permalink / raw)
To: mpe, linuxppc-dev
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
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
---
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(-)
diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 23be8f1..16fab68 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -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);
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index de04c9f..a877bf8 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -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);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: powerpc/syscalls/trace: Fix mmap in syscalls_trace
2017-04-12 6:35 [PATCH] powerpc/syscalls/trace: Fix mmap in syscalls_trace Balbir Singh
@ 2017-04-13 11:23 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2017-04-13 11:23 UTC (permalink / raw)
To: Balbir Singh, linuxppc-dev
On Wed, 2017-04-12 at 06:35:19 UTC, Balbir Singh wrote:
> 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.
...
>
> Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/9c355917fcf006af47ffaa5ae43a1a
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-13 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 6:35 [PATCH] powerpc/syscalls/trace: Fix mmap in syscalls_trace Balbir Singh
2017-04-13 11:23 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.