Re: [PATCH net-next v2 12/15] idpf: add RX splitq napi poll support
From: Jakub Kicinski <kuba@kernel.org>
Date: 2023-06-17 07:01:03
On Wed, 14 Jun 2023 10:14:25 -0700 Tony Nguyen wrote:
+static bool idpf_rx_can_reuse_page(struct idpf_rx_buf *rx_buf)
+{
+ unsigned int last_offset = PAGE_SIZE - rx_buf->buf_size;
+ struct idpf_page_info *pinfo;
+ unsigned int pagecnt_bias;
+ struct page *page;
+
+ pinfo = &rx_buf->page_info[rx_buf->page_indx];
+ pagecnt_bias = pinfo->pagecnt_bias;
+ page = pinfo->page;
+
+ if (unlikely(!dev_page_is_reusable(page)))
+ return false;
+
+ if (PAGE_SIZE < 8192) {
+ /* For 2K buffers, we can reuse the page if we are the
+ * owner. For 4K buffers, we can reuse the page if there are
+ * no other others.
+ */
+ if (unlikely((page_count(page) - pagecnt_bias) >
+ pinfo->reuse_bias))
+ return false;
+ } else if (pinfo->page_offset > last_offset) {
+ return false;
+ }
+
+ /* If we have drained the page fragment pool we need to update
+ * the pagecnt_bias and page count so that we fully restock the
+ * number of references the driver holds.
+ */
+ if (unlikely(pagecnt_bias == 1)) {
+ page_ref_add(page, USHRT_MAX - 1);
+ pinfo->pagecnt_bias = USHRT_MAX;
+ }
+
+ return true;
+}If you want to do local recycling you must use the page pool first, and then share the analysis of how much and why the recycling helps.