Author: Chuck Lever SUNRPC: introduce per-task RPC iostats Account for various things that occur while an RPC task is executed. Separate timers for RPC round trip and RPC execution time show how long RPC requests wait in queue before being sent. Eventually these will be accumulated at xprt_release time in one place where they can be viewed from userland. Test plan: Compile kernel with CONFIG_NFS enabled. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- include/linux/sunrpc/sched.h | 6 ++++++ net/sunrpc/clnt.c | 2 ++ net/sunrpc/sched.c | 3 +++ net/sunrpc/xprt.c | 2 ++ net/sunrpc/xprtsock.c | 1 + 5 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 6c23f73..45a64ae 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -86,6 +86,12 @@ struct rpc_task { struct work_struct tk_work; /* Async task work queue */ struct rpc_wait tk_wait; /* RPC wait */ } u; + + unsigned short tk_timeouts; /* maj timeouts */ + size_t tk_bytes_sent; /* total bytes sent */ + unsigned long tk_start; /* RPC task init timestamp */ + long tk_rtt; /* round-trip time (jiffies) */ + #ifdef RPC_DEBUG unsigned short tk_pid; /* debugging aid */ #endif diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 5c1ec0f..800a544 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -995,6 +995,8 @@ call_timeout(struct rpc_task *task) } dprintk("RPC: %4d call_timeout (major)\n", task->tk_pid); + task->tk_timeouts++; + if (RPC_IS_SOFT(task)) { printk(KERN_NOTICE "%s: server %s not responding, timed out\n", clnt->cl_protname, clnt->cl_server); diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index c9b9617..a04cf3b 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -820,6 +820,9 @@ void rpc_init_task(struct rpc_task *task BUG_ON(task->tk_ops == NULL); + /* starting timestamp */ + task->tk_start = jiffies; + dprintk("RPC: %4d new task procpid %d\n", task->tk_pid, current->pid); } diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 93a0a3c..c624197 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -648,6 +648,8 @@ void xprt_complete_rqst(struct rpc_task task->tk_pid, ntohl(req->rq_xid), copied); task->tk_xprt->stat.recvs++; + task->tk_rtt = (long)jiffies - req->rq_xtime; + list_del_init(&req->rq_list); req->rq_received = req->rq_private_buf.len = copied; rpc_wake_up_task(task); diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 6766b7f..4b4e7df 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -382,6 +382,7 @@ static int xs_tcp_send_request(struct rp /* If we've sent the entire packet, immediately * reset the count of bytes sent. */ req->rq_bytes_sent += status; + task->tk_bytes_sent += status; if (likely(req->rq_bytes_sent >= req->rq_slen)) { req->rq_bytes_sent = 0; return 0;