From: Chuck Lever <cel@kernel.org>
To: Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
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 v2 01/10] sunrpc: Remove backchannel check in svc_init_buffer()
Date: Mon, 21 Apr 2025 10:59:07 -0400 [thread overview]
Message-ID: <0202b574-19b4-4e06-9966-0cded6ff6c11@kernel.org> (raw)
In-Reply-To: <1263daf84321d07574a05e3cbda66ecf3716a4bc.camel@kernel.org>
On 4/21/25 8:16 AM, Jeff Layton wrote:
> On Sat, 2025-04-19 at 13:28 -0400, cel@kernel.org wrote:
>> From: Chuck Lever <chuck.lever@oracle.com>
>>
>> A backchannel service might use forechannel send and receive
>> buffers, but svc_recv() still calls svc_alloc_arg() on backchannel
>> svc_rqsts, so it will populate the svc_rqst's rq_pages[] array
>> anyway. The "is backchannel" check in svc_init_buffer() saves us
>> nothing.
>>
>> In a moment, I plan to replace the rq_pages[] array with a
>> dynamically-allocated piece of memory, and svc_init_buffer() is
>> where that memory will get allocated. Backchannel requests actually
>> do use that array, so it has to be available to handle those
>> requests without a segfault.
>>
>> XXX: Or, make svc_alloc_arg() ignore backchannel requests too?
>> Could set rqstp->rq_maxpages to zero.
>>
>
> Maybe I'm confused here, but the backchannel still needs some pages to
> do its thing? I guess the main change here is that the pages are
> allocated at svc_create time instead of waiting until later?
The backchannel does not use the pages in svc_rqst::rq_pages, it's
rq_arg::pages comes from the RPC client's page allocator. Currently,
svc_init_buffer() skips allocating pages in rq_pages for that reason.
Except that, svc_rqst::rq_pages is filled anyway when a backchannel
svc_rqst is passed to svc_recv() -> and then to svc_alloc_arg().
This isn't really a problem at the moment, except that these pages are
allocated but then never used AFAICT.
The problem is that in 03/10, in addition to populating rq_pages[],
svc_init_buffer() also now allocates the rq_pages array itself. If
that is skipped, then svc_alloc_args() chases a NULL pointer.
As I mentioned in the patch description, there are two or three ways to
handle this. I'm not sure the way proposed here is best, but it does
avoid introducing extra conditional logic in svc_alloc_args(), which is
a hot path.
Let me know if you have a better idea. I will try to bolster the patch
description here as well.
>> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
>> ---
>> net/sunrpc/svc.c | 4 ----
>> 1 file changed, 4 deletions(-)
>>
>> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
>> index e7f9c295d13c..8ce3e6b3df6a 100644
>> --- a/net/sunrpc/svc.c
>> +++ b/net/sunrpc/svc.c
>> @@ -640,10 +640,6 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, int node)
>> {
>> unsigned long pages, ret;
>>
>> - /* bc_xprt uses fore channel allocated buffers */
>> - if (svc_is_backchannel(rqstp))
>> - return true;
>> -
>> pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
>> * We assume one is at most one page
>> */
>
> Acked-by: Jeff Layton <jlayton@kernel.org>
--
Chuck Lever
next prev parent reply other threads:[~2025-04-21 14:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-19 17:28 [PATCH v2 00/10] Allocate payload arrays dynamically cel
2025-04-19 17:28 ` [PATCH v2 01/10] sunrpc: Remove backchannel check in svc_init_buffer() cel
2025-04-21 12:16 ` Jeff Layton
2025-04-21 14:59 ` Chuck Lever [this message]
2025-04-19 17:28 ` [PATCH v2 02/10] sunrpc: Add a helper to derive maxpages from sv_max_mesg cel
2025-04-22 20:48 ` NeilBrown
2025-04-23 13:16 ` Chuck Lever
2025-04-19 17:28 ` [PATCH v2 03/10] sunrpc: Replace the rq_pages array with dynamically-allocated memory cel
2025-04-21 12:19 ` Jeff Layton
2025-04-19 17:28 ` [PATCH v2 04/10] sunrpc: Replace the rq_vec " cel
2025-04-21 12:22 ` Jeff Layton
2025-04-21 15:05 ` Chuck Lever
2025-04-19 17:28 ` [PATCH v2 05/10] sunrpc: Replace the rq_bvec " cel
2025-04-19 17:28 ` [PATCH v2 06/10] sunrpc: Adjust size of socket's receive page array dynamically cel
2025-04-19 17:28 ` [PATCH v2 07/10] svcrdma: Adjust the number of RDMA contexts per transport cel
2025-04-19 17:28 ` [PATCH v2 08/10] svcrdma: Adjust the number of entries in svc_rdma_recv_ctxt::rc_pages cel
2025-04-19 17:28 ` [PATCH v2 09/10] svcrdma: Adjust the number of entries in svc_rdma_send_ctxt::sc_pages cel
2025-04-19 17:28 ` [PATCH v2 10/10] sunrpc: Remove the RPCSVC_MAXPAGES macro cel
2025-04-19 17:54 ` [PATCH v2 00/10] Allocate payload arrays dynamically Chuck Lever
2025-04-21 12:28 ` 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=0202b574-19b4-4e06-9966-0cded6ff6c11@kernel.org \
--to=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--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