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

i40e: optimise prefetch page refcount

refcount of rx_buffer page will be added here originally, so prefetchw
is needed, but after commit 1793668c3b8c ("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 <lkp@intel.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Li RongQing and committed by
Tony Nguyen
1fa5cef2 f49be6dc

+9 -1
+1 -1
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 1953 1953 struct i40e_rx_buffer *rx_buffer; 1954 1954 1955 1955 rx_buffer = i40e_rx_bi(rx_ring, rx_ring->next_to_clean); 1956 - prefetchw(rx_buffer->page); 1956 + prefetch_page_address(rx_buffer->page); 1957 1957 1958 1958 /* we are reusing so sync this buffer for CPU use */ 1959 1959 dma_sync_single_range_for_cpu(rx_ring->dev,
+8
include/linux/prefetch.h
··· 15 15 #include <asm/processor.h> 16 16 #include <asm/cache.h> 17 17 18 + struct page; 18 19 /* 19 20 prefetch(x) attempts to pre-emptively get the memory pointed to 20 21 by address "x" into the CPU L1 cache. ··· 60 59 61 60 for (cp = addr; cp < end; cp += PREFETCH_STRIDE) 62 61 prefetch(cp); 62 + #endif 63 + } 64 + 65 + static inline void prefetch_page_address(struct page *page) 66 + { 67 + #if defined(WANT_PAGE_VIRTUAL) || defined(HASHED_PAGE_VIRTUAL) 68 + prefetch(page); 63 69 #endif 64 70 } 65 71