From: "Li,Rongqing" <lirongqing@baidu.com>
To: "Loftus, Ciara" <ciara.loftus@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/2] af_xdp: avoid to unnecessary allocation and free mbuf
Date: Fri, 18 Sep 2020 11:16:31 +0000 [thread overview]
Message-ID: <0911565e9178402699ed56264f3eab48@baidu.com> (raw)
In-Reply-To: <a3fac55ba7054bee82966009d01dd793@intel.com>
> -----Original Message-----
> From: Loftus, Ciara [mailto:ciara.loftus@intel.com]
> Sent: Friday, September 18, 2020 5:39 PM
> To: Li,Rongqing <lirongqing@baidu.com>
> Cc: dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH 2/2] af_xdp: avoid to unnecessary allocation and
> free mbuf
>
> >
> > optimize rx performance, by allocating mbuf based on result of
> > xsk_ring_cons__peek, to avoid to redundancy allocation, and free mbuf
> > when receive packets
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > Signed-off-by: Dongsheng Rong <rongdongsheng@baidu.com>
> > ---
> > drivers/net/af_xdp/rte_eth_af_xdp.c | 64
> > ++++++++++++++++---------------
> > ------
> > 1 file changed, 27 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> > b/drivers/net/af_xdp/rte_eth_af_xdp.c
> > index 7ce4ad04a..48824050e 100644
> > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> > @@ -229,28 +229,29 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf
> > **bufs, uint16_t nb_pkts)
> > struct xsk_umem_info *umem = rxq->umem;
> > uint32_t idx_rx = 0;
> > unsigned long rx_bytes = 0;
> > - int rcvd, i;
> > + int i;
> > struct rte_mbuf *fq_bufs[ETH_AF_XDP_RX_BATCH_SIZE];
> >
> > - /* allocate bufs for fill queue replenishment after rx */
> > - if (rte_pktmbuf_alloc_bulk(umem->mb_pool, fq_bufs, nb_pkts)) {
> > - AF_XDP_LOG(DEBUG,
> > - "Failed to get enough buffers for fq.\n");
> > - return 0;
> > - }
> >
> > - rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
> > + nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
> >
> > - if (rcvd == 0) {
> > + if (nb_pkts == 0) {
> > #if defined(XDP_USE_NEED_WAKEUP)
> > if (xsk_ring_prod__needs_wakeup(&umem->fq))
> > (void)poll(rxq->fds, 1, 1000);
> > #endif
> >
> > - goto out;
> > + return 0;
> > }
> >
> > - for (i = 0; i < rcvd; i++) {
> > + /* allocate bufs for fill queue replenishment after rx */
> > + if (rte_pktmbuf_alloc_bulk(umem->mb_pool, fq_bufs, nb_pkts)) {
> > + AF_XDP_LOG(DEBUG,
> > + "Failed to get enough buffers for fq.\n");
>
> Thanks for this patch. I've considered this in the past.
> There is a problem if we hit this condition.
> We advance the rx producer @ xsk_ring_cons__peek.
> But if we have no mbufs to hold the rx data, it is lost.
> That's why we allocate the mbufs up front now.
True, thanks
-Li
next prev parent reply other threads:[~2020-09-18 11:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 5:11 [dpdk-dev] [PATCH 1/2] af_xdp: not return a negative value in af_xdp_rx_zc Li RongQing
2020-09-17 5:11 ` [dpdk-dev] [PATCH 2/2] af_xdp: avoid to unnecessary allocation and free mbuf Li RongQing
2020-09-18 9:38 ` Loftus, Ciara
2020-09-18 11:16 ` Li,Rongqing [this message]
2020-09-20 6:02 ` Li,Rongqing
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=0911565e9178402699ed56264f3eab48@baidu.com \
--to=lirongqing@baidu.com \
--cc=ciara.loftus@intel.com \
--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).