From ea549ffc2915aa58861637472b12196222673fa2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 21 Dec 2009 13:02:19 +0100 Subject: PR11015 Support shared library reloading (in different processes) * runtime/task_finder_vma.c (stap_remove_vma_map_info): Return negative status on failure. (stap_find_vma_map_info): Likewise. (stap_find_vma_map_info_user): New function. (stap_drop_vma_maps): New function. * runtime/sym.h (addr): Renamed to static_addr, to store addresses for sections which are always mapped at the same address. (_stp_module_relocate): Add extra struct task_struct *tsk argument. * runtime/sym.c (_stp_tf_exec_cb): New callback, calls stap_drop_vma_maps. (_stp_tf_mmap_cb): Don't store address in module.section, but call stap_add_vma_map_info() per tsk->group_leader for matched module. Don't register empty/null modules. (_stp_module_relocate): Take extra struct task_struct *tsk argument, cache last tsk used. Only use section->static_addr for none dynamic modules. Use stap_find_vma_map_info_user() to locate dynamic modules. (_stp_mod_sec_lookup): Add extra argument unsigned long *rel_addr to optionally store relative address when module/section found. (_stp_kallsyms_lookup): Use _stp_mod_sec_lookup to find relative address. (_stp_sym_init): Register _stp_tf_exec_cb in stap_task_finder_target. Add error check to see if task finder could be initialized. * dwflpp.cxx (emit_address): Pass NULL for kernel/modules and current for user tasks to _stp_module_relocate. * runtime/transport/symbols.c (_stp_do_relocation): Set new static_addr _stp_section field. * runtime/unwind.c (adjustStartLoc): Take new struct task_struct *tsk argument and pass to stap_find_vma_map_info_user and _stp_module_relocate to find adjusted addr. (_stp_search_unwind_hdr): Pass through struct task_struct *tsk. (unwind_frame): Likewise. * tapset/context-symbols.stp (probemod): Add NULL to _stp_mod_sec_lookup call to indicate we aren't interested in relative address. * tapsets.cxx (dwarf_derived_probe_group::emit_module_init): Pass NULL to _stp_module_relocate to indicate kernel/module address. --- tapset/context-symbols.stp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tapset') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 6cd4dcbb..38900196 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -91,7 +91,7 @@ function probemod:string () %{ /* pure */ *dst = 0; } else if (CONTEXT->regs) { struct _stp_module *m; - m = _stp_mod_sec_lookup (REG_IP(CONTEXT->regs), current, NULL); + m = _stp_mod_sec_lookup (REG_IP(CONTEXT->regs), current, NULL, NULL); if (m && m->name) strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN); else @@ -111,7 +111,7 @@ function probemod:string () %{ /* pure */ */ function modname:string (addr: long) %{ /* pure */ struct _stp_module *m; - m = _stp_mod_sec_lookup (THIS->addr, current, NULL); + m = _stp_mod_sec_lookup (THIS->addr, current, NULL, NULL); if (m && m->name) strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN); else -- cgit From d5d6f6f18b4ed3e2cd02b6a6a0740938582df89b Mon Sep 17 00:00:00 2001 From: Rajasekhar Duddu Date: Tue, 22 Dec 2009 12:10:24 +0530 Subject: Tracepoint based tapset for memory - changes to NEWS and tapset/memory.stp that got left out in earlier commit 0c487e433fd6343e49b1e9dbc6492f38cfe26143. --- tapset/memory.stp | 266 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) (limited to 'tapset') diff --git a/tapset/memory.stp b/tapset/memory.stp index c6d3ec8f..3f44f9df 100644 --- a/tapset/memory.stp +++ b/tapset/memory.stp @@ -195,3 +195,269 @@ probe vm.brk = kernel.function("do_brk") { probe vm.oom_kill = kernel.function("__oom_kill_task") { task = $p } + +function __gfp_flag_str:string(gfp_flag:long) %{ + long gfp_flag = THIS->gfp_flag; + THIS->__retvalue[0] = '\0'; + + +/* Macro for GFP Bitmasks. */ +/* The resulted GFP_FLAGS may be either single or concatenation of the multiple bitmasks. */ + + +#define __GFP_BITMASKS(FLAG) if(gfp_flag & FLAG) { if(THIS->__retvalue[0] != '\0') \ + strlcat(THIS->__retvalue, " | "#FLAG, MAXSTRINGLEN); \ + else strlcat(THIS->__retvalue, #FLAG, MAXSTRINGLEN); } + + +/* Macro for Composite Flags. */ +/* Each Composite GFP_FLAG is the combination of multiple bitmasks. */ + + +#define __GFP_COMPOSITE_FLAG(FLAG) if(gfp_flag == FLAG) { \ + strlcat(THIS->__retvalue, #FLAG, MAXSTRINGLEN); return; } + + +/* Composite GFP FLAGS of the BitMasks. */ + + __GFP_COMPOSITE_FLAG(GFP_ZONEMASK) + __GFP_COMPOSITE_FLAG(GFP_ATOMIC) + __GFP_COMPOSITE_FLAG(GFP_NOIO) + __GFP_COMPOSITE_FLAG(GFP_NOFS) + __GFP_COMPOSITE_FLAG(GFP_KERNEL) + __GFP_COMPOSITE_FLAG(GFP_TEMPORARY) + __GFP_COMPOSITE_FLAG(GFP_USER) + __GFP_COMPOSITE_FLAG(GFP_HIGHUSER) + __GFP_COMPOSITE_FLAG(GFP_HIGHUSER_MOVABLE) + __GFP_COMPOSITE_FLAG(GFP_THISNODE) + __GFP_COMPOSITE_FLAG(GFP_DMA) + __GFP_COMPOSITE_FLAG(GFP_DMA32) + +/* GFP BitMasks */ + + __GFP_BITMASKS(__GFP_DMA) + __GFP_BITMASKS(__GFP_HIGHMEM) + __GFP_BITMASKS(__GFP_MOVABLE) + __GFP_BITMASKS(__GFP_WAIT) + __GFP_BITMASKS(__GFP_HIGH) + __GFP_BITMASKS(__GFP_IO) + __GFP_BITMASKS(__GFP_FS) + __GFP_BITMASKS(__GFP_COLD) + __GFP_BITMASKS(__GFP_NOWARN) + __GFP_BITMASKS(__GFP_REPEAT) + __GFP_BITMASKS(__GFP_NOFAIL) + __GFP_BITMASKS(__GFP_COMP) + __GFP_BITMASKS(__GFP_ZERO) + __GFP_BITMASKS(__GFP_NOMEMALLOC) + __GFP_BITMASKS(__GFP_HARDWALL) + __GFP_BITMASKS(__GFP_THISNODE) + __GFP_BITMASKS(__GFP_RECLAIMABLE) + __GFP_BITMASKS(__GFP_NOTRACK) + + +#undef __GFP_BITMASKS +#undef __GFP_COMPOSITE_FLAG +%} + +/* The Formal Parameters will be displayed if available, otherwise \ + "0" or "unknown" will be displayed */ + +probe __vm.kmalloc.tp = kernel.trace("kmalloc") { + name = "kmalloc" + call_site = $call_site + caller_function = symname(call_site) + bytes_req = $bytes_req + bytes_alloc = $bytes_alloc + gfp_flags = $gfp_flags + gfp_flag_name = __gfp_flag_str($gfp_flags) + ptr = $ptr +} + +/* It is unsafe to invoke __builtin_return_address() \ +presently(to get call_site for kprobe based probes) \ +and that it can be improved later when fix for bugs bz#6961 and bz#6580 is available. */ + +probe __vm.kmalloc.kp = kernel.function("kmalloc").return { + name = "kmalloc" + call_site = 0 + caller_function = "unknown" + bytes_req = $size + bytes_alloc = "unknown" + gfp_flags = $gfp_flags + gfp_flag_name = __gfp_flag_str($gfp_flags) + ptr = $return +} + +/** + * probe vm.kmalloc - Fires when kmalloc is requested. + * @call_site: Address of the kmemory function. + * @caller_function: Name of the caller function. + * @bytes_req: Requested Bytes + * @bytes_alloc: Allocated Bytes + * @gfp_flags: type of kmemory to allocate + * @gfp_flag_name: type of kmemory to allocate (in String format) + * @ptr: Pointer to the kmemory allocated + */ +probe vm.kmalloc = __vm.kmalloc.tp !, + __vm.kmalloc.kp +{} + + +probe __vm.kmem_cache_alloc.tp = kernel.trace("kmem_cache_alloc") { + name = "kmem_cache_alloc" + call_site = $call_site + caller_function = symname(call_site) + bytes_req = $bytes_req + bytes_alloc = $bytes_alloc + gfp_flags = $gfp_flags + gfp_flag_name = __gfp_flag_str($gfp_flags) + ptr = $ptr +} + +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) + ptr = $return +} + +/** + * probe vm.kmem_cache_alloc - Fires when \ + * kmem_cache_alloc is requested. + * @call_site: Address of the function calling this kmemory function. + * @caller_function: Name of the caller function. + * @bytes_req: Requested Bytes + * @bytes_alloc: Allocated Bytes + * @gfp_flags: type of kmemory to allocate + * @gfp_flag_name: Type of kmemory to allocate(in string format) + * @ptr: Pointer to the kmemory allocated + */ + +probe vm.kmem_cache_alloc = __vm.kmem_cache_alloc.tp !, + __vm.kmem_cache_alloc.kp +{} + +probe __vm.kmalloc_node.tp = kernel.trace("kmalloc_node")? { + name = "kmalloc_node" + call_site = $call_site + caller_function = symname(call_site) + bytes_req = $bytes_req + bytes_alloc = $bytes_alloc + gfp_flags = $gfp_flags + gfp_flag_name = __gfp_flag_str($gfp_flags) + ptr = $ptr +} + +probe __vm.kmalloc_node.kp = kernel.function("kmalloc_node").return? { + name = "kmalloc_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) + ptr = $return +} + +/** + * probe vm.kmalloc_node - Fires when kmalloc_node is requested. + * @call_site: Address of the function caling this kmemory function. + * @caller_function: Name of the caller function. + * @bytes_req: Requested Bytes + * @bytes_alloc: Allocated Bytes + * @gfp_flags: type of kmemory to allocate + * @gfp_flag_name: Type of kmemory to allocate(in string format) + * @ptr: Pointer to the kmemory allocated + */ +probe vm.kmalloc_node = __vm.kmalloc_node.tp !, + __vm.kmalloc_node.kp +{} + +probe __vm.kmem_cache_alloc_node.tp = kernel.trace("kmem_cache_alloc_node")? { + name = "kmem_cache_alloc_node" + call_site = $call_site + caller_function = symname(call_site) + bytes_req = $bytes_req + bytes_alloc = $bytes_alloc + gfp_flags = $gfp_flags + gfp_flag_name = __gfp_flag_str($gfp_flags) + ptr = $ptr +} + +probe __vm.kmem_cache_alloc_node.kp = kernel.function("kmem_cache_alloc_node").return? { + 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) + ptr = $return +} + +/** + * probe vm.kmem_cache_alloc_node - Fires when \ + * kmem_cache_alloc_node is requested. + * @call_site: Address of the function calling this kmemory function. + * @caller_function: Name of the caller function. + * @bytes_req: Requested Bytes + * @bytes_alloc: Allocated Bytes + * @gfp_flags: type of kmemory to allocate + * @gfp_flag_name: Type of kmemory to allocate(in string format) + * @ptr: Pointer to the kmemory allocated + */ +probe vm.kmem_cache_alloc_node = __vm.kmem_cache_alloc_node.tp !, + __vm.kmem_cache_alloc_node.kp +{} + + +probe __vm.kfree.tp = kernel.trace("kfree") { + name = "kfree" + call_site = $call_site + caller_function = symname(call_site) + ptr = $ptr +} + +probe __vm.kfree.kp = kernel.function("kfree").return { + name = "kfree" + call_site = 0 + caller_function = "unknown" + ptr = $return +} + +/** + * probe vm.kfree - Fires when kfree is requested. + * @call_site: Address of the function calling this kmemory function. + * @caller_function: Name of the caller function. + * @ptr: Pointer to the kmemory allocated which is returned by kmalloc + */ +probe vm.kfree = __vm.kfree.tp !, + __vm.kfree.kp +{} + +probe __vm.kmem_cache_free.tp = kernel.trace("kmem_cache_free") { + name = "kmem_cache_free" + call_site = $call_site + caller_function = symname(call_site) + ptr = $ptr +} +probe __vm.kmem_cache_free.kp = kernel.function("kmem_cache_free").return { + name = "kmem_cache_free" + call_site = 0 + caller_function = "unknown" + ptr = $return +} +/** + * probe vm.kmem_cache_free - Fires when \ + * kmem_cache_free is requested. + * @call_site: Address of the function calling this kmemory function. + * @caller_function: Name of the caller function. + * @ptr: Pointer to the kmemory allocated which is returned by kmem_cache + */ +probe vm.kmem_cache_free = __vm.kmem_cache_free.tp !, + __vm.kmem_cache_free.kp +{} -- cgit From 3bd556fd59f403d962ea9a203c46451332b0ee46 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Tue, 22 Dec 2009 14:25:00 +0800 Subject: Update tapset related to struct inet_sock for 2.6.33 * tapset/inet_sock.stp : Add prefix "inet_" to field. * tapset/ip.stp : Ditto. * tapset/tcp.stp : Ditto. * tapset/tcpmib.stp : Ditto. --- tapset/inet_sock.stp | 8 ++++++++ tapset/ip.stp | 8 ++++++++ tapset/tcp.stp | 8 ++++++++ tapset/tcpmib.stp | 16 ++++++++++++++++ 4 files changed, 40 insertions(+) (limited to 'tapset') diff --git a/tapset/inet_sock.stp b/tapset/inet_sock.stp index 33de9775..3962f5a1 100644 --- a/tapset/inet_sock.stp +++ b/tapset/inet_sock.stp @@ -16,7 +16,11 @@ function inet_get_local_port:long(sock:long) %(kernel_v < "2.6.11" %? port = @cast(sock, "inet_sock", "kernel")->inet->num; %: +%(kernel_v < "2.6.33" %? port = @cast(sock, "inet_sock", "kernel")->num; +%: + port = @cast(sock, "inet_sock", "kernel")->inet_num; +%) %) return port; } @@ -27,7 +31,11 @@ function inet_get_ip_source:string(sock:long) %(kernel_v < "2.6.11" %? daddr = @cast(sock, "inet_sock", "kernel")->inet->daddr; %: +%(kernel_v < "2.6.33" %? daddr = @cast(sock, "inet_sock", "kernel")->daddr; +%: + daddr = @cast(sock, "inet_sock", "kernel")->inet_daddr; +%) %) return daddr_to_string(daddr); } diff --git a/tapset/ip.stp b/tapset/ip.stp index 299d88d2..ec17b7c0 100644 --- a/tapset/ip.stp +++ b/tapset/ip.stp @@ -26,13 +26,21 @@ function ip_ntop:string (addr:long) /* return the source IP address for a given sock */ function __ip_sock_saddr:long (sock:long) { +%(kernel_v < "2.6.33" %? return @cast(sock, "inet_sock")->saddr +%: + return @cast(sock, "inet_sock")->inet_saddr +%) } /* return the destination IP address for a given sock */ function __ip_sock_daddr:long (sock:long) { +%(kernel_v < "2.6.33" %? return @cast(sock, "inet_sock")->daddr +%: + return @cast(sock, "inet_sock")->inet_daddr +%) } /* Get the IP header for recent (> 2.6.21) kernels */ diff --git a/tapset/tcp.stp b/tapset/tcp.stp index 2c5dce7e..094161c9 100644 --- a/tapset/tcp.stp +++ b/tapset/tcp.stp @@ -76,7 +76,11 @@ function tcp_ts_get_info_state:long(sock:long) /* return the TCP destination port for a given sock */ function __tcp_sock_dport:long (sock:long){ +%(kernel_v < "2.6.33" %? return @cast(sock, "inet_sock")->dport +%: + return @cast(sock, "inet_sock")->inet_dport +%) } /* returns the TCP header for recent (<2.6.21) kernel */ @@ -145,7 +149,11 @@ function __tcp_skb_dport:long (tcphdr){ /* return the TCP source port for a given sock */ function __tcp_sock_sport:long (sock:long){ +%(kernel_v < "2.6.33" %? return @cast(sock, "inet_sock")->sport +%: + return @cast(sock, "inet_sock")->inet_sport +%) } global sockstate[13], sockstate_init_p diff --git a/tapset/tcpmib.stp b/tapset/tcpmib.stp index aba7837b..cfaaf9c7 100644 --- a/tapset/tcpmib.stp +++ b/tapset/tcpmib.stp @@ -53,7 +53,11 @@ function tcpmib_get_state:long (sk:long) function tcpmib_local_addr:long(sk:long) %{ /* pure */ struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) + THIS->__retvalue = ntohl(kread(&(inet->inet_saddr))); +#else THIS->__retvalue = ntohl(kread(&(inet->saddr))); +#endif CATCH_DEREF_FAULT(); %} @@ -67,7 +71,11 @@ function tcpmib_local_addr:long(sk:long) function tcpmib_remote_addr:long(sk:long) %{ /* pure */ struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) + THIS->__retvalue = ntohl(kread(&(inet->inet_daddr))); +#else THIS->__retvalue = ntohl(kread(&(inet->daddr))); +#endif CATCH_DEREF_FAULT(); %} @@ -81,7 +89,11 @@ function tcpmib_remote_addr:long(sk:long) function tcpmib_local_port:long(sk:long) %{ /* pure */ struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) + THIS->__retvalue = ntohs(kread(&(inet->inet_sport))); +#else THIS->__retvalue = ntohs(kread(&(inet->sport))); +#endif CATCH_DEREF_FAULT(); %} @@ -95,7 +107,11 @@ function tcpmib_local_port:long(sk:long) function tcpmib_remote_port:long(sk:long) %{ /* pure */ struct inet_sock *inet = (struct inet_sock *) (long) THIS->sk; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) + THIS->__retvalue = ntohs(kread(&(inet->inet_dport))); +#else THIS->__retvalue = ntohs(kread(&(inet->dport))); +#endif CATCH_DEREF_FAULT(); %} -- cgit From 82acd39eeb4e04fc2359cb4ce1a0834f0d7769cc Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Tue, 22 Dec 2009 14:03:31 +0530 Subject: Updates to SCSI tapset scsi.stp and corresponding testcases --- tapset/scsi.stp | 133 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 18 deletions(-) (limited to 'tapset') diff --git a/tapset/scsi.stp b/tapset/scsi.stp index f1090231..0b2d94a0 100644 --- a/tapset/scsi.stp +++ b/tapset/scsi.stp @@ -1,12 +1,12 @@ // scsi tapset -// Copyright (C) 2005, 2006 IBM Corp. +// Copyright (C) 2005, 2006, 2009 IBM Corp. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General // Public License (GPL); either version 2, or (at your option) any // later version. // -// This family of probe points is used to probe SCSI activities. +// This family of probe points is used to probe SCSI activities. // %{ #include @@ -17,13 +17,38 @@ #include %} +function describe_data_direction:string(state:long) +%{ /* pure */ + switch ((long)THIS->state) { + case DMA_BIDIRECTIONAL: strlcpy(THIS->__retvalue, "BIDIRECTIONAL", MAXSTRINGLEN); break; + case DMA_TO_DEVICE: strlcpy(THIS->__retvalue, "TO_DEVICE", MAXSTRINGLEN); break; + case DMA_FROM_DEVICE: strlcpy(THIS->__retvalue, "FROM_DEVICE", MAXSTRINGLEN); break; + case DMA_NONE: strlcpy(THIS->__retvalue, "NONE", MAXSTRINGLEN); break; + default: strlcpy(THIS->__retvalue, "[INVALID]", MAXSTRINGLEN); + } +%} + +function describe_device_state:string(state:long) +%{ /* pure */ + switch ((long)THIS->state) { + case SDEV_CREATED: strlcpy(THIS->__retvalue, "CREATED", MAXSTRINGLEN); break; + case SDEV_RUNNING: strlcpy(THIS->__retvalue, "RUNNING", MAXSTRINGLEN); break; + case SDEV_CANCEL: strlcpy(THIS->__retvalue, "CANCEL", MAXSTRINGLEN); break; + case SDEV_DEL: strlcpy(THIS->__retvalue, "DEL", MAXSTRINGLEN); break; + case SDEV_QUIESCE: strlcpy(THIS->__retvalue, "QUIESCE", MAXSTRINGLEN); break; + case SDEV_OFFLINE: strlcpy(THIS->__retvalue, "OFFLINE", MAXSTRINGLEN); break; + case SDEV_BLOCK: strlcpy(THIS->__retvalue, "BLOCK", MAXSTRINGLEN); break; + case SDEV_CREATED_BLOCK: strlcpy(THIS->__retvalue, "CREATED_BLOCK", MAXSTRINGLEN); break; + default: strlcpy(THIS->__retvalue, "[INVALID]", MAXSTRINGLEN); + } +%} /** * probe scsi.ioentry - Prepares a SCSI mid-layer request * @disk_major: The major number of the disk (-1 if no information) * @disk_minor: The minor number of the disk (-1 if no information) - * @device_state: The current state of the device. + * @device_state: The current state of the device + * @device_state_str: The current state of the device, as a string */ -// FIXME describe the device_state probe scsi.ioentry = module("scsi_mod").function("scsi_prep_fn@drivers/scsi/scsi_lib.c")!, kernel.function("scsi_prep_fn@drivers/scsi/scsi_lib.c")? @@ -36,6 +61,7 @@ probe scsi.ioentry disk_minor = $req->rq_disk->first_minor } device_state = get_devstate_from_req($q) + device_state_str = describe_device_state(device_state) req_addr = $req } @@ -45,24 +71,27 @@ probe scsi.ioentry * @channel: The channel number * @lun: The lun number * @dev_id: The scsi device id - * @device_state: The current state of the device. - * @data_direction: The data_direction specifies whether this command is from/to the device. + * @device_state: The current state of the device + * @device_state_str: The current state of the device, as a string + * @data_direction: The data_direction specifies whether this command is from/to the device * 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE), * 2 (DMA_FROM_DEVICE), 3 (DMA_NONE) + * @data_direction_str: Data direction, as a string * @request_buffer: The request buffer address - * @req_bufflen: The request buffer length + * @request_bufflen: The request buffer length */ probe scsi.iodispatching = module("scsi_mod").function("scsi_dispatch_cmd@drivers/scsi/scsi.c")!, kernel.function("scsi_dispatch_cmd@drivers/scsi/scsi.c")? { - host_no = $cmd->device->host->host_no channel = $cmd->device->channel lun = $cmd->device->lun dev_id = $cmd->device->id device_state = $cmd->device->sdev_state + device_state_str = describe_device_state(device_state) data_direction = $cmd->sc_data_direction + data_direction_str = describe_data_direction(data_direction) %( kernel_v >= "2.6.25" %? request_buffer = $cmd->sdb->table->sgl request_bufflen = $cmd->sdb->length @@ -74,14 +103,16 @@ probe scsi.iodispatching } /** - * probe scsi.iodone - SCSI command completed by low level driver and enqueued into the done queue. + * probe scsi.iodone - SCSI command completed by low level driver and enqueued into the done queue. * @host_no: The host number * @channel: The channel number * @lun: The lun number * @dev_id: The scsi device id * @device_state: The current state of the device + * @device_state_str: The current state of the device, as a string * @data_direction: The data_direction specifies whether this command is * from/to the device. + * @data_direction_str: Data direction, as a string */ probe scsi.iodone = module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")!, @@ -93,7 +124,9 @@ probe scsi.iodone lun = $cmd->device->lun dev_id = $cmd->device->id device_state = $cmd->device->sdev_state + device_state_str = describe_device_state(device_state) data_direction = $cmd->sc_data_direction + data_direction_str = describe_data_direction(data_direction) req_addr = $cmd->request scsi_timer_pending = scsi_timer_pending($cmd); } @@ -105,9 +138,11 @@ probe scsi.iodone * @lun: The lun number * @dev_id: The scsi device id * @device_state: The current state of the device + * @device_state_str: The current state of the device, as a string * @data_direction: The data_direction specifies whether this command is from/to * the device - * @goodbytes: The bytes completed. + * @data_direction_str: Data direction, as a string + * @goodbytes: The bytes completed */ // mid-layer processes the completed IO probe scsi.iocompleted @@ -119,23 +154,25 @@ probe scsi.iocompleted lun = $cmd->device->lun dev_id = $cmd->device->id device_state = $cmd->device->sdev_state + device_state_str = describe_device_state(device_state) data_direction = $cmd->sc_data_direction + data_direction_str = describe_data_direction(data_direction) req_addr = $cmd->request goodbytes = $good_bytes } function scsi_timer_pending:long(var:long) %{ /* pure */ - struct scsi_cmnd *cmd = (struct scsi_cmnd *)((long)THIS->var); + struct scsi_cmnd *cmd = (struct scsi_cmnd *)((long)THIS->var); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - THIS->__retvalue = timer_pending(&cmd->eh_timeout); /* FIXME: deref hazard! */ + THIS->__retvalue = timer_pending(&cmd->eh_timeout); /* FIXME: deref hazard! */ #else - struct request *req; - struct request_queue *rq; - req = (struct request *)kread(&cmd->request); - rq = (struct request_queue *)kread(&req->q); - THIS->__retvalue = timer_pending(&rq->timeout); /* FIXME: deref hazard! */ - CATCH_DEREF_FAULT(); + struct request *req; + struct request_queue *rq; + req = (struct request *)kread(&cmd->request); + rq = (struct request_queue *)kread(&req->q); + THIS->__retvalue = timer_pending(&rq->timeout); /* FIXME: deref hazard! */ + CATCH_DEREF_FAULT(); #endif %} @@ -144,3 +181,63 @@ function get_devstate_from_req:long(var:long) sdev = @cast(var, "request_queue", "kernel:scsi_mod")->queuedata return @cast(sdev, "scsi_device", "kernel:scsi_mod")->sdev_state } + +/** + * probe scsi.ioexecute - Create mid-layer SCSI request and wait for the result + * @host_no: The host number + * @channel: The channel number + * @lun: The lun number + * @dev_id: The scsi device id + * @device_state: The current state of the device + * @device_state_str: The current state of the device, as a string + * @data_direction: The data_direction specifies whether this command is + * from/to the device. + * @data_direction_str: Data direction, as a string + * @request_buffer: The data buffer address + * @request_bufflen: The data buffer buffer length + * @timeout: Request timeout in seconds + * @retries: Number of times to retry request + */ +probe scsi.ioexecute + = module("scsi_mod").function("scsi_execute@drivers/scsi/scsi_lib.c")!, + kernel.function("scsi_execute@drivers/scsi/scsi_lib.c")? +{ + host_no = $sdev->host->host_no + channel = $sdev->channel + lun = $sdev->lun + dev_id = $sdev->id + device_state = $sdev->sdev_state + device_state_str = describe_device_state(device_state) + data_direction = $data_direction + data_direction_str = describe_data_direction(data_direction) + request_buffer = $buffer + request_bufflen = $bufflen + timeout = $timeout + retries = $retries +} + +/** + * probe scsi.set_state - Order SCSI device state change + * @host_no: The host number + * @channel: The channel number + * @lun: The lun number + * @dev_id: The scsi device id + * @old_state: The current state of the device + * @old_state_str: The current state of the device, as a string + * @state: The new state of the device + * @state_str: The new state of the device, as a string + */ +probe scsi.set_state + = module("scsi_mod").function("scsi_device_set_state@drivers/scsi/scsi_lib.c")!, + kernel.function("scsi_device_set_state@drivers/scsi/scsi_lib.c")? +{ + state = $state + state_str = describe_device_state(state) + + host_no = $sdev->host->host_no + channel = $sdev->channel + lun = $sdev->lun + dev_id = $sdev->id + old_state = $sdev->sdev_state + old_state_str = describe_device_state(old_state) +} -- cgit