From: "Björn Töpel" <bjorn.topel@intel.com>
To: "Jesper Dangaard Brouer" <brouer@redhat.com>,
"Björn Töpel" <bjorn.topel@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org,
bpf@vger.kernel.org, magnus.karlsson@intel.com,
davem@davemloft.net, kuba@kernel.org, john.fastabend@gmail.com,
intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH bpf-next 6/6] ixgbe, xsk: finish napi loop if AF_XDP Rx queue is full
Date: Fri, 4 Sep 2020 17:54:42 +0200 [thread overview]
Message-ID: <59da4aa6-dbc5-b366-e84e-0030f6010e55@intel.com> (raw)
In-Reply-To: <20200904173540.3a617eee@carbon>
On 2020-09-04 17:35, Jesper Dangaard Brouer wrote:
> On Fri, 4 Sep 2020 15:53:31 +0200
> Björn Töpel <bjorn.topel@gmail.com> wrote:
>
>> From: Björn Töpel <bjorn.topel@intel.com>
>>
>> Make the AF_XDP zero-copy path aware that the reason for redirect
>> failure was due to full Rx queue. If so, exit the napi loop as soon as
>> possible (exit the softirq processing), so that the userspace AF_XDP
>> process can hopefully empty the Rx queue. This mainly helps the "one
>> core scenario", where the userland process and Rx softirq processing
>> is on the same core.
>>
>> Note that the early exit can only be performed if the "need wakeup"
>> feature is enabled, because otherwise there is no notification
>> mechanism available from the kernel side.
>>
>> This requires that the driver starts using the newly introduced
>> xdp_do_redirect_ext() and xsk_do_redirect_rx_full() functions.
>>
>> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
>> ---
>> drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 23 ++++++++++++++------
>> 1 file changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
>> index 3771857cf887..a4aebfd986b3 100644
>> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
>> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
>> @@ -93,9 +93,11 @@ int ixgbe_xsk_pool_setup(struct ixgbe_adapter *adapter,
>>
>> static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
>> struct ixgbe_ring *rx_ring,
>> - struct xdp_buff *xdp)
>> + struct xdp_buff *xdp,
>> + bool *early_exit)
>> {
>> int err, result = IXGBE_XDP_PASS;
>> + enum bpf_map_type map_type;
>> struct bpf_prog *xdp_prog;
>> struct xdp_frame *xdpf;
>> u32 act;
>> @@ -116,8 +118,13 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
>> result = ixgbe_xmit_xdp_ring(adapter, xdpf);
>> break;
>> case XDP_REDIRECT:
>> - err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog);
>> - result = !err ? IXGBE_XDP_REDIR : IXGBE_XDP_CONSUMED;
>> + err = xdp_do_redirect_ext(rx_ring->netdev, xdp, xdp_prog, &map_type);
>> + if (err) {
>> + *early_exit = xsk_do_redirect_rx_full(err, map_type);
>
> Have you tried calling xdp_do_flush (that calls __xsk_map_flush()) and
> (I guess) xsk_set_rx_need_wakeup() here, instead of stopping the loop?
> (Or doing this in xsk core).
>
Moving the need_wake logic to the xsk core/flush would be a very nice
cleanup. The driver would still need to pass information from the driver
though. Still, much cleaner. I'll take a stab at that. Thanks!
> Looking at the code, the AF_XDP frames are "published" in the queue
> rather late for AF_XDP. Maybe in an orthogonal optimization, have you
> considered "publishing" the ring producer when e.g. the queue is
> half-full?
>
Hmm, I haven't. You mean instead of yielding, you publish/submit? I
*think* I still prefer stopping the processing.
I'll play with this a bit!
Very nice suggestions, Jesper! Thanks!
Björn
next prev parent reply other threads:[~2020-09-04 15:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 13:53 [PATCH bpf-next 0/6] xsk: exit NAPI loop when AF_XDP Rx ring is full Björn Töpel
2020-09-04 13:53 ` [PATCH bpf-next 1/6] xsk: improve xdp_do_redirect() error codes Björn Töpel
2020-09-04 13:53 ` [PATCH bpf-next 2/6] xdp: introduce xdp_do_redirect_ext() function Björn Töpel
2020-09-04 13:53 ` [PATCH bpf-next 3/6] xsk: introduce xsk_do_redirect_rx_full() helper Björn Töpel
2020-09-04 15:11 ` Jesper Dangaard Brouer
2020-09-04 15:39 ` Björn Töpel
2020-09-07 12:45 ` Jesper Dangaard Brouer
2020-09-04 13:53 ` [PATCH bpf-next 4/6] i40e, xsk: finish napi loop if AF_XDP Rx queue is full Björn Töpel
2020-09-04 13:53 ` [PATCH bpf-next 5/6] ice, " Björn Töpel
2020-09-04 13:53 ` [PATCH bpf-next 6/6] ixgbe, " Björn Töpel
2020-09-04 15:35 ` Jesper Dangaard Brouer
2020-09-04 15:54 ` Björn Töpel [this message]
2020-09-04 13:59 ` [PATCH bpf-next 0/6] xsk: exit NAPI loop when AF_XDP Rx ring " Björn Töpel
2020-09-08 10:32 ` Maxim Mikityanskiy
2020-09-08 11:37 ` Magnus Karlsson
2020-09-08 12:21 ` Björn Töpel
2020-09-09 15:37 ` Jesper Dangaard Brouer
2020-09-04 14:27 ` Jesper Dangaard Brouer
2020-09-04 14:32 ` Björn Töpel
2020-09-04 23:58 ` Jakub Kicinski
2020-09-07 13:37 ` Björn Töpel
2020-09-07 18:40 ` Jakub Kicinski
2020-09-08 6:58 ` Björn Töpel
2020-09-08 17:24 ` Jakub Kicinski
2020-09-08 18:28 ` Björn Töpel
2020-09-08 18:34 ` Jakub Kicinski
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=59da4aa6-dbc5-b366-e84e-0030f6010e55@intel.com \
--to=bjorn.topel@intel.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.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).