From dfb5f085c90cad2f3c61dfb9b17d82006cb02c24 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Fri, 22 Jan 2016 18:40:33 -0500 Subject: [PATCH] Add tapset support for mlock2 syscall in 4.4 aux_syscalls.stp - flags to str function nd_syscalls.stp - add kprobe based syscall probe point syscalls.stp - add kernel function based syscall probe point --- tapset/linux/aux_syscalls.stp | 21 ++++++++++++++++++++- tapset/linux/nd_syscalls.stp | 20 ++++++++++++++++++++ tapset/linux/syscalls.stp | 19 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp index 929396d70..d59ebbfd5 100644 --- a/tapset/linux/aux_syscalls.stp +++ b/tapset/linux/aux_syscalls.stp @@ -1678,15 +1678,34 @@ function _mfd_flags_str:string(flags:long) _stp_lookup_or_str(_stp_mfd_flags_list, flags, STAP_RETVALUE, MAXSTRINGLEN); %} +%{ +#include +static const _stp_val_array const _stp_mlock2_flags_list[] = { +#ifdef MLOCK_ONFAULT + V(MLOCK_ONFAULT), +#endif + {0, NULL} +}; +%} +/* `man mlock2` for more information */ +function _stp_mlock2_str:string(flags:long) +%{ + uint32_t flags = (uint32_t)STAP_ARG_flags; + _stp_lookup_or_str(_stp_mlock2_flags_list, flags, STAP_RETVALUE, + MAXSTRINGLEN); +%} + %{ #include static const _stp_val_array const _stp_mlockall_flags_list[] = { V(MCL_CURRENT), V(MCL_FUTURE), +#ifdef MCL_ONFAULT + V(MCL_ONFAULT), +#endif {0, NULL} }; %} - /* `man mlockall` for more information */ function _mlockall_flags_str:string(flags:long) %{ /* pure */ diff --git a/tapset/linux/nd_syscalls.stp b/tapset/linux/nd_syscalls.stp index b17501de7..ff7e4750f 100644 --- a/tapset/linux/nd_syscalls.stp +++ b/tapset/linux/nd_syscalls.stp @@ -3945,6 +3945,26 @@ probe nd_syscall.mlock.return = kprobe.function("sys_mlock").return ? retstr = returnstr(1) } +# mlock2 _____________________________________________________ +# +# long sys_mlock2(unsigned long start, size_t len, int flags) +# +probe nd_syscall.mlock2 = kprobe.function("sys_mlock2") ? +{ + name = "mlock2" + asmlinkage() + addr = __ulong(1) + len = __ulong(2) + flags = __int32(3) + flags_str = _stp_mlock2_str(__int32(3)) + argstr = sprintf("%p, %u %s", addr, len, flags_str) +} +probe nd_syscall.mlock2.return = kprobe.function("sys_mlock2").return ? +{ + name = "mlock2" + retstr = returnstr(1) +} + # mlockall ___________________________________________________ # # long sys_mlockall(int flags) diff --git a/tapset/linux/syscalls.stp b/tapset/linux/syscalls.stp index d55060027..d93dc7811 100644 --- a/tapset/linux/syscalls.stp +++ b/tapset/linux/syscalls.stp @@ -3710,6 +3710,25 @@ probe syscall.mlock.return = kernel.function("sys_mlock").return ? retstr = return_str(1, $return) } +# mlock2 _____________________________________________________ +# +# long sys_mlock2(unsigned long start, size_t len, int flags) +# +probe syscall.mlock2 = kernel.function("sys_mlock2").call ? +{ + name = "mlock2" + addr = __ulong($start) + len = __ulong($len) + flags = __int32($flags) + flags_str = _stp_mlock2_str(__int32(flags)) + argstr = sprintf("%p, %u %s", addr, len, flags_str) +} +probe syscall.mlock2.return = kernel.function("sys_mlock2").return ? +{ + name = "mlock2" + retstr = return_str(1, $return) +} + # mlockall ___________________________________________________ # # long sys_mlockall(int flags) -- 2.43.5