DPDK usage discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Lokesh Chakka <lvenkatakumarchakka@gmail.com>
Cc: users <users@dpdk.org>
Subject: Re: mbuf validity in conjunction with ref cnt
Date: Fri, 21 Feb 2025 10:46:06 -0800	[thread overview]
Message-ID: <20250221104606.60dafc66@hermes.local> (raw)
In-Reply-To: <CACh--sjc80K+O=kHZ2JoW2H3emrz=vjAZPCZ_FkOh9bvPJZgJg@mail.gmail.com>

On Fri, 21 Feb 2025 13:09:34 +0530
Lokesh Chakka <lvenkatakumarchakka@gmail.com> wrote:

> Hello,
> 
> I've created mbuf using rte_pktmbuf_alloc.
> Just after creating mbuf rte_mbuf_refcnt_read is giving 1.
> 
> After rte_eth_tx_burst, rte_mbuf_refcnt_read is giving 1.
> 
> Even
>       rte_eth_tx_burst
>       sleep(10);
>        rte_mbuf_refcnt_read
> is still giving 1
> 
> Even
>       rte_eth_tx_burst
>       sleep(10);
>        rte_mbuf_refcnt_read // is still giving 1
>        rte_pktmbuf_free
>       sleep(10);
>        rte_mbuf_refcnt_read // is still giving 1
> 
> Does it mean mbuf can be reused like
>         while(1)
>         {
>                   rte_eth_tx_burst
>         }
> 
> 
> Thanks & Regards
> --
> Lokesh Chakka.

Once you gave the mbuf to the driver, with a refcnt of 1 it
means the driver will free it. Any later reference is a use after free.
The driver will free it at an undetermined time after sending.
Some drivers defer the free until a later reclaim cycle (next send).

When mbuf is freed, the refcnt does not
go to zero, it just moves into the mbuf free pool.
Read the the source for more details.

There is no callback in DPDK for when mbuf is actually sent or freed.


  reply	other threads:[~2025-02-21 18:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21  7:39 Lokesh Chakka
2025-02-21 18:46 ` Stephen Hemminger [this message]
2025-02-22  4:52   ` Lokesh Chakka
2025-02-22 16:18     ` Stephen Hemminger

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=20250221104606.60dafc66@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=lvenkatakumarchakka@gmail.com \
    --cc=users@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).