From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Toshiaki Makita" <makita.toshiaki@lab.ntt.co.jp>,
"David Ahern" <dsahern@gmail.com>,
"Toke Høiland-Jørgensen" <toke@toke.dk>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
brouer@redhat.com, "John Fastabend" <john.fastabend@gmail.com>
Subject: Re: virtio_net: suspicious RCU usage with xdp
Date: Fri, 26 Apr 2019 13:05:50 +0200 [thread overview]
Message-ID: <20190426130550.7bb1d4bd@carbon> (raw)
In-Reply-To: <8bcd6aba-ea18-7e20-b883-3b926b9a2c07@redhat.com>
On Fri, 26 Apr 2019 16:00:28 +0800
Jason Wang <jasowang@redhat.com> wrote:
> On 2019/4/26 上午1:41, Jesper Dangaard Brouer wrote:
> > It does sound like my commit 5d053f9da431 ("bpf: devmap prepare xdp
> > frames for bulking") introduced this issue. I guess we can add the RCU
> > section to xdp_do_flush_map(), and then also verify that the devmap
> > (and cpumap) take-down code also have appropriate RCU sections (which
> > they should have).
> >
> > Another requirement for calling .ndo_xdp_xmit is running under NAPI
> > protection,
>
>
> May I know the reason for this? I'm asking since if the packet was
> redirected from tuntap, ndo_xdp_xmit() won't be called under the
> protection of NAPI (but bh is disabled).
There are a number of things that rely on this NAPI/softirq protection.
One is preempt-free access per-cpu struct bpf_redirect_info. Which is
at the core of the XDP and TC redirect feature.
DEFINE_PER_CPU(struct bpf_redirect_info, bpf_redirect_info);
EXPORT_PER_CPU_SYMBOL_GPL(bpf_redirect_info);
struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
And devmap and cpumap also have per-cpu variables, that we don't use
preempt-disable around.
Another is xdp_return_frame_rx_napi() that when page_pool is active,
can store frames to be recycled directly into an array, in function
__page_pool_recycle_direct() (but as I don't trust every driver getting
this correct I've added a safe-guard in page-pool via
in_serving_softirq().
I guess, disable_bh is sufficient protection, as we are mostly
optimizing away a preempt-disable when accessing per-cpu variables.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2019-04-26 11:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 17:13 virtio_net: suspicious RCU usage with xdp David Ahern
2019-04-24 17:37 ` Michael S. Tsirkin
2019-04-24 17:40 ` David Ahern
2019-04-25 2:56 ` Jason Wang
2019-04-25 2:55 ` Jason Wang
2019-04-25 4:58 ` Toshiaki Makita
2019-04-25 17:03 ` Michael S. Tsirkin
2019-04-25 17:41 ` Jesper Dangaard Brouer
2019-04-25 17:44 ` David Ahern
2019-04-25 18:54 ` Maciej Fijalkowski
2019-04-25 20:04 ` David Ahern
2019-04-25 20:12 ` Jesper Dangaard Brouer
2019-04-26 7:42 ` Toshiaki Makita
2019-04-26 8:00 ` Jason Wang
2019-04-26 11:05 ` Jesper Dangaard Brouer [this message]
2019-04-28 3:06 ` Jason Wang
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=20190426130550.7bb1d4bd@carbon \
--to=brouer@redhat.com \
--cc=dsahern@gmail.com \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=toke@toke.dk \
/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).