This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Tracepoint Tapset for Memory Subsystem


Hi all,
	here I am posting a patch for Memory Tapset based on
kernel Tracepoints. 

This patch adds tracepoint tapset to memory.stp and a testcase 
(mem_tracepoints.stp) which tests if all probes in the
tapset are resolvable .


Signed-off-by: Rajasekhar Duddu <rajduddu@linux.vnet.ibm.com>
diff -rupaN a/tapset/memory.stp b/tapset/memory.stp
--- a/tapset/memory.stp	2009-09-16 14:24:21.000000000 +0200
+++ b/tapset/memory.stp	2009-09-19 06:33:34.000000000 +0200
@@ -195,3 +195,132 @@ probe vm.brk = kernel.function("do_brk")
 probe vm.oom_kill = kernel.function("__oom_kill_task") {
     task = $p
 }
+
+
+/*Function to convert the GFP_FLAGS .*/
+function gfp_f:string (gfp_flag:long)
+%{
+        switch (THIS->gfp_flag) {
+                case 32:
+                        strlcpy(THIS->__retvalue, "GFP_ATOMIC", MAXSTRINGLEN);
+                        break;
+                case 208:
+                        strlcpy(THIS->__retvalue, "GFP_KERNEL", MAXSTRINGLEN);
+                        break;
+                case 16:
+                        strlcpy(THIS->__retvalue, "GFP_NOIO", MAXSTRINGLEN);
+                        break;
+                case 80:
+                        strlcpy(THIS->__retvalue, "GFP_NOFS", MAXSTRINGLEN);
+                        break;
+                case 524496:
+                        strlcpy(THIS->__retvalue, "GFP_TEMPORARY", MAXSTRINGLEN);
+                        break;
+                case 8400:
+                        strlcpy(THIS->__retvalue, "GFP_USER", MAXSTRINGLEN);
+                        break;
+                case 8402:
+                        strlcpy(THIS->__retvalue, "GFP_HIGHUSER", MAXSTRINGLEN);
+                        break;
+                case 8410:
+                       strlcpy(THIS->__retvalue, "GFP_HIGHUSER_MOVABLE", MAXSTRINGLEN);
+                        break;
+                default:
+                        break;
+        }
+
+%}
+
+/**
+ * probe mem.kmalloc - Fires when <command>kmalloc</command> is requested.
+ * @call_site: Address of the memory function.
+ * @bytes_req: Requested Bytes
+ * @bytes_alloc: Allocated Bytes
+ * @gfp_flags: type of memory to allocate
+ * @ptr: Pointer to the memory allocated
+ */
+
+probe mem.kmalloc = kernel.trace("kmalloc") {
+	name = "kmalloc"
+	call_site = symname($call_site)
+	bytes_req = $bytes_req
+	bytes_alloc = $bytes_alloc
+	gfp_flags = gfp_f($gfp_flags)
+	ptr = $ptr
+}
+
+/**
+ * probe mem.kmem_cache_alloc - Fires when \
+ *		<command>kmem_cache_alloc</command> is requested
+ * @call_site: Address of the function calling this memory function
+ * @bytes_req: Requested Bytes
+ * @bytes_alloc: Allocated Bytes
+ * @gfp_flags: Type of memory to allocate
+ * @ptr: Pointer to the memory allocated
+ */
+probe mem.kmem_cache_alloc = kernel.trace("kmem_cache_alloc") {
+	name = "kmem_cache_alloc"
+	call_site = symname($call_site)
+        bytes_req = $bytes_req
+        bytes_alloc = $bytes_alloc
+	gfp_flags = gfp_f($gfp_flags)
+        ptr = $ptr
+}
+
+/**
+ * probe mem.kmalloc_node - Fires when <command>kmalloc_node</command> is requested
+ * @call_site: Address of the function caling this  memory function
+ * @bytes_req: Requested Bytes
+ * @bytes_alloc: Allocated Bytes
+ * @gfp_flags: Type of memory to allocate
+ * @ptr: Pointer to the memory allocated
+ */
+probe mem.kmalloc_node = kernel.trace("kmalloc_node")? {
+	name = "kmalloc_node"
+	call_site = symname($call_site)
+	bytes_req = $bytes_req
+        bytes_alloc = $bytes_alloc
+        gfp_flags = gfp_f($gfp_flags)
+        ptr = $ptr
+}
+
+/**
+ * probe mem.kmem_cache_alloc_node - Fires when \
+ *		<command>kmem_cache_alloc_node</command> is requested
+ * @call_site: Address of the function calling this memory function
+ * @bytes_req: Requested Bytes
+ * @bytes_alloc: Allocated Bytes
+ * @gfp_flags: Type of memory to allocate
+ * @ptr: Pointer to the memory allocated
+ */
+probe mem.kmem_cache_alloc_node = kernel.trace("kmem_cache_alloc_node")? {
+	name = "kmem_cache_alloc_node"
+	call_site = symname($call_site)
+        bytes_req = $bytes_req
+	bytes_alloc = $bytes_alloc
+        gfp_flags =gfp_f($gfp_flags)
+        ptr = $ptr
+}
+
+/**
+ * probe mem.kfree - Fires when <command>kfree</comand> is requested.
+ * @call_site: Address of the function calling this memory function.
+ * @ptr: Pointer to the memory allocated which is returned by kmalloc
+ */
+probe mem.kfree = kernel.trace("kfree") {
+	name = "kfree"
+	call_site = symname($call_site)
+	ptr = $ptr
+}
+
+/**
+ * probe mem.kmem_cache_free - Fires when \
+ *		<command>kmem_cache_free</command> is requested.
+ * @call_site: Address of the function calling this memory function.
+ * @ptr: Pointer to the memory allocated which is returned by kmem_cache
+ */
+probe mem.kmem_cache_free = kernel.trace("kmem_cache_free") {
+	name = "kmem_cache_free"
+	call_site = symname($call_site)
+	ptr = $ptr
+}
diff -rupaN a/testsuite/buildok/mem_tracepoints.stp b/testsuite/buildok/mem_tracepoints.stp
--- a/testsuite/buildok/mem_tracepoints.stp	1970-01-01 01:00:00.000000000 +0100
+++ b/testsuite/buildok/mem_tracepoints.stp	2009-09-19 06:25:06.000000000 +0200
@@ -0,0 +1,35 @@
+#!/usr/bin/stp -up4
+probe mem.kfree {
+	println (name)
+		printf("%-15s %-15s %-15p \n", execname(),call_site,ptr)
+}
+
+probe mem.kmalloc {
+	        println (name)
+		printf("%-15s %-15s %-15p %-15d %-15d %-15s \n", execname(),call_site,ptr,bytes_req,bytes_alloc,gfp_flags)
+}
+
+probe mem.kmem_cache_alloc {
+	        println (name)
+		printf("%-15s %-15s %-15p %-15d %-15d %-15s \n", execname(),call_site,ptr,bytes_req,bytes_alloc,gfp_flags)
+}
+probe mem.kmalloc_node {
+	        println (name)
+		printf("%-15s %-15s %-15p %-15d %-15d %-15s \n", execname(),call_site,ptr,bytes_req,bytes_alloc,gfp_flags)
+}
+
+probe mem.kmem_cache_alloc_node {
+	        println (name)
+		printf("%-15s %-15s %-15p %-15d %-15d %-15s \n", execname(),call_site,ptr,bytes_req,bytes_alloc,gfp_flags)
+}
+
+probe mem.kmem_cache_free {
+	        println (name)
+                printf("%-15s %-15s %-15p \n", execname(),call_site,ptr)
+}
+
+probe timer.s(1) {
+                exit()
+}
+
+

Thanks 
-- 
Rajasekhar Duddu (rajduddu@linux.vnet.ibm.com),
Linux on System z - CSVT, IBM LTC, Bangalore.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]