Skip to content

Commit 4e2866b

Browse files
committed
SUNRPC: Add svc_rqst_page_release() helper
svc_rqst_replace_page() releases displaced pages through a per-rqst folio batch, but exposes the add-or-flush sequence directly. svc_tcp_restore_pages() releases displaced pages individually with put_page(). Introduce svc_rqst_page_release() to encapsulate the batched release mechanism. Convert svc_rqst_replace_page() and svc_tcp_restore_pages() to use it. The latter now benefits from the same batched release that svc_rqst_replace_page() already uses. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 3603bf9 commit 4e2866b

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

include/linux/sunrpc/svc.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,21 @@ int svc_generic_rpcbind_set(struct net *net,
498498

499499
#define RPC_MAX_ADDRBUFLEN (63U)
500500

501+
/**
502+
* svc_rqst_page_release - release a page associated with an RPC transaction
503+
* @rqstp: RPC transaction context
504+
* @page: page to release
505+
*
506+
* Released pages are batched and freed together, reducing
507+
* allocator pressure under heavy RPC workloads.
508+
*/
509+
static inline void svc_rqst_page_release(struct svc_rqst *rqstp,
510+
struct page *page)
511+
{
512+
if (!folio_batch_add(&rqstp->rq_fbatch, page_folio(page)))
513+
__folio_batch_release(&rqstp->rq_fbatch);
514+
}
515+
501516
/*
502517
* When we want to reduce the size of the reserved space in the response
503518
* buffer, we need to take into account the size of any checksum data that

net/sunrpc/svc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,8 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
976976
return false;
977977
}
978978

979-
if (*rqstp->rq_next_page) {
980-
if (!folio_batch_add(&rqstp->rq_fbatch,
981-
page_folio(*rqstp->rq_next_page)))
982-
__folio_batch_release(&rqstp->rq_fbatch);
983-
}
979+
if (*rqstp->rq_next_page)
980+
svc_rqst_page_release(rqstp, *rqstp->rq_next_page);
984981

985982
get_page(page);
986983
*(rqstp->rq_next_page++) = page;

net/sunrpc/svcsock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ static size_t svc_tcp_restore_pages(struct svc_sock *svsk,
988988
npages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
989989
for (i = 0; i < npages; i++) {
990990
if (rqstp->rq_pages[i] != NULL)
991-
put_page(rqstp->rq_pages[i]);
991+
svc_rqst_page_release(rqstp, rqstp->rq_pages[i]);
992992
BUG_ON(svsk->sk_pages[i] == NULL);
993993
rqstp->rq_pages[i] = svsk->sk_pages[i];
994994
svsk->sk_pages[i] = NULL;

0 commit comments

Comments
 (0)