From 11c015d84facc299ebcb12771ccda1975333a6bc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 29 Dec 2009 21:05:55 +0100 Subject: [PATCH] Fixup some memory tapset vm kernel function probe fallbacks. Older kernels don't have all GFP constants defined, and the fallback kernel function probe fallbacks don't have the same dwarf variable names as the kernel trace point probes. So replace them with variables that are available. bytes_alloc was sometimes a long and sometimes a string, this caused scripts to fail depending on which alternative was chosen for a particular kernel. So make it a long always. This isn't a full solution since kmalloc is always inlined which makes the kernel.function("kmalloc").return probe fail. * tapset/memory.stp: Define __GFP_THISNODE, __GFP_RECLAIMABLE, GFP_TEMPORARY, GFP_HIGHUSER_MOVABLE and GFP_THISNODE when not yet defined. (__vm.kmalloc.kp): Use $flags, not $gfp_flags. Set bytes_alloc equal to bytes_req. (__vm.kmem_cache_alloc.kp): Likewise. And use $cachep->buffer_size for bytes_req. (__vm.kmalloc_node.kp): Likewise. (__vm.kmem_cache_alloc_node.kp): Likewise. (__vm.kfree.kp): Use $ibjp for ptr, not $return. (__vm.kmem_cache_free.kp): Likewise. * testsuite/buildok/vm.tracepoints.stp: Move vm.kmalloc test to... * testsuite/buildok/vm.tracepoints.kmalloc.stp: ... here. --- tapset/memory.stp | 59 ++++++++++++++------ testsuite/buildok/vm.tracepoints.kmalloc.stp | 9 +++ testsuite/buildok/vm.tracepoints.stp | 5 +- 3 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 testsuite/buildok/vm.tracepoints.kmalloc.stp diff --git a/tapset/memory.stp b/tapset/memory.stp index bd71a386d..c170c5c74 100644 --- a/tapset/memory.stp +++ b/tapset/memory.stp @@ -217,6 +217,33 @@ function __gfp_flag_str:string(gfp_flag:long) %{ #endif #endif +#ifndef __GFP_THISNODE +#define __GFP_THISNODE ((__force gfp_t)0x40000u) +#endif + +#ifndef __GFP_RECLAIMABLE +#define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) +#endif + +#ifndef GFP_TEMPORARY +#define GFP_TEMPORARY (__GFP_WAIT | __GFP_IO | __GFP_FS | \ + __GFP_RECLAIMABLE) +#endif + +#ifndef GFP_HIGHUSER_MOVABLE +#define GFP_HIGHUSER_MOVABLE (__GFP_WAIT | __GFP_IO | __GFP_FS | \ + __GFP_HARDWALL | __GFP_HIGHMEM | \ + __GFP_MOVABLE) +#endif + +#ifndef GFP_THISNODE +#ifdef CONFIG_NUMA +#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY) +#else +#define GFP_THISNODE ((__force gfp_t)0) +#endif +#endif + /* Macro for GFP Bitmasks. */ /* The resulted GFP_FLAGS may be either single or concatenation of the multiple bitmasks. */ @@ -298,9 +325,9 @@ probe __vm.kmalloc.kp = kernel.function("kmalloc").return { call_site = 0 caller_function = "unknown" bytes_req = $size - bytes_alloc = "unknown" - gfp_flags = $gfp_flags - gfp_flag_name = __gfp_flag_str($gfp_flags) + bytes_alloc = bytes_req // pretend they are always the same + gfp_flags = $flags + gfp_flag_name = __gfp_flag_str(gfp_flags) ptr = $return } @@ -334,10 +361,10 @@ probe __vm.kmem_cache_alloc.kp = kernel.function("kmem_cache_alloc").return { name = "kmem_cache_alloc" call_site = 0 caller_function = "unknown" - bytes_req = $size - bytes_alloc = "unknown" - gfp_flags = $gfp_flags - gfp_flag_name = __gfp_flag_str($gfp_flags) + bytes_req = $cachep->buffer_size + bytes_alloc = bytes_req // pretend they are always the same + gfp_flags = $flags + gfp_flag_name = __gfp_flag_str(gfp_flags) ptr = $return } @@ -373,9 +400,9 @@ probe __vm.kmalloc_node.kp = kernel.function("kmalloc_node").return? { call_site = 0 caller_function = "unknown" bytes_req = $size - bytes_alloc = "unknown" - gfp_flags = $gfp_flags - gfp_flag_name = __gfp_flag_str($gfp_flags) + bytes_alloc = bytes_req // pretend they are always the same + gfp_flags = $flags + gfp_flag_name = __gfp_flag_str(gfp_flags) ptr = $return } @@ -408,10 +435,10 @@ probe __vm.kmem_cache_alloc_node.kp = kernel.function("kmem_cache_alloc_node").r name = "kmem_cache_alloc_node" call_site = 0 caller_function = "unknown" - bytes_req = $size - bytes_alloc = "unknown" - gfp_flags = $gfp_flags - gfp_flag_name = __gfp_flag_str($gfp_flags) + bytes_req = $cachep->buffer_size + bytes_alloc = bytes_req // pretend they are always the same + gfp_flags = $flags + gfp_flag_name = __gfp_flag_str(gfp_flags) ptr = $return } @@ -442,7 +469,7 @@ probe __vm.kfree.kp = kernel.function("kfree").return { name = "kfree" call_site = 0 caller_function = "unknown" - ptr = $return + ptr = $objp } /** @@ -465,7 +492,7 @@ probe __vm.kmem_cache_free.kp = kernel.function("kmem_cache_free").return { name = "kmem_cache_free" call_site = 0 caller_function = "unknown" - ptr = $return + ptr = $objp } /** * probe vm.kmem_cache_free - Fires when \ diff --git a/testsuite/buildok/vm.tracepoints.kmalloc.stp b/testsuite/buildok/vm.tracepoints.kmalloc.stp new file mode 100644 index 000000000..f723737c6 --- /dev/null +++ b/testsuite/buildok/vm.tracepoints.kmalloc.stp @@ -0,0 +1,9 @@ +#! stap -up4 + +/* All other tracepoint memory probes are in another test vm.tracepoints.stp */ + +probe vm.kmalloc { + println(name) + printf("%-15s %-15p %-15s %-15p %-15d %-15d %-15d %-15s \n", execname(), call_site, caller_function, ptr, bytes_req, bytes_alloc, gfp_flags, gfp_flag_name) +} + diff --git a/testsuite/buildok/vm.tracepoints.stp b/testsuite/buildok/vm.tracepoints.stp index 488ca0fc9..6ed747d70 100644 --- a/testsuite/buildok/vm.tracepoints.stp +++ b/testsuite/buildok/vm.tracepoints.stp @@ -5,10 +5,7 @@ probe vm.kfree { printf("%-15s %-15p %-15s %-15p \n", execname(), call_site, caller_function, ptr) } -probe vm.kmalloc { - println(name) - printf("%-15s %-15p %-15s %-15p %-15d %-15d %-15d %-15s \n", execname(), call_site, caller_function, ptr, bytes_req, bytes_alloc, gfp_flags, gfp_flag_name) -} +/* vm.kmalloc is in a separate test vm.tracepoints.kmalloc.stp */ probe vm.kmem_cache_alloc { println(name) -- 2.43.5