From: Emil Tantilov <emil.s.tantilov@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 5/9] ixgbevf: update code to better handle incrementing page count
Date: Mon, 11 Dec 2017 10:37:10 -0800 [thread overview]
Message-ID: <20171211183709.21524.19432.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20171211183537.21524.10133.stgit@localhost6.localdomain6>
Based on commit bd4171a5d4c2
("igb: update code to better handle incrementing page count")
Update the driver code so that we do bulk updates of the page reference
count instead of just incrementing it by one reference at a time. The
advantage to doing this is that we cut down on atomic operations and
this in turn should give us a slight improvement in cycles per packet.
In addition if we eventually move this over to using build_skb the gains
will be more noticeable.
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
---
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 7 ++++-
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 30 +++++++++++++++------
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index b1da9f4..c70a789 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -62,7 +62,12 @@ struct ixgbevf_tx_buffer {
struct ixgbevf_rx_buffer {
dma_addr_t dma;
struct page *page;
- unsigned int page_offset;
+#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
+ __u32 page_offset;
+#else
+ __u16 page_offset;
+#endif
+ __u16 pagecnt_bias;
};
struct ixgbevf_stats {
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index fbd493e..ae2402d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -611,6 +611,7 @@ static bool ixgbevf_alloc_mapped_page(struct ixgbevf_ring *rx_ring,
bi->dma = dma;
bi->page = page;
bi->page_offset = 0;
+ bi->pagecnt_bias = 1;
return true;
}
@@ -747,6 +748,7 @@ static void ixgbevf_reuse_rx_page(struct ixgbevf_ring *rx_ring,
new_buff->page = old_buff->page;
new_buff->dma = old_buff->dma;
new_buff->page_offset = old_buff->page_offset;
+ new_buff->pagecnt_bias = old_buff->pagecnt_bias;
}
static inline bool ixgbevf_page_is_reserved(struct page *page)
@@ -758,13 +760,15 @@ static bool ixgbevf_can_reuse_rx_page(struct ixgbevf_rx_buffer *rx_buffer,
struct page *page,
const unsigned int truesize)
{
+ unsigned int pagecnt_bias = rx_buffer->pagecnt_bias--;
+
/* avoid re-using remote pages */
if (unlikely(ixgbevf_page_is_reserved(page)))
return false;
#if (PAGE_SIZE < 8192)
/* if we are only owner of page we can reuse it */
- if (unlikely(page_count(page) != 1))
+ if (unlikely(page_ref_count(page) != pagecnt_bias))
return false;
/* flip page offset to other buffer */
@@ -778,10 +782,15 @@ static bool ixgbevf_can_reuse_rx_page(struct ixgbevf_rx_buffer *rx_buffer,
return false;
#endif
- /* Even if we own the page, we are not allowed to use atomic_set()
- * This would break get_page_unless_zero() users.
+
+ /* 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.
*/
- page_ref_inc(page);
+ if (unlikely(pagecnt_bias == 1)) {
+ page_ref_add(page, USHRT_MAX);
+ rx_buffer->pagecnt_bias = USHRT_MAX;
+ }
return true;
}
@@ -827,7 +836,6 @@ static bool ixgbevf_add_rx_frag(struct ixgbevf_ring *rx_ring,
return true;
/* this page cannot be reused so discard it */
- put_page(page);
return false;
}
@@ -899,10 +907,13 @@ static struct sk_buff *ixgbevf_fetch_rx_buffer(struct ixgbevf_ring *rx_ring,
/* hand second half of page back to the ring */
ixgbevf_reuse_rx_page(rx_ring, rx_buffer);
} else {
- /* we are not reusing the buffer so unmap it */
+ /* We are not reusing the buffer so unmap it and free
+ * any references we are holding to it
+ */
dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma,
PAGE_SIZE, DMA_FROM_DEVICE,
IXGBEVF_RX_DMA_ATTR);
+ __page_frag_cache_drain(page, rx_buffer->pagecnt_bias);
}
/* clear contents of buffer_info */
@@ -2135,6 +2146,8 @@ static void ixgbevf_clean_rx_ring(struct ixgbevf_ring *rx_ring)
struct ixgbevf_rx_buffer *rx_buffer;
rx_buffer = &rx_ring->rx_buffer_info[i];
+ if (!rx_buffer->page)
+ continue;
/* Invalidate cache lines that may have been written to by
* device so that we avoid corrupting memory.
@@ -2152,8 +2165,9 @@ static void ixgbevf_clean_rx_ring(struct ixgbevf_ring *rx_ring)
DMA_FROM_DEVICE,
IXGBEVF_RX_DMA_ATTR);
- if (rx_buffer->page)
- __free_page(rx_buffer->page);
+ __page_frag_cache_drain(rx_buffer->page,
+ rx_buffer->pagecnt_bias);
+
rx_buffer->page = NULL;
}
next prev parent reply other threads:[~2017-12-11 18:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-11 18:36 [Intel-wired-lan] [PATCH 0/9] ixgbevf: update Rx/Tx code path for build_skb Emil Tantilov
2017-12-11 18:36 ` [Intel-wired-lan] [PATCH 1/9] ixgbevf: add function for checking if we can reuse page Emil Tantilov
2018-01-04 15:41 ` Singh, Krishneil K
2017-12-11 18:36 ` [Intel-wired-lan] [PATCH 2/9] ixgbevf: only DMA sync frame length Emil Tantilov
2018-01-04 15:43 ` Singh, Krishneil K
2018-02-26 15:55 ` Singh, Krishneil K
2017-12-11 18:36 ` [Intel-wired-lan] [PATCH 3/9] ixgbevf: use length to determine if descriptor is done Emil Tantilov
2018-01-04 15:44 ` Singh, Krishneil K
2018-02-26 15:57 ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 4/9] ixgbevf: add support for DMA_ATTR_SKIP_CPU_SYNC/WEAK_ORDERING Emil Tantilov
2018-01-04 15:46 ` Singh, Krishneil K
2018-02-26 15:54 ` Singh, Krishneil K
2017-12-11 18:37 ` Emil Tantilov [this message]
2018-01-04 15:46 ` [Intel-wired-lan] [PATCH 5/9] ixgbevf: update code to better handle incrementing page count Singh, Krishneil K
2018-02-26 15:56 ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 6/9] ixgbevf: add counters for Rx page allocations Emil Tantilov
2018-01-04 15:47 ` Singh, Krishneil K
2018-02-26 15:54 ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 7/9] ixgbevf: clear rx_buffer_info in configure instead of clean Emil Tantilov
2018-01-04 15:48 ` Singh, Krishneil K
2018-02-26 15:55 ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 8/9] ixgbevf: improve performance and reduce size of ixgbevf_tx_map() Emil Tantilov
2018-01-04 15:49 ` Singh, Krishneil K
2018-02-26 15:54 ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 9/9] ixgbevf: don't bother clearing tx_buffer_info in ixgbevf_clean_tx_ring() Emil Tantilov
2018-01-04 15:50 ` Singh, Krishneil K
2018-02-26 15:57 ` Singh, Krishneil K
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171211183709.21524.19432.stgit@localhost6.localdomain6 \
--to=emil.s.tantilov@intel.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).