From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13087 invoked by alias); 19 Sep 2009 05:01:18 -0000 Received: (qmail 12918 invoked by uid 22791); 19 Sep 2009 05:01:14 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_23,J_CHICKENPOX_35,J_CHICKENPOX_37,J_CHICKENPOX_63 X-Spam-Check-By: sourceware.org Received: from e23smtp08.au.ibm.com (HELO e23smtp08.au.ibm.com) (202.81.31.141) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Sep 2009 05:01:08 +0000 Received: from d23relay01.au.ibm.com (d23relay01.au.ibm.com [202.81.31.243]) by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id n8J4tOim032040 for ; Sat, 19 Sep 2009 14:55:24 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay01.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n8J514CP495626 for ; Sat, 19 Sep 2009 15:01:04 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n8J514uT020155 for ; Sat, 19 Sep 2009 15:01:04 +1000 Received: from localhost ([9.77.125.25]) by d23av04.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n8J512uR020119 for ; Sat, 19 Sep 2009 15:01:03 +1000 Date: Sat, 19 Sep 2009 05:01:00 -0000 From: Rajasekhar Duddu To: systemtap@sources.redhat.com Subject: [PATCH] Tracepoint Tapset for Memory Subsystem Message-ID: <20090919050102.GA3767@rajduddu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00808.txt.bz2 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 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 kmalloc 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 \ + * kmem_cache_alloc 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 kmalloc_node 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 \ + * kmem_cache_alloc_node 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 kfree 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 \ + * kmem_cache_free 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.