From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F082DB79D for ; Thu, 26 Feb 2026 14:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772117268; cv=none; b=q3m3gOZ4cabqkRt5H/eduuutFgEMXSKoemTzXcxqg5vl2pmohakh9aDMv3GRSfoTNUzaHSOtL9dNkp6rjhzSAeEqYm2qK0Ct5UBDZdmvcUiSbXuL9OluJ4a8/lGsApYhYP1xM0+kyepOLLLJqhxGNJR1Pu1joCdnYRLrWqGuhDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772117268; c=relaxed/simple; bh=xjZtIDkc6vngwg5sZ1d+vGi/1JkZeCIiuPRiVWmS9Y0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GFiPds+KY/orlX7ooQMeUeAzAKXR3VSvSrOx9EEh9HzTR+afq+mdET+23DDbvEzPcOUoo07B9cai3705LdFpCpD20QAPfFbaalJNKewpDl/ycANi1urPjUgy+GNnTfXmfbCvsiLpO6x4FHLqA8ydtV1p8O9T4zWhq3S40TukOn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e/q51uc0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e/q51uc0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09511C19423; Thu, 26 Feb 2026 14:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772117267; bh=xjZtIDkc6vngwg5sZ1d+vGi/1JkZeCIiuPRiVWmS9Y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/q51uc0xQ/Ty+N6Eh33mBvxhtPFm889p4jlhoU0MBVzbO3q1mLCPA9rBadyLpCCc YbxDhA0Y9lB3YHTgG6w0G4WTx8aqF+DlJGV3Jm4GFLJzhdUEXx29HrFhhiuzDO3ouD U+mUVOFNzz6bIuBNOdUViWF/SHEqVZ8HijL1dbdZz7X0rZwATaAWSAPYALE083pQYJ 6V7enaSQD9n7teWcwRw9df9zu+GCFv/h6AcUl143N1wJSuPbdp5u/MAoeBrEyDnyDF eT2CCueaCuc2WLK0Zmj+CAcIbDA48p0IC7UpoW9gHAs867q4fIOYk/B2RN5axV5U5Y nfiflylPOIQow== From: Chuck Lever To: NeilBrown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v2 6/6] SUNRPC: Optimize rq_respages allocation in svc_alloc_arg Date: Thu, 26 Feb 2026 09:47:39 -0500 Message-ID: <20260226144739.193129-7-cel@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260226144739.193129-1-cel@kernel.org> References: <20260226144739.193129-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever svc_alloc_arg() invokes alloc_pages_bulk() with the full rq_maxpages count (~259 for 1MB messages) for the rq_respages array, causing a full-array scan despite most slots holding valid pages. svc_rqst_release_pages() NULLs only the range [rq_respages, rq_next_page) after each RPC, so only that range contains NULL entries. Limit the rq_respages fill in svc_alloc_arg() to that range instead of scanning the full array. svc_init_buffer() initializes rq_next_page to span the entire rq_respages array, so the first svc_alloc_arg() call fills all slots. Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 4 ++++ net/sunrpc/svc.c | 1 + net/sunrpc/svc_xprt.c | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index b5a842dd97a4..7315c529f88a 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -152,6 +152,10 @@ extern u32 svc_max_payload(const struct svc_rqst *rqstp); * still in transport use, and set rq_pages_nfree to the count. * svc_alloc_arg() refills only that many rq_pages entries. * + * For rq_respages, svc_rqst_release_pages() NULLs entries in + * [rq_respages, rq_next_page) after each RPC. svc_alloc_arg() + * refills only that range. + * * xdr_buf holds responses; the structure fits NFS read responses * (header, data pages, optional tail) and enables sharing of * client-side routines. diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 6e57e35fa6d6..5e0b5ec2fd52 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -656,6 +656,7 @@ svc_init_buffer(struct svc_rqst *rqstp, const struct svc_serv *serv, int node) } rqstp->rq_pages_nfree = rqstp->rq_maxpages; + rqstp->rq_next_page = rqstp->rq_respages + rqstp->rq_maxpages; return true; } diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 795b5729525f..b16e710926c1 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -686,8 +686,14 @@ static bool svc_alloc_arg(struct svc_rqst *rqstp) rqstp->rq_pages_nfree = 0; } - if (!svc_fill_pages(rqstp, rqstp->rq_respages, pages)) + if (WARN_ON_ONCE(rqstp->rq_next_page < rqstp->rq_respages)) return false; + nfree = rqstp->rq_next_page - rqstp->rq_respages; + if (nfree) { + if (!svc_fill_pages(rqstp, rqstp->rq_respages, nfree)) + return false; + } + rqstp->rq_next_page = rqstp->rq_respages; rqstp->rq_page_end = &rqstp->rq_respages[pages]; /* svc_rqst_replace_page() dereferences *rq_next_page even -- 2.53.0