From: Ariel Otilibili <ariel.otilibili@6wind.com>
To: Maryam Tahhan <mtahhan@redhat.com>
Cc: dev@dpdk.org, stable@dpdk.org,
Thomas Monjalon <thomas@monjalon.net>,
David Marchand <david.marchand@redhat.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Ciara Loftus <ciara.loftus@intel.com>
Subject: Re: [PATCH v3 2/2] net/af_xdp: Refactor af_xdp_tx_zc()
Date: Fri, 31 Jan 2025 00:06:44 +0100 [thread overview]
Message-ID: <CAF1zDgbFkCA9vT=m_cBLM_zHQDL_GVQAceRCMxX+ATOE_7-RpA@mail.gmail.com> (raw)
In-Reply-To: <f067b5ea-ade9-4b2d-8a66-9f8446138bb5@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3053 bytes --]
Hello Maryam,
On Wed, Jan 29, 2025 at 6:58 PM Maryam Tahhan <mtahhan@redhat.com> wrote:
> > +static struct rte_mbuf *
> > +maybe_kick_tx(struct pkt_tx_queue *txq, uint32_t *idx_tx, struct
> rte_mbuf *mbuf)
> > +{
> > + struct rte_mbuf *ret = mbuf;
> > +
> > + if (!xsk_ring_prod__reserve(&txq->tx, 1, idx_tx)) {
> > + kick_tx(txq, &txq->pair->cq);
> > + if (!xsk_ring_prod__reserve(&txq->tx, 1, idx_tx))
> > + ret = NULL;
> > + }
> > +
> > + return ret;
> > +}
>
>
> [MT] I don't see why we are passing in mbuf here?
>
My aim was to use the output of maybe_kick_tx() for the if statement on
local_buf: the true leg would copy mbuf into local_mbuf, and the false
would create a fresh local_mbuf
> > +static void
> > +maybe_cpy_pkt(bool is_mbuf_equal, struct xsk_umem_info *umem,
> > + uint64_t addr_plus_offset, struct rte_mbuf *mbuf,
> > + struct xdp_desc *desc)
> > +{
> > + void *pkt;
> > +
> > + if(is_mbuf_equal)
> > + goto out;
> > +
> > + pkt = xsk_umem__get_data(umem->buffer, addr_plus_offset);
> > + rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), desc->len);
> > + rte_pktmbuf_free(mbuf);
> > +
> > +out:
> > + return;
> > +}
>
>
> [MT] does this really need to be an inline function? it wasn't common
> code between the blocks?
>
In order for the next statements to just fall through till the exit. The
loop would have read as such:
1. Some boiler plate to check if mbuf is equal to umem; and the creation of
local_mbuf accordingly
2. If local_mbuf is null, goto exit.
3. Else, update addr, offset, and description
> Firstly thank you for your efforts to clean up the code. I believe a
> simpler cleanup approach would better balance readability +
> maintainability. This approach would focus on eliminating the repeated
> code in both branches of the conditional block. For me the main
> repetition between the branches is the code that reserves and fills the
> descriptor info, Please find an example below...
>
Thanks to you, I do appreciate your honest feedback. From what I
understand, you would like to take the filling of addr, offset, and desc
off from af_xdp_tx_zc(), but keep its core logic.
I wanted the boiler plate to be into separate functions, so one could read
through the subsequent statements. So we could avoid the cascade of if
statements.
>
> Note: The following is all untested code (don't even know if it
> compiles) it's just to give an idea around the cleanup I had in mind:
>
The code did compile on the go, that was pretty neat. I cleared out few
warnings, and pushed out a new version
https://inbox.dpdk.org/dev/20250130221853.789366-3-ariel.otilibili@6wind.com/
>
> Please let me know your thoughts, and I’d be happy to discuss further
>
> I improved on the snippets your proposal. It has fewer lines, so fewer
changes.
What matters to me, is that the series be merged.
Have a good day,
Ariel
[-- Attachment #2: Type: text/html, Size: 4486 bytes --]
next prev parent reply other threads:[~2025-01-30 23:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 19:56 [PATCH 0/2] Fix use after free, and refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-16 19:56 ` [PATCH 1/2] net/af_xdp: fix use after free in af_xdp_tx_zc() Ariel Otilibili
2025-01-30 18:24 ` Stephen Hemminger
2025-01-30 22:22 ` Ariel Otilibili
2025-01-16 19:56 ` [PATCH 2/2] net/af_xdp: Refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-16 21:47 ` Stephen Hemminger
2025-01-16 22:20 ` Ariel Otilibili
2025-01-16 22:26 ` Stephen Hemminger
2025-01-16 22:36 ` Ariel Otilibili
2025-01-16 22:51 ` [PATCH v2 0/2] Fix use after free, and refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-16 22:51 ` [PATCH v2 1/2] net/af_xdp: fix use after free in af_xdp_tx_zc() Ariel Otilibili
2025-01-20 14:54 ` Maryam Tahhan
2025-01-21 8:54 ` Ariel Otilibili
2025-01-16 22:51 ` [PATCH v2 2/2] net/af_xdp: Refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-20 15:28 ` Maryam Tahhan
2025-01-21 8:57 ` Ariel Otilibili
2025-01-28 23:11 ` [PATCH v3 0/2] Fix use after free, and refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-28 23:11 ` [PATCH v3 1/2] net/af_xdp: fix use after free in af_xdp_tx_zc() Ariel Otilibili
2025-01-28 23:11 ` [PATCH v3 2/2] net/af_xdp: Refactor af_xdp_tx_zc() Ariel Otilibili
2025-01-29 17:58 ` Maryam Tahhan
2025-01-30 23:06 ` Ariel Otilibili [this message]
2025-01-30 22:18 ` [PATCH v4 0/2] Fix use after free, and refactor af_xdp_tx_zc Ariel Otilibili
2025-01-30 22:18 ` [PATCH v4 1/2] net/af_xdp: Fix use after free in af_xdp_tx_zc Ariel Otilibili
2025-01-30 22:18 ` [PATCH v4 2/2] net/af_xdp: Refactor af_xdp_tx_zc Ariel Otilibili
2025-01-30 23:55 ` 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='CAF1zDgbFkCA9vT=m_cBLM_zHQDL_GVQAceRCMxX+ATOE_7-RpA@mail.gmail.com' \
--to=ariel.otilibili@6wind.com \
--cc=ciara.loftus@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=mtahhan@redhat.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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).