[Devel] [PATCH RHEL COMMIT] net/drivers/i40e: suppress warning on skb linearization

Konstantin Khorenko khorenko at virtuozzo.com
Thu Sep 30 16:04:07 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit efa2b3e920caf66766cea03e6de6740c32b2ce59
Author: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Date:   Thu Sep 30 16:04:07 2021 +0300

    net/drivers/i40e: suppress warning on skb linearization
    
    Preallocate required memory with reasoned flags and skip memory
    allocation step made by __pskb_pull_tail.
    
    https://pmc.acronis.com/browse/VSTOR-22811
    Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
    
    Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    khorenko@:
    * skb buffer is provided to DMA zone, so allocation cannot be switched to
      kvmalloc(), so we just supress the warning here.
    
    * i40e_skb_linearize() code is taken from __pskb_pull_tail(),
      except for the size: we omit "+128" preallocation here
      because no future expansions are expected in this case.
    
    * there is another similar place: i40e_xmit_frame_ring() in i40evf/i40e_txrx.c,
      but as we did not trigger the warning there and as we just shut up the warning,
      we don't touch the second place in advance.
    
    https://jira.sw.ru/browse/PSBM-127846
    (cherry-picked from vz7 commit 9b2d96420858 ("net/drivers/i40e: suppress
    warning on skb linearization"))
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    
    (cherry picked from vz8 commit ec1793e41ef5bffd082395bac3ace24a946d51ce)
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 74143f3480b5..084169d98495 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -3734,6 +3734,23 @@ static int i40e_xmit_xdp_ring(struct xdp_frame *xdpf,
 	return I40E_XDP_TX;
 }
 
+
+static int i40e_skb_linearize(struct sk_buff *skb)
+{
+	int eat = (skb->tail + skb->data_len) - skb->end;
+
+	/* workaround to avoid allocation without __GFP_ORDER_NOWARN inside
+	 * __pskb_pull_tail()
+	 */
+	if (eat > 0 || skb_cloned(skb)) {
+		if (pskb_expand_head(skb, 0, eat > 0 ? eat : 0,
+				     GFP_ATOMIC | __GFP_ORDER_NOWARN))
+			return -ENOMEM;
+	}
+
+	return __skb_linearize(skb);
+}
+
 /**
  * i40e_xmit_frame_ring - Sends buffer on Tx ring
  * @skb:     send buffer
@@ -3762,7 +3779,7 @@ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb,
 
 	count = i40e_xmit_descriptor_count(skb);
 	if (i40e_chk_linearize(skb, count)) {
-		if (__skb_linearize(skb)) {
+		if (i40e_skb_linearize(skb)) {
 			dev_kfree_skb_any(skb);
 			return NETDEV_TX_OK;
 		}


More information about the Devel mailing list