aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/stats.c')
-rw-r--r--net/sunrpc/stats.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index 54530490944e..9711a155bc50 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -116,7 +116,15 @@ EXPORT_SYMBOL_GPL(svc_seq_show);
116 */ 116 */
117struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) 117struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt)
118{ 118{
119 return kcalloc(clnt->cl_maxproc, sizeof(struct rpc_iostats), GFP_KERNEL); 119 struct rpc_iostats *stats;
120 int i;
121
122 stats = kcalloc(clnt->cl_maxproc, sizeof(*stats), GFP_KERNEL);
123 if (stats) {
124 for (i = 0; i < clnt->cl_maxproc; i++)
125 spin_lock_init(&stats[i].om_lock);
126 }
127 return stats;
120} 128}
121EXPORT_SYMBOL_GPL(rpc_alloc_iostats); 129EXPORT_SYMBOL_GPL(rpc_alloc_iostats);
122 130
@@ -135,20 +143,21 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);
135 * rpc_count_iostats - tally up per-task stats 143 * rpc_count_iostats - tally up per-task stats
136 * @task: completed rpc_task 144 * @task: completed rpc_task
137 * @stats: array of stat structures 145 * @stats: array of stat structures
138 *
139 * Relies on the caller for serialization.
140 */ 146 */
141void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats) 147void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats)
142{ 148{
143 struct rpc_rqst *req = task->tk_rqstp; 149 struct rpc_rqst *req = task->tk_rqstp;
144 struct rpc_iostats *op_metrics; 150 struct rpc_iostats *op_metrics;
145 ktime_t delta; 151 ktime_t delta, now;
146 152
147 if (!stats || !req) 153 if (!stats || !req)
148 return; 154 return;
149 155
156 now = ktime_get();
150 op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; 157 op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx];
151 158
159 spin_lock(&op_metrics->om_lock);
160
152 op_metrics->om_ops++; 161 op_metrics->om_ops++;
153 op_metrics->om_ntrans += req->rq_ntrans; 162 op_metrics->om_ntrans += req->rq_ntrans;
154 op_metrics->om_timeouts += task->tk_timeouts; 163 op_metrics->om_timeouts += task->tk_timeouts;
@@ -161,8 +170,10 @@ void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats)
161 170
162 op_metrics->om_rtt = ktime_add(op_metrics->om_rtt, req->rq_rtt); 171 op_metrics->om_rtt = ktime_add(op_metrics->om_rtt, req->rq_rtt);
163 172
164 delta = ktime_sub(ktime_get(), task->tk_start); 173 delta = ktime_sub(now, task->tk_start);
165 op_metrics->om_execute = ktime_add(op_metrics->om_execute, delta); 174 op_metrics->om_execute = ktime_add(op_metrics->om_execute, delta);
175
176 spin_unlock(&op_metrics->om_lock);
166} 177}
167EXPORT_SYMBOL_GPL(rpc_count_iostats); 178EXPORT_SYMBOL_GPL(rpc_count_iostats);
168 179