From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Toshiaki Makita <toshiaki.makita1@gmail.com>
Cc: bpf@vger.kernel.org, tom@herbertland.com,
"Eric Dumazet" <eric.dumazet@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Paolo Abeni" <pabeni@redhat.com>,
"Toke Høiland-Jørgensen" <toke@toke.dk>,
dsahern@kernel.org, makita.toshiaki@lab.ntt.co.jp,
kernel-team@cloudflare.com, phil@nwl.cc, netdev@vger.kernel.org,
"Jakub Kicinski" <kuba@kernel.org>
Subject: Re: [PATCH net-next V5 2/2] veth: apply qdisc backpressure on full ptr_ring to reduce TX drops
Date: Fri, 18 Apr 2025 22:08:05 +0200 [thread overview]
Message-ID: <e49b96fa-6b2c-4722-adcc-7639f1a9a66a@kernel.org> (raw)
In-Reply-To: <8265c592-a51f-4b26-9e6d-df69c16aebf4@gmail.com>
On 18/04/2025 14.38, Toshiaki Makita wrote:
> On 2025/04/17 22:55, Jesper Dangaard Brouer wrote:
> ...
>> + case NETDEV_TX_BUSY:
>> + /* If a qdisc is attached to our virtual device, returning
>> + * NETDEV_TX_BUSY is allowed.
>> + */
>> + txq = netdev_get_tx_queue(dev, rxq);
>> +
>> + if (qdisc_txq_has_no_queue(txq)) {
>> + dev_kfree_skb_any(skb);
>> + goto drop;
>> + }
>> + netif_tx_stop_queue(txq);
>> + /* Restore Eth hdr pulled by dev_forward_skb/eth_type_trans */
>> + __skb_push(skb, ETH_HLEN);
>> + if (use_napi)
>> + __veth_xdp_flush(rq);
>> + /* Cancel TXQ stop for very unlikely race */
>> + if (unlikely(__ptr_ring_empty(&rq->xdp_ring)))
>> + netif_tx_wake_queue(txq);
>
> xdp_ring is only initialized when use_napi is not NULL.
> Should add "if (use_napi)" ?
>
We actually don't need the "if (use_napi)" check, because this code path
cannot be invoked without use_name set. This also means the check
before __veth_xdp_flush() is unnecessary. I still added it, because it
is subtle that this isn't needed and if code change slightly is will be
needed.
Regarding xdp_ring is only initialized when use_napi is not NULL, I'm
considering not adding a if(use_napi) check, because this code path
cannot be called without use_napi is true, and if that change in the
future, then it's better that the code crash. Different opinions are
welcomed...
> BTW, you added a check for the ring_empty here. so
>
> if empty:
> this function starts the queue by itself
> else:
> it is guaranteed that veth_xdp_rcv() consumes the ring after this point.
> so the rcv side definitely starts the queue.
>
> With that, __veth_xdp_flush invocation seems to be unnecessary,
> if your concern is starting the queue.
That is actually correct. I'm trying to catch the race in two different
ways. The __ptr_ring_empty() will be sufficient, to cover both cases.
I'll try to think of a good comment that explains, the parring with the
!__ptr_ring_empty() check in veth_poll().
--Jesper
prev parent reply other threads:[~2025-04-18 20:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 13:55 [PATCH net-next V5 0/2] veth: qdisc backpressure and qdisc check refactor Jesper Dangaard Brouer
2025-04-17 13:55 ` [PATCH net-next V5 1/2] net: sched: generalize check for no-queue qdisc on TX queue Jesper Dangaard Brouer
2025-04-17 13:55 ` [PATCH net-next V5 2/2] veth: apply qdisc backpressure on full ptr_ring to reduce TX drops Jesper Dangaard Brouer
2025-04-18 12:38 ` Toshiaki Makita
2025-04-18 20:08 ` Jesper Dangaard Brouer [this message]
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=e49b96fa-6b2c-4722-adcc-7639f1a9a66a@kernel.org \
--to=hawk@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=eric.dumazet@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phil@nwl.cc \
--cc=toke@toke.dk \
--cc=tom@herbertland.com \
--cc=toshiaki.makita1@gmail.com \
/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