]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
SUNRPC: Use RMW bitops in single-threaded hot paths
authorChuck Lever <chuck.lever@oracle.com>
Fri, 29 Apr 2022 14:06:21 +0000 (10:06 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:06 +0000 (16:19 +0200)
[ Upstream commit 28df0988815f63e2af5e6718193c9f68681ad7ff ]

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 <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4xdr.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/svc.c
net/sunrpc/svc_xprt.c
net/sunrpc/svcsock.c
net/sunrpc/xprtrdma/svc_rdma_transport.c

index 3ac2978c596ae1a17c843e14ca4f26d5a3b0f140..5b56877c7fb57384e304e7d2e3b389d50e2ed702 100644 (file)
@@ -970,7 +970,7 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
         * the client wants us to do more in this compound:
         */
        if (!nfsd4_last_compound_op(rqstp))
-               clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
+               __clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
 
        /* check stateid */
        status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh,
@@ -2644,11 +2644,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
        cstate->minorversion = args->minorversion;
        fh_init(current_fh, NFS4_FHSIZE);
        fh_init(save_fh, NFS4_FHSIZE);
+
        /*
         * Don't use the deferral mechanism for NFSv4; compounds make it
         * too hard to avoid non-idempotency problems.
         */
-       clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
+       __clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
 
        /*
         * According to RFC3010, this takes precedence over all other errors.
@@ -2770,7 +2771,7 @@ encode_op:
 out:
        cstate->status = status;
        /* Reset deferral mechanism for RPC deferrals */
-       set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
+       __set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
        return rpc_success;
 }
 
index 771d3057577efe27d35dd92d61b74daf8531e43e..96d41b1cc2d175184ef77bf42ee168ddf5293d9a 100644 (file)
@@ -2408,7 +2408,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
        argp->rqstp->rq_cachetype = cachethis ? RC_REPLBUFF : RC_NOCACHE;
 
        if (readcount > 1 || max_reply > PAGE_SIZE - auth_slack)
-               clear_bit(RQ_SPLICE_OK, &argp->rqstp->rq_flags);
+               __clear_bit(RQ_SPLICE_OK, &argp->rqstp->rq_flags);
 
        return true;
 }
index 48b608cb5f5ec772a0c3edb7804e0b8bba0ea84b..2381c5d1b07100794622d77e6798096eac5ba157 100644 (file)
@@ -900,7 +900,7 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g
         * rejecting the server-computed MIC in this somewhat rare case,
         * do not use splice with the GSS integrity service.
         */
-       clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
+       __clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
 
        /* Did we already verify the signature on the original pass through? */
        if (rqstp->rq_deferred)
@@ -972,7 +972,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
        int pad, remaining_len, offset;
        u32 rseqno;
 
-       clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
+       __clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
 
        priv_len = svc_getnl(&buf->head[0]);
        if (rqstp->rq_deferred) {
index 87da3ff46ce9afa7a4778d510148cb43e5eca882..f2a8c1ee8530efe10a8fc157ec97a10ed884b3db 100644 (file)
@@ -1281,10 +1281,10 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
                goto err_short_len;
 
        /* Will be turned off by GSS integrity and privacy services */
-       set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
+       __set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
        /* Will be turned off only when NFSv4 Sessions are used */
-       set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
-       clear_bit(RQ_DROPME, &rqstp->rq_flags);
+       __set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
+       __clear_bit(RQ_DROPME, &rqstp->rq_flags);
 
        svc_putu32(resv, rqstp->rq_xid);
 
index 67ccf1a6459ae37b0938e079cadad8ab2c0d6e06..39acef5134f5c79b8525c6d2f0ea75c29fa310f3 100644 (file)
@@ -1251,7 +1251,7 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req)
        trace_svc_defer(rqstp);
        svc_xprt_get(rqstp->rq_xprt);
        dr->xprt = rqstp->rq_xprt;
-       set_bit(RQ_DROPME, &rqstp->rq_flags);
+       __set_bit(RQ_DROPME, &rqstp->rq_flags);
 
        dr->handle.revisit = svc_revisit;
        return &dr->handle;
index be7081284a09894f70e547085e3d8bd28fc7f16e..46cea0e413aebbace2c24aa3ba7da07bf52c36db 100644 (file)
@@ -298,9 +298,9 @@ static void svc_sock_setbufsize(struct svc_sock *svsk, unsigned int nreqs)
 static void svc_sock_secure_port(struct svc_rqst *rqstp)
 {
        if (svc_port_is_privileged(svc_addr(rqstp)))
-               set_bit(RQ_SECURE, &rqstp->rq_flags);
+               __set_bit(RQ_SECURE, &rqstp->rq_flags);
        else
-               clear_bit(RQ_SECURE, &rqstp->rq_flags);
+               __clear_bit(RQ_SECURE, &rqstp->rq_flags);
 }
 
 /*
@@ -1005,9 +1005,9 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
        rqstp->rq_xprt_ctxt   = NULL;
        rqstp->rq_prot        = IPPROTO_TCP;
        if (test_bit(XPT_LOCAL, &svsk->sk_xprt.xpt_flags))
-               set_bit(RQ_LOCAL, &rqstp->rq_flags);
+               __set_bit(RQ_LOCAL, &rqstp->rq_flags);
        else
-               clear_bit(RQ_LOCAL, &rqstp->rq_flags);
+               __clear_bit(RQ_LOCAL, &rqstp->rq_flags);
 
        p = (__be32 *)rqstp->rq_arg.head[0].iov_base;
        calldir = p[1];
index f776f0cb471f0d9bcc2624b9ec5209fa84a15071..ac147304fb0e9260514052e324c2c6b2faeeeb61 100644 (file)
@@ -602,7 +602,7 @@ static int svc_rdma_has_wspace(struct svc_xprt *xprt)
 
 static void svc_rdma_secure_port(struct svc_rqst *rqstp)
 {
-       set_bit(RQ_SECURE, &rqstp->rq_flags);
+       __set_bit(RQ_SECURE, &rqstp->rq_flags);
 }
 
 static void svc_rdma_kill_temp_xprt(struct svc_xprt *xprt)