aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2009-12-03 15:58:56 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-12-03 15:58:56 -0500
commit206a134b4d8abf57cd34dffacf993869355b9aac (patch)
treeffe4724ce1957243de3eaa2e123b25c883c53412 /net/sunrpc/clnt.c
parentdd47f96c077b4516727e497e4b6fd47a06778c0a (diff)
SUNRPC: Check explicitly for tk_status == 0 in call_transmit_status()
The success case, where task->tk_status == 0, is by far the most frequent case in call_transmit_status(). The default: arm of the switch statement in call_transmit_status() handles the 0 case. default: was moved close to the top of the switch statement in call_transmit_status() under the theory that the compiler places object code for the earliest arms of a switch statement first, making the CPU do less work. The default: arm of a switch statement, however, is executed only after all the other cases have been checked. Even if the compiler rearranges the object code, the default: arm is the "last resort", meaning all of the other cases have been explicitly exhausted. That makes the current arrangement about as inefficient as it gets for the common case. To fix this, add an explicit check for zero before the switch statement. That forces the compiler to do the zero check first, no matter what optimizations it might try to do to the switch statement. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 38829e20500b..7bcd931e06ee 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1180,10 +1180,22 @@ static void
1180call_transmit_status(struct rpc_task *task) 1180call_transmit_status(struct rpc_task *task)
1181{ 1181{
1182 task->tk_action = call_status; 1182 task->tk_action = call_status;
1183
1184 /*
1185 * Common case: success. Force the compiler to put this
1186 * test first.
1187 */
1188 if (task->tk_status == 0) {
1189 xprt_end_transmit(task);
1190 rpc_task_force_reencode(task);
1191 return;
1192 }
1193
1183 switch (task->tk_status) { 1194 switch (task->tk_status) {
1184 case -EAGAIN: 1195 case -EAGAIN:
1185 break; 1196 break;
1186 default: 1197 default:
1198 dprint_status(task);
1187 xprt_end_transmit(task); 1199 xprt_end_transmit(task);
1188 /* 1200 /*
1189 * Special cases: if we've been waiting on the 1201 * Special cases: if we've been waiting on the