Skip to content

Commit 28df098

Browse files
committed
SUNRPC: Use RMW bitops in single-threaded hot paths
I noticed CPU pipeline stalls while using perf. Once an svc thread is scheduled and executing an RPC, no other processes will touch svc_rqst::rq_flags. Thus bus-locked atomics are not needed outside the svc thread scheduler. Signed-off-by: Chuck Lever <[email protected]>
1 parent bb283ca commit 28df098

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
970970
* the client wants us to do more in this compound:
971971
*/
972972
if (!nfsd4_last_compound_op(rqstp))
973-
clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
973+
__clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
974974

975975
/* check stateid */
976976
status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh,
@@ -2650,11 +2650,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
26502650
cstate->minorversion = args->minorversion;
26512651
fh_init(current_fh, NFS4_FHSIZE);
26522652
fh_init(save_fh, NFS4_FHSIZE);
2653+
26532654
/*
26542655
* Don't use the deferral mechanism for NFSv4; compounds make it
26552656
* too hard to avoid non-idempotency problems.
26562657
*/
2657-
clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
2658+
__clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
26582659

26592660
/*
26602661
* According to RFC3010, this takes precedence over all other errors.
@@ -2769,7 +2770,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
27692770
out:
27702771
cstate->status = status;
27712772
/* Reset deferral mechanism for RPC deferrals */
2772-
set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
2773+
__set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
27732774
return rpc_success;
27742775
}
27752776

fs/nfsd/nfs4xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
24112411
argp->rqstp->rq_cachetype = cachethis ? RC_REPLBUFF : RC_NOCACHE;
24122412

24132413
if (readcount > 1 || max_reply > PAGE_SIZE - auth_slack)
2414-
clear_bit(RQ_SPLICE_OK, &argp->rqstp->rq_flags);
2414+
__clear_bit(RQ_SPLICE_OK, &argp->rqstp->rq_flags);
24152415

24162416
return true;
24172417
}

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g
900900
* rejecting the server-computed MIC in this somewhat rare case,
901901
* do not use splice with the GSS integrity service.
902902
*/
903-
clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
903+
__clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
904904

905905
/* Did we already verify the signature on the original pass through? */
906906
if (rqstp->rq_deferred)
@@ -972,7 +972,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
972972
int pad, remaining_len, offset;
973973
u32 rseqno;
974974

975-
clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
975+
__clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
976976

977977
priv_len = svc_getnl(&buf->head[0]);
978978
if (rqstp->rq_deferred) {

net/sunrpc/svc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,10 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
12441244
goto err_short_len;
12451245

12461246
/* Will be turned off by GSS integrity and privacy services */
1247-
set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
1247+
__set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
12481248
/* Will be turned off only when NFSv4 Sessions are used */
1249-
set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
1250-
clear_bit(RQ_DROPME, &rqstp->rq_flags);
1249+
__set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
1250+
__clear_bit(RQ_DROPME, &rqstp->rq_flags);
12511251

12521252
svc_putu32(resv, rqstp->rq_xid);
12531253

net/sunrpc/svc_xprt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req)
12381238
trace_svc_defer(rqstp);
12391239
svc_xprt_get(rqstp->rq_xprt);
12401240
dr->xprt = rqstp->rq_xprt;
1241-
set_bit(RQ_DROPME, &rqstp->rq_flags);
1241+
__set_bit(RQ_DROPME, &rqstp->rq_flags);
12421242

12431243
dr->handle.revisit = svc_revisit;
12441244
return &dr->handle;

net/sunrpc/svcsock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ static void svc_sock_setbufsize(struct svc_sock *svsk, unsigned int nreqs)
298298
static void svc_sock_secure_port(struct svc_rqst *rqstp)
299299
{
300300
if (svc_port_is_privileged(svc_addr(rqstp)))
301-
set_bit(RQ_SECURE, &rqstp->rq_flags);
301+
__set_bit(RQ_SECURE, &rqstp->rq_flags);
302302
else
303-
clear_bit(RQ_SECURE, &rqstp->rq_flags);
303+
__clear_bit(RQ_SECURE, &rqstp->rq_flags);
304304
}
305305

306306
/*
@@ -1008,9 +1008,9 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
10081008
rqstp->rq_xprt_ctxt = NULL;
10091009
rqstp->rq_prot = IPPROTO_TCP;
10101010
if (test_bit(XPT_LOCAL, &svsk->sk_xprt.xpt_flags))
1011-
set_bit(RQ_LOCAL, &rqstp->rq_flags);
1011+
__set_bit(RQ_LOCAL, &rqstp->rq_flags);
10121012
else
1013-
clear_bit(RQ_LOCAL, &rqstp->rq_flags);
1013+
__clear_bit(RQ_LOCAL, &rqstp->rq_flags);
10141014

10151015
p = (__be32 *)rqstp->rq_arg.head[0].iov_base;
10161016
calldir = p[1];

net/sunrpc/xprtrdma/svc_rdma_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static int svc_rdma_has_wspace(struct svc_xprt *xprt)
602602

603603
static void svc_rdma_secure_port(struct svc_rqst *rqstp)
604604
{
605-
set_bit(RQ_SECURE, &rqstp->rq_flags);
605+
__set_bit(RQ_SECURE, &rqstp->rq_flags);
606606
}
607607

608608
static void svc_rdma_kill_temp_xprt(struct svc_xprt *xprt)

0 commit comments

Comments
 (0)