Commit 3cf72922 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Replace division by multiplication in calculation of queue length

When checking whether or not a particular xprt queue length is shorter
than the average queue length for all xprts, prefer to use multiplication
rather than division for performance reasons.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 50c80007
...@@ -322,7 +322,6 @@ struct rpc_xprt *xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter *xpi) ...@@ -322,7 +322,6 @@ struct rpc_xprt *xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter *xpi)
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
unsigned long xprt_queuelen; unsigned long xprt_queuelen;
unsigned long xps_queuelen; unsigned long xps_queuelen;
unsigned long xps_avglen;
do { do {
xprt = xprt_iter_next_entry_multiple(xpi, xprt = xprt_iter_next_entry_multiple(xpi,
...@@ -333,8 +332,8 @@ struct rpc_xprt *xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter *xpi) ...@@ -333,8 +332,8 @@ struct rpc_xprt *xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter *xpi)
if (xprt_queuelen <= 2) if (xprt_queuelen <= 2)
break; break;
xps_queuelen = atomic_long_read(&xps->xps_queuelen); xps_queuelen = atomic_long_read(&xps->xps_queuelen);
xps_avglen = DIV_ROUND_UP(xps_queuelen, xps->xps_nactive); /* Exit loop if xprt_queuelen <= average queue length */
} while (xprt_queuelen > xps_avglen); } while (xprt_queuelen * READ_ONCE(xps->xps_nactive) > xps_queuelen);
return xprt; return xprt;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment