Message ID | 20190716200433.38758-3-trond.myklebust@hammerspace.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] SUNRPC: Replace division by multiplication in calculation of queue length | expand |
diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index c12778e1235e..852da66cdaec 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -293,18 +293,14 @@ struct rpc_xprt *xprt_switch_set_next_cursor(struct list_head *head, struct rpc_xprt **cursor, xprt_switch_find_xprt_t find_next) { - struct rpc_xprt *cur, *pos, *old; + struct rpc_xprt *pos, *old; - cur = READ_ONCE(*cursor); - for (;;) { - old = cur; + old = READ_ONCE(*cursor); + do { pos = find_next(head, old); if (pos == NULL) break; - cur = cmpxchg_relaxed(cursor, old, pos); - if (cur == old) - break; - } + } while (!try_cmpxchg(cursor, &old, pos)); return pos; }
Apparently we do need the memory barrier. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> --- net/sunrpc/xprtmultipath.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)