DPDK patches and discussions
 help / color / mirror / Atom feed
From: Evgeniy Marchenko <e.marchenko@ddos-guard.net>
To: dev@dpdk.org
Subject: [dpdk-dev] mbuf cleanup in i40e/ixgbe
Date: Sun, 01 Nov 2015 15:06:55 +0300	[thread overview]
Message-ID: <5105036.dxuAVOzRX1@mentor> (raw)

Hello

I'm checking mbuf consumption issues in TX path and it looks like i40e and 
ixgbe drivers consume all mbufs in "full featured" path and free them one-by-
one only after TX queue wraps.

Upstream drivers are more conservative with memory consumption and free up to 
256 SKBs on every napi_poll invocation. And this makes sense because there is 
indeed not too much work for cleanup and freeing as much memory buffers as 
possible would lower memory pressure and memory requirements and allow bigger 
TX bursts without cleanup procedures and better CPU cache utilization.

Why cannot we bulk free mbuf in i40e_xmit_cleanup ? Why do we need 
nb_tx_to_clean calculations? Isn't it always equal to txq->tx_rs_thresh?

Here is a proposed patch for i40e PMD to bulk free unused mbufs:

----------------------------------- CUT --------------------------------------
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8731712..9e3a333 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -883,8 +883,12 @@ i40e_xmit_cleanup(struct i40e_tx_queue *txq)
        uint16_t nb_tx_desc = txq->nb_tx_desc;
        uint16_t desc_to_clean_to;
        uint16_t nb_tx_to_clean;
+       struct i40e_tx_entry *txe;
+       int i;
 
-       desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
+       nb_tx_to_clean = txq->tx_rs_thresh;
+
+       desc_to_clean_to = (uint16_t)(last_desc_cleaned + nb_tx_to_clean);
        if (desc_to_clean_to >= nb_tx_desc)
                desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
 
@@ -898,12 +902,18 @@ i40e_xmit_cleanup(struct i40e_tx_queue *txq)
                return -1;
        }
 
-       if (last_desc_cleaned > desc_to_clean_to)
-               nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
-                                                       desc_to_clean_to);
-       else
-               nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
-                                       last_desc_cleaned);
+       i = last_desc_cleaned;
+       while (i++ != desc_to_clean_to) {
+               if (i >= nb_tx_desc)
+                       i -= nb_tx_desc;
+
+               txe = &sw_ring[i];
+               RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
+               if (txe->mbuf) {
+                       rte_pktmbuf_free_seg(txe->mbuf);
+                       txe->mbuf = NULL;
+               }
+       }
 
        txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
 
----------------------------------- CUT --------------------------------------

What do you think about cleaning not just txq->tx_rs_thresh mbufs but as many 
as possible?

Regards, Evgeniy Marchenko
DDoS-Guard.net

                 reply	other threads:[~2015-11-01 12:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=5105036.dxuAVOzRX1@mentor \
    --to=e.marchenko@ddos-guard.net \
    --cc=dev@dpdk.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).