SUNRPC: Micro-optimize __rpc_execute
authorChuck Lever <chuck.lever@oracle.com>
Wed, 3 Jan 2018 20:38:49 +0000 (15:38 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 23 Jan 2018 14:44:40 +0000 (09:44 -0500)
The common case: There are 13 to 14 actions per RPC, and tk_callback
is non-NULL in only one of them. There's no need to store a NULL in
the tk_callback field during each FSM step.

This slightly improves throughput results in dbench and other multi-
threaded benchmarks on my two-socket client on 56Gb InfiniBand, but
will probably be inconsequential on slower systems.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/sched.c

index c292a5e1a70ccf192e31061d7242700af8036246..896691afbb1a805b71a51aa600efa599e784f3c7 100644 (file)
@@ -755,21 +755,19 @@ static void __rpc_execute(struct rpc_task *task)
                void (*do_action)(struct rpc_task *);
 
                /*
-                * Execute any pending callback first.
+                * Perform the next FSM step or a pending callback.
+                *
+                * tk_action may be NULL if the task has been killed.
+                * In particular, note that rpc_killall_tasks may
+                * do this at any time, so beware when dereferencing.
                 */
-               do_action = task->tk_callback;
-               task->tk_callback = NULL;
-               if (do_action == NULL) {
-                       /*
-                        * Perform the next FSM step.
-                        * tk_action may be NULL if the task has been killed.
-                        * In particular, note that rpc_killall_tasks may
-                        * do this at any time, so beware when dereferencing.
-                        */
-                       do_action = task->tk_action;
-                       if (do_action == NULL)
-                               break;
+               do_action = task->tk_action;
+               if (task->tk_callback) {
+                       do_action = task->tk_callback;
+                       task->tk_callback = NULL;
                }
+               if (!do_action)
+                       break;
                trace_rpc_task_run_action(task->tk_client, task, do_action);
                do_action(task);