Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+18 -6
+15
include/linux/sunrpc/svc.h
··· 498 498 499 499 #define RPC_MAX_ADDRBUFLEN (63U) 500 500 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 + 501 516 /* 502 517 * When we want to reduce the size of the reserved space in the response 503 518 * buffer, we need to take into account the size of any checksum data that
+2 -5
net/sunrpc/svc.c
··· 976 976 return false; 977 977 } 978 978 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); 984 981 985 982 get_page(page); 986 983 *(rqstp->rq_next_page++) = page;
+1 -1
net/sunrpc/svcsock.c
··· 988 988 npages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 989 989 for (i = 0; i < npages; i++) { 990 990 if (rqstp->rq_pages[i] != NULL) 991 - put_page(rqstp->rq_pages[i]); 991 + svc_rqst_page_release(rqstp, rqstp->rq_pages[i]); 992 992 BUG_ON(svsk->sk_pages[i] == NULL); 993 993 rqstp->rq_pages[i] = svsk->sk_pages[i]; 994 994 svsk->sk_pages[i] = NULL;