diff options
| -rw-r--r-- | include/linux/sunrpc/metrics.h | 7 | ||||
| -rw-r--r-- | include/linux/sunrpc/sched.h | 5 | ||||
| -rw-r--r-- | include/linux/sunrpc/xprt.h | 3 | ||||
| -rw-r--r-- | net/sunrpc/sched.c | 2 | ||||
| -rw-r--r-- | net/sunrpc/stats.c | 27 | ||||
| -rw-r--r-- | net/sunrpc/xprt.c | 8 |
6 files changed, 24 insertions, 28 deletions
diff --git a/include/linux/sunrpc/metrics.h b/include/linux/sunrpc/metrics.h index 77f78e56c481..b6edbc0ea83d 100644 --- a/include/linux/sunrpc/metrics.h +++ b/include/linux/sunrpc/metrics.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #define _LINUX_SUNRPC_METRICS_H | 26 | #define _LINUX_SUNRPC_METRICS_H |
| 27 | 27 | ||
| 28 | #include <linux/seq_file.h> | 28 | #include <linux/seq_file.h> |
| 29 | #include <linux/ktime.h> | ||
| 29 | 30 | ||
| 30 | #define RPC_IOSTATS_VERS "1.0" | 31 | #define RPC_IOSTATS_VERS "1.0" |
| 31 | 32 | ||
| @@ -58,9 +59,9 @@ struct rpc_iostats { | |||
| 58 | * and the total time the request spent from init to release | 59 | * and the total time the request spent from init to release |
| 59 | * are measured. | 60 | * are measured. |
| 60 | */ | 61 | */ |
| 61 | unsigned long long om_queue, /* jiffies queued for xmit */ | 62 | ktime_t om_queue, /* queued for xmit */ |
| 62 | om_rtt, /* jiffies for RPC RTT */ | 63 | om_rtt, /* RPC RTT */ |
| 63 | om_execute; /* jiffies for RPC execution */ | 64 | om_execute; /* RPC execution */ |
| 64 | } ____cacheline_aligned; | 65 | } ____cacheline_aligned; |
| 65 | 66 | ||
| 66 | struct rpc_task; | 67 | struct rpc_task; |
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 7bc7fd5291ce..76720d262ef2 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #define _LINUX_SUNRPC_SCHED_H_ | 10 | #define _LINUX_SUNRPC_SCHED_H_ |
| 11 | 11 | ||
| 12 | #include <linux/timer.h> | 12 | #include <linux/timer.h> |
| 13 | #include <linux/ktime.h> | ||
| 13 | #include <linux/sunrpc/types.h> | 14 | #include <linux/sunrpc/types.h> |
| 14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 15 | #include <linux/wait.h> | 16 | #include <linux/wait.h> |
| @@ -80,8 +81,8 @@ struct rpc_task { | |||
| 80 | 81 | ||
| 81 | unsigned short tk_timeouts; /* maj timeouts */ | 82 | unsigned short tk_timeouts; /* maj timeouts */ |
| 82 | size_t tk_bytes_sent; /* total bytes sent */ | 83 | size_t tk_bytes_sent; /* total bytes sent */ |
| 83 | unsigned long tk_start; /* RPC task init timestamp */ | 84 | ktime_t tk_start, /* RPC task init timestamp */ |
| 84 | long tk_rtt; /* round-trip time (jiffies) */ | 85 | tk_rtt; /* round-trip time */ |
| 85 | 86 | ||
| 86 | pid_t tk_owner; /* Process id for batching tasks */ | 87 | pid_t tk_owner; /* Process id for batching tasks */ |
| 87 | unsigned char tk_priority : 2;/* Task priority */ | 88 | unsigned char tk_priority : 2;/* Task priority */ |
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 04fc342d9840..f8851861b744 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/socket.h> | 13 | #include <linux/socket.h> |
| 14 | #include <linux/in.h> | 14 | #include <linux/in.h> |
| 15 | #include <linux/kref.h> | 15 | #include <linux/kref.h> |
| 16 | #include <linux/ktime.h> | ||
| 16 | #include <linux/sunrpc/sched.h> | 17 | #include <linux/sunrpc/sched.h> |
| 17 | #include <linux/sunrpc/xdr.h> | 18 | #include <linux/sunrpc/xdr.h> |
| 18 | #include <linux/sunrpc/msg_prot.h> | 19 | #include <linux/sunrpc/msg_prot.h> |
| @@ -94,7 +95,7 @@ struct rpc_rqst { | |||
| 94 | */ | 95 | */ |
| 95 | u32 rq_bytes_sent; /* Bytes we have sent */ | 96 | u32 rq_bytes_sent; /* Bytes we have sent */ |
| 96 | 97 | ||
| 97 | unsigned long rq_xtime; /* when transmitted */ | 98 | ktime_t rq_xtime; /* transmit time stamp */ |
| 98 | int rq_ntrans; | 99 | int rq_ntrans; |
| 99 | 100 | ||
| 100 | #if defined(CONFIG_NFS_V4_1) | 101 | #if defined(CONFIG_NFS_V4_1) |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index c8979ce5d88a..aa7b07ef5d55 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
| @@ -834,7 +834,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta | |||
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | /* starting timestamp */ | 836 | /* starting timestamp */ |
| 837 | task->tk_start = jiffies; | 837 | task->tk_start = ktime_get(); |
| 838 | 838 | ||
| 839 | dprintk("RPC: new task initialized, procpid %u\n", | 839 | dprintk("RPC: new task initialized, procpid %u\n", |
| 840 | task_pid_nr(current)); | 840 | task_pid_nr(current)); |
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 5785d2037f45..aacd95f0dce5 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c | |||
| @@ -144,7 +144,7 @@ void rpc_count_iostats(struct rpc_task *task) | |||
| 144 | struct rpc_rqst *req = task->tk_rqstp; | 144 | struct rpc_rqst *req = task->tk_rqstp; |
| 145 | struct rpc_iostats *stats; | 145 | struct rpc_iostats *stats; |
| 146 | struct rpc_iostats *op_metrics; | 146 | struct rpc_iostats *op_metrics; |
| 147 | long rtt, execute, queue; | 147 | ktime_t delta; |
| 148 | 148 | ||
| 149 | if (!task->tk_client || !task->tk_client->cl_metrics || !req) | 149 | if (!task->tk_client || !task->tk_client->cl_metrics || !req) |
| 150 | return; | 150 | return; |
| @@ -159,20 +159,13 @@ void rpc_count_iostats(struct rpc_task *task) | |||
| 159 | op_metrics->om_bytes_sent += task->tk_bytes_sent; | 159 | op_metrics->om_bytes_sent += task->tk_bytes_sent; |
| 160 | op_metrics->om_bytes_recv += req->rq_reply_bytes_recvd; | 160 | op_metrics->om_bytes_recv += req->rq_reply_bytes_recvd; |
| 161 | 161 | ||
| 162 | queue = (long)req->rq_xtime - task->tk_start; | 162 | delta = ktime_sub(req->rq_xtime, task->tk_start); |
| 163 | if (queue < 0) | 163 | op_metrics->om_queue = ktime_add(op_metrics->om_queue, delta); |
| 164 | queue = -queue; | ||
| 165 | op_metrics->om_queue += queue; | ||
| 166 | 164 | ||
| 167 | rtt = task->tk_rtt; | 165 | op_metrics->om_rtt = ktime_add(op_metrics->om_rtt, task->tk_rtt); |
| 168 | if (rtt < 0) | ||
| 169 | rtt = -rtt; | ||
| 170 | op_metrics->om_rtt += rtt; | ||
| 171 | 166 | ||
| 172 | execute = (long)jiffies - task->tk_start; | 167 | delta = ktime_sub(ktime_get(), task->tk_start); |
| 173 | if (execute < 0) | 168 | op_metrics->om_execute = ktime_add(op_metrics->om_execute, delta); |
| 174 | execute = -execute; | ||
| 175 | op_metrics->om_execute += execute; | ||
| 176 | } | 169 | } |
| 177 | 170 | ||
| 178 | static void _print_name(struct seq_file *seq, unsigned int op, | 171 | static void _print_name(struct seq_file *seq, unsigned int op, |
| @@ -186,8 +179,6 @@ static void _print_name(struct seq_file *seq, unsigned int op, | |||
| 186 | seq_printf(seq, "\t%12u: ", op); | 179 | seq_printf(seq, "\t%12u: ", op); |
| 187 | } | 180 | } |
| 188 | 181 | ||
| 189 | #define MILLISECS_PER_JIFFY (1000 / HZ) | ||
| 190 | |||
| 191 | void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) | 182 | void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) |
| 192 | { | 183 | { |
| 193 | struct rpc_iostats *stats = clnt->cl_metrics; | 184 | struct rpc_iostats *stats = clnt->cl_metrics; |
| @@ -214,9 +205,9 @@ void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) | |||
| 214 | metrics->om_timeouts, | 205 | metrics->om_timeouts, |
| 215 | metrics->om_bytes_sent, | 206 | metrics->om_bytes_sent, |
| 216 | metrics->om_bytes_recv, | 207 | metrics->om_bytes_recv, |
| 217 | metrics->om_queue * MILLISECS_PER_JIFFY, | 208 | ktime_to_ms(metrics->om_queue), |
| 218 | metrics->om_rtt * MILLISECS_PER_JIFFY, | 209 | ktime_to_ms(metrics->om_rtt), |
| 219 | metrics->om_execute * MILLISECS_PER_JIFFY); | 210 | ktime_to_ms(metrics->om_execute)); |
| 220 | } | 211 | } |
| 221 | } | 212 | } |
| 222 | EXPORT_SYMBOL_GPL(rpc_print_iostats); | 213 | EXPORT_SYMBOL_GPL(rpc_print_iostats); |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 698c62712294..8986b1b82862 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
| 44 | #include <linux/workqueue.h> | 44 | #include <linux/workqueue.h> |
| 45 | #include <linux/net.h> | 45 | #include <linux/net.h> |
| 46 | #include <linux/ktime.h> | ||
| 46 | 47 | ||
| 47 | #include <linux/sunrpc/clnt.h> | 48 | #include <linux/sunrpc/clnt.h> |
| 48 | #include <linux/sunrpc/metrics.h> | 49 | #include <linux/sunrpc/metrics.h> |
| @@ -779,10 +780,11 @@ static void xprt_update_rtt(struct rpc_task *task) | |||
| 779 | struct rpc_rqst *req = task->tk_rqstp; | 780 | struct rpc_rqst *req = task->tk_rqstp; |
| 780 | struct rpc_rtt *rtt = task->tk_client->cl_rtt; | 781 | struct rpc_rtt *rtt = task->tk_client->cl_rtt; |
| 781 | unsigned timer = task->tk_msg.rpc_proc->p_timer; | 782 | unsigned timer = task->tk_msg.rpc_proc->p_timer; |
| 783 | long m = usecs_to_jiffies(ktime_to_us(task->tk_rtt)); | ||
| 782 | 784 | ||
| 783 | if (timer) { | 785 | if (timer) { |
| 784 | if (req->rq_ntrans == 1) | 786 | if (req->rq_ntrans == 1) |
| 785 | rpc_update_rtt(rtt, timer, task->tk_rtt); | 787 | rpc_update_rtt(rtt, timer, m); |
| 786 | rpc_set_timeo(rtt, timer, req->rq_ntrans - 1); | 788 | rpc_set_timeo(rtt, timer, req->rq_ntrans - 1); |
| 787 | } | 789 | } |
| 788 | } | 790 | } |
| @@ -803,7 +805,7 @@ void xprt_complete_rqst(struct rpc_task *task, int copied) | |||
| 803 | task->tk_pid, ntohl(req->rq_xid), copied); | 805 | task->tk_pid, ntohl(req->rq_xid), copied); |
| 804 | 806 | ||
| 805 | xprt->stat.recvs++; | 807 | xprt->stat.recvs++; |
| 806 | task->tk_rtt = (long)jiffies - req->rq_xtime; | 808 | task->tk_rtt = ktime_sub(ktime_get(), req->rq_xtime); |
| 807 | if (xprt->ops->timer != NULL) | 809 | if (xprt->ops->timer != NULL) |
| 808 | xprt_update_rtt(task); | 810 | xprt_update_rtt(task); |
| 809 | 811 | ||
| @@ -904,7 +906,7 @@ void xprt_transmit(struct rpc_task *task) | |||
| 904 | return; | 906 | return; |
| 905 | 907 | ||
| 906 | req->rq_connect_cookie = xprt->connect_cookie; | 908 | req->rq_connect_cookie = xprt->connect_cookie; |
| 907 | req->rq_xtime = jiffies; | 909 | req->rq_xtime = ktime_get(); |
| 908 | status = xprt->ops->send_request(task); | 910 | status = xprt->ops->send_request(task); |
| 909 | if (status != 0) { | 911 | if (status != 0) { |
| 910 | task->tk_status = status; | 912 | task->tk_status = status; |
