diff options
| author | Steve Dickson <steved@redhat.com> | 2011-09-08 13:51:00 -0400 |
|---|---|---|
| committer | Steve Dickson <steved@redhat.com> | 2011-09-08 13:51:00 -0400 |
| commit | 480862d06d3658a47754da4806e713c8b58ce29b (patch) | |
| tree | cc8395ca8c4219b6b0c25f399bc86175f7622bb3 | |
| parent | bc2b0fb722a32ff1fbadc40a9f73dc0eb75935e6 (diff) | |
| download | systemtap-480862d06d3658a47754da4806e713c8b58ce29b.tar.gz systemtap-480862d06d3658a47754da4806e713c8b58ce29b.tar.xz systemtap-480862d06d3658a47754da4806e713c8b58ce29b.zip | |
Removed duplicated routines
Signed-off-by: Steve Dickson <steved@redhat.com>
| -rw-r--r-- | tapset/sunrpc_task.stp | 63 | ||||
| -rw-r--r-- | tapset/task.stp | 77 |
2 files changed, 67 insertions, 73 deletions
diff --git a/tapset/sunrpc_task.stp b/tapset/sunrpc_task.stp deleted file mode 100644 index 47cc178..0000000 --- a/tapset/sunrpc_task.stp +++ /dev/null @@ -1,63 +0,0 @@ -%{ -#include <linux/sunrpc/svc.h> -#include <linux/sunrpc/sched.h> -#include <linux/sunrpc/clnt.h> -%} - -function cl_prog:string(_task:long) -%{ - struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); - struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); - struct rpc_procinfo *proc = - (struct rpc_procinfo *)(long) kread(&(clnt->cl_procinfo)); - char *p_name = kread(&(proc->p_name)); - static struct { - int prog; - char *string; - } prog_progtbl[] = { - {100000, "rpcbind"}, - {100024, "statd"}, - {100011, "rquotad"}, - {100003, "nfsd"}, - {100021, "nlockmgr"}, - {100005, "mountd"}, - {100227, "nfs_acl"}, - }; - int i; - int tabsz = (sizeof(prog_progtbl)/sizeof(prog_progtbl[0])); - - for (i = 0; i < tabsz; i++) { - if (prog_progtbl[i].prog == clnt->cl_prog) { - break; - } - } - if (i == tabsz) - snprintf(THIS->__retvalue, MAXSTRINGLEN, "0x%x[%d]:%d", - clnt->cl_prog, clnt->cl_vers, proc->p_proc); - else - snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s[%d]:%d", - prog_progtbl[i].string, clnt->cl_vers, proc->p_proc); - - CATCH_DEREF_FAULT(); -%} -function cl_server:string(_task:long) -%{ - struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); - struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); - char *cl_server = kread(&(clnt->cl_server)); - - snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", - cl_server ? cl_server : "NULL"); - - CATCH_DEREF_FAULT(); -%} - -function task_status:long(_task:long) -%{ - struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); - - THIS->__retvalue = task->tk_status; - - CATCH_DEREF_FAULT(); -%} - diff --git a/tapset/task.stp b/tapset/task.stp index 9a635ca..4be41a9 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -1,5 +1,6 @@ %{ #include <linux/kernel.h> +#include <linux/ktime.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/sched.h> #include <linux/sunrpc/svc.h> @@ -93,14 +94,30 @@ function cl_vers:long(_task:long) CATCH_DEREF_FAULT(); %} +function cl_protname:string(_task:long) +%{ + struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); + struct rpc_clnt *clnt; + char *protname = NULL; + + if (task) { + clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); + if (clnt) + protname = (char *)(long) kread(&(clnt->cl_protname)); + } + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", protname); + + CATCH_DEREF_FAULT(); +%} function cl_prog:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); - struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); - struct rpc_procinfo *proc = - (struct rpc_procinfo *)(long) kread(&(clnt->cl_procinfo)); - char *p_name = kread(&(proc->p_name)); + struct rpc_clnt *clnt; + struct rpc_procinfo *proc; + char *p_name; + char buf[64]; + static struct { int prog; char *string; @@ -116,28 +133,68 @@ function cl_prog:string(_task:long) int i; int tabsz = (sizeof(prog_progtbl)/sizeof(prog_progtbl[0])); + if (task <= 0) { + sprintf(buf, "task NULL"); + goto leave; + } + clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); + if (clnt == NULL) { + sprintf(buf, "tk_client NULL"); + goto leave; + } + proc = (struct rpc_procinfo *)(long) kread(&(clnt->cl_procinfo)); + if (proc == NULL) { + sprintf(buf, "cl_procinfo NULL"); + goto leave; + } + p_name = kread(&(proc->p_name)); + for (i = 0; i < tabsz; i++) { if (prog_progtbl[i].prog == clnt->cl_prog) { break; } } if (i == tabsz) - snprintf(THIS->__retvalue, MAXSTRINGLEN, "0x%x[%d]:%d", + snprintf(buf, 64, "0x%x[%d]:%d", clnt->cl_prog, clnt->cl_vers, proc->p_proc); else - snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s[%d]:%d", + snprintf(buf, 64, "%s[%d]:%d", prog_progtbl[i].string, clnt->cl_vers, proc->p_proc); +leave: + snprintf(THIS->__retvalue, 64, "%s", buf); + CATCH_DEREF_FAULT(); %} + function cl_server:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); - struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); - char *cl_server = kread(&(clnt->cl_server)); + struct rpc_clnt *clnt; + char *cl_server; + + if (task) { + clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); + if (clnt) + cl_server = kread(&(clnt->cl_server)); + } + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", cl_server); + + CATCH_DEREF_FAULT(); +%} +function rpc_rtt:long(_task:long) +%{ + struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); + struct rpc_rqst *req; + long rtt = 0; + + if (task) { + req = (struct rpc_rqst *)(long) kread(&(task->tk_rqstp)); + if (req) + rtt = ktime_to_ms(req->rq_rtt); + } - snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", - cl_server ? cl_server : "NULL"); + THIS->__retvalue = rtt; CATCH_DEREF_FAULT(); %} |
