]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
SUNRPC: Add svc_rqst_page_release() helper
authorChuck Lever <chuck.lever@oracle.com>
Wed, 11 Mar 2026 16:18:54 +0000 (12:18 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 3 Apr 2026 13:26:17 +0000 (09:26 -0400)
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>
include/linux/sunrpc/svc.h
net/sunrpc/svc.c
net/sunrpc/svcsock.c

index 669c944eaf7fa9b21fc05f0e13037903261d48fe..1ebd9c7efa707f09fe550692f70c015cb2bc8ccf 100644 (file)
@@ -498,6 +498,21 @@ int                   svc_generic_rpcbind_set(struct net *net,
 
 #define        RPC_MAX_ADDRBUFLEN      (63U)
 
+/**
+ * svc_rqst_page_release - release a page associated with an RPC transaction
+ * @rqstp: RPC transaction context
+ * @page: page to release
+ *
+ * Released pages are batched and freed together, reducing
+ * allocator pressure under heavy RPC workloads.
+ */
+static inline void svc_rqst_page_release(struct svc_rqst *rqstp,
+                                        struct page *page)
+{
+       if (!folio_batch_add(&rqstp->rq_fbatch, page_folio(page)))
+               __folio_batch_release(&rqstp->rq_fbatch);
+}
+
 /*
  * When we want to reduce the size of the reserved space in the response
  * buffer, we need to take into account the size of any checksum data that
index 5e0b5ec2fd52830f9d99912d9ee709b363e143b3..576fa42e7abf7561b0be46fe4fe673350924cfc9 100644 (file)
@@ -976,11 +976,8 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
                return false;
        }
 
-       if (*rqstp->rq_next_page) {
-               if (!folio_batch_add(&rqstp->rq_fbatch,
-                               page_folio(*rqstp->rq_next_page)))
-                       __folio_batch_release(&rqstp->rq_fbatch);
-       }
+       if (*rqstp->rq_next_page)
+               svc_rqst_page_release(rqstp, *rqstp->rq_next_page);
 
        get_page(page);
        *(rqstp->rq_next_page++) = page;
index 2ce43f9995f16b3c06fa4b202a764178d77ed6c4..7be3de1a1aed91cefd2ae426ea86c96a1ba9388d 100644 (file)
@@ -988,7 +988,7 @@ static size_t svc_tcp_restore_pages(struct svc_sock *svsk,
        npages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
        for (i = 0; i < npages; i++) {
                if (rqstp->rq_pages[i] != NULL)
-                       put_page(rqstp->rq_pages[i]);
+                       svc_rqst_page_release(rqstp, rqstp->rq_pages[i]);
                BUG_ON(svsk->sk_pages[i] == NULL);
                rqstp->rq_pages[i] = svsk->sk_pages[i];
                svsk->sk_pages[i] = NULL;