From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, NeilBrown <neilb@ownmail.net>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH 2/3] sunrpc: skip svc_xprt_enqueue in svc_xprt_received when idle
Date: Tue, 24 Mar 2026 09:39:15 -0400 [thread overview]
Message-ID: <2cc13ec847b6366197103c8e5d02a709eeb57dd4.camel@kernel.org> (raw)
In-Reply-To: <20260324130449.16437-3-cel@kernel.org>
On Tue, 2026-03-24 at 09:04 -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> svc_xprt_received() unconditionally calls
> svc_xprt_enqueue() after clearing XPT_BUSY. When no
> work flags are pending, the enqueue traverses
> svc_xprt_ready() -- executing an smp_rmb(), READ_ONCE(),
> and tracepoint -- before returning false.
>
> Trace data from a 256KB NFSv3 workload over RDMA shows
> 85% of svc_xprt_received() invocations reach
> svc_xprt_enqueue() with no pending work flags. In the
> WRITE phase, 167,335 of 196,420 calls find no work; in
> the READ phase, 97,165 of 98,276. Each unnecessary call
> executes a memory barrier, a flags read, and (when
> tracing is active) fires the svc_xprt_enqueue
> tracepoint.
>
> Add a flags pre-check between clear_bit(XPT_BUSY) and
> svc_xprt_enqueue(). Both the clear and the subsequent
> READ_ONCE operate on the same xpt_flags word, so
> cache-line serialization of the atomic bitops ensures
> the read observes any flag set by a concurrent producer
> before the line was acquired for the clear. If a
> producer's set_bit occurs after the clear_bit, that
> producer's own svc_xprt_enqueue() call observes
> !XPT_BUSY and dispatches the transport.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> net/sunrpc/svc_xprt.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> index 73149280167c..36c8437cfd8d 100644
> --- a/net/sunrpc/svc_xprt.c
> +++ b/net/sunrpc/svc_xprt.c
> @@ -234,7 +234,19 @@ void svc_xprt_received(struct svc_xprt *xprt)
> svc_xprt_get(xprt);
> smp_mb__before_atomic();
> clear_bit(XPT_BUSY, &xprt->xpt_flags);
> - svc_xprt_enqueue(xprt);
> +
> + /*
> + * Skip the enqueue when no actionable flags are set.
> + * Each producer both sets its flag (XPT_DATA, XPT_CLOSE,
> + * etc.) and calls svc_xprt_enqueue(); if a set_bit races
> + * with this check, the producer's own enqueue observes
> + * !XPT_BUSY and dispatches the transport.
> + */
> + if (READ_ONCE(xprt->xpt_flags) &
> + (BIT(XPT_CONN) | BIT(XPT_CLOSE) | BIT(XPT_HANDSHAKE) |
> + BIT(XPT_DATA) | BIT(XPT_DEFERRED)))
> + svc_xprt_enqueue(xprt);
> +
> svc_xprt_put(xprt);
> }
> EXPORT_SYMBOL_GPL(svc_xprt_received);
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2026-03-24 13:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:04 [PATCH 0/3] Avoid no-op transport enqueues Chuck Lever
2026-03-24 13:04 ` [PATCH 1/3] sunrpc: skip svc_xprt_enqueue when no work is pending Chuck Lever
2026-03-24 13:26 ` Jeff Layton
2026-03-24 13:04 ` [PATCH 2/3] sunrpc: skip svc_xprt_enqueue in svc_xprt_received when idle Chuck Lever
2026-03-24 13:39 ` Jeff Layton [this message]
2026-03-24 13:04 ` [PATCH 3/3] sunrpc: skip svc_xprt_enqueue when transport is busy Chuck Lever
2026-03-24 13:42 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2cc13ec847b6366197103c8e5d02a709eeb57dd4.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dai.ngo@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@ownmail.net \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox