0017-i40e-Fix-memory-leak-related-filter-programming-stat.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Alexander Duyck <[email protected]>
  3. Date: Wed, 4 Oct 2017 08:44:43 -0700
  4. Subject: [PATCH] i40e: Fix memory leak related filter programming status
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. It looks like we weren't correctly placing the pages from buffers that had
  9. been used to return a filter programming status back on the ring. As a
  10. result they were being overwritten and tracking of the pages was lost.
  11. This change works to correct that by incorporating part of
  12. i40e_put_rx_buffer into the programming status handler code. As a result we
  13. should now be correctly placing the pages for those buffers on the
  14. re-allocation list instead of letting them stay in place.
  15. Fixes: 0e626ff7ccbf ("i40e: Fix support for flow director programming status")
  16. Reported-by: Anders K. Pedersen <[email protected]>
  17. Signed-off-by: Alexander Duyck <[email protected]>
  18. Tested-by: Anders K Pedersen <[email protected]>
  19. Signed-off-by: Jeff Kirsher <[email protected]>
  20. (cherry picked from commit 2b9478ffc550f17c6cd8c69057234e91150f5972)
  21. Signed-off-by: Fabian Grünbichler <[email protected]>
  22. ---
  23. drivers/net/ethernet/intel/i40e/i40e_txrx.c | 63 ++++++++++++++++-------------
  24. 1 file changed, 36 insertions(+), 27 deletions(-)
  25. diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
  26. index 2194960d5855..391b1878c24b 100644
  27. --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
  28. +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
  29. @@ -1042,6 +1042,32 @@ static bool i40e_set_new_dynamic_itr(struct i40e_ring_container *rc)
  30. return false;
  31. }
  32. +/**
  33. + * i40e_reuse_rx_page - page flip buffer and store it back on the ring
  34. + * @rx_ring: rx descriptor ring to store buffers on
  35. + * @old_buff: donor buffer to have page reused
  36. + *
  37. + * Synchronizes page for reuse by the adapter
  38. + **/
  39. +static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
  40. + struct i40e_rx_buffer *old_buff)
  41. +{
  42. + struct i40e_rx_buffer *new_buff;
  43. + u16 nta = rx_ring->next_to_alloc;
  44. +
  45. + new_buff = &rx_ring->rx_bi[nta];
  46. +
  47. + /* update, and store next to alloc */
  48. + nta++;
  49. + rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
  50. +
  51. + /* transfer page from old buffer to new buffer */
  52. + new_buff->dma = old_buff->dma;
  53. + new_buff->page = old_buff->page;
  54. + new_buff->page_offset = old_buff->page_offset;
  55. + new_buff->pagecnt_bias = old_buff->pagecnt_bias;
  56. +}
  57. +
  58. /**
  59. * i40e_rx_is_programming_status - check for programming status descriptor
  60. * @qw: qword representing status_error_len in CPU ordering
  61. @@ -1076,15 +1102,24 @@ static void i40e_clean_programming_status(struct i40e_ring *rx_ring,
  62. union i40e_rx_desc *rx_desc,
  63. u64 qw)
  64. {
  65. - u32 ntc = rx_ring->next_to_clean + 1;
  66. + struct i40e_rx_buffer *rx_buffer;
  67. + u32 ntc = rx_ring->next_to_clean;
  68. u8 id;
  69. /* fetch, update, and store next to clean */
  70. + rx_buffer = &rx_ring->rx_bi[ntc++];
  71. ntc = (ntc < rx_ring->count) ? ntc : 0;
  72. rx_ring->next_to_clean = ntc;
  73. prefetch(I40E_RX_DESC(rx_ring, ntc));
  74. + /* place unused page back on the ring */
  75. + i40e_reuse_rx_page(rx_ring, rx_buffer);
  76. + rx_ring->rx_stats.page_reuse_count++;
  77. +
  78. + /* clear contents of buffer_info */
  79. + rx_buffer->page = NULL;
  80. +
  81. id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >>
  82. I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
  83. @@ -1643,32 +1678,6 @@ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb,
  84. return false;
  85. }
  86. -/**
  87. - * i40e_reuse_rx_page - page flip buffer and store it back on the ring
  88. - * @rx_ring: rx descriptor ring to store buffers on
  89. - * @old_buff: donor buffer to have page reused
  90. - *
  91. - * Synchronizes page for reuse by the adapter
  92. - **/
  93. -static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
  94. - struct i40e_rx_buffer *old_buff)
  95. -{
  96. - struct i40e_rx_buffer *new_buff;
  97. - u16 nta = rx_ring->next_to_alloc;
  98. -
  99. - new_buff = &rx_ring->rx_bi[nta];
  100. -
  101. - /* update, and store next to alloc */
  102. - nta++;
  103. - rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
  104. -
  105. - /* transfer page from old buffer to new buffer */
  106. - new_buff->dma = old_buff->dma;
  107. - new_buff->page = old_buff->page;
  108. - new_buff->page_offset = old_buff->page_offset;
  109. - new_buff->pagecnt_bias = old_buff->pagecnt_bias;
  110. -}
  111. -
  112. /**
  113. * i40e_page_is_reusable - check if any reuse is possible
  114. * @page: page struct to check
  115. --
  116. 2.14.2