Skip to content

Commit

Permalink
i40e: optimise prefetch page refcount
Browse files Browse the repository at this point in the history
refcount of rx_buffer page will be added here originally, so prefetchw
is needed, but after commit 1793668 ("i40e/i40evf: Update code to
better handle incrementing page count"), and refcount is not added
every time, so change prefetchw as prefetch.

Now it mainly services page_address(), but which accesses struct page
only when WANT_PAGE_VIRTUAL or HASHED_PAGE_VIRTUAL is defined otherwise
it returns address based on offset, so we prefetch it conditionally.

Jakub suggested to define prefetch_page_address in a common header.

Reported-by: kernel test robot <[email protected]>
Suggested-by: Jakub Kicinski <[email protected]>
Signed-off-by: Li RongQing <[email protected]>
Reviewed-by: Jesse Brandeburg <[email protected]>
Tested-by: Aaron Brown <[email protected]>
Signed-off-by: Tony Nguyen <[email protected]>
  • Loading branch information
lrq-max authored and anguy11 committed Sep 14, 2020
1 parent f49be6d commit 1fa5cef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/intel/i40e/i40e_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ static struct i40e_rx_buffer *i40e_get_rx_buffer(struct i40e_ring *rx_ring,
struct i40e_rx_buffer *rx_buffer;

rx_buffer = i40e_rx_bi(rx_ring, rx_ring->next_to_clean);
prefetchw(rx_buffer->page);
prefetch_page_address(rx_buffer->page);

/* we are reusing so sync this buffer for CPU use */
dma_sync_single_range_for_cpu(rx_ring->dev,
Expand Down
8 changes: 8 additions & 0 deletions include/linux/prefetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <asm/processor.h>
#include <asm/cache.h>

struct page;
/*
prefetch(x) attempts to pre-emptively get the memory pointed to
by address "x" into the CPU L1 cache.
Expand Down Expand Up @@ -62,4 +63,11 @@ static inline void prefetch_range(void *addr, size_t len)
#endif
}

static inline void prefetch_page_address(struct page *page)
{
#if defined(WANT_PAGE_VIRTUAL) || defined(HASHED_PAGE_VIRTUAL)
prefetch(page);
#endif
}

#endif

0 comments on commit 1fa5cef

Please sign in to comment.