From: "Michael S. Tsirkin" <mst@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: songliubraving@fb.com, gustavoars@kernel.org,
kvm@vger.kernel.org, decui@microsoft.com, ast@kernel.org,
virtualization@lists.linux-foundation.org,
linux-kselftest@vger.kernel.org, steffen.klassert@secunet.com,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
herbert@gondor.apana.org.au, daniel@iogearbox.net,
john.fastabend@gmail.com, andrii@kernel.org, yhs@fb.com,
pabeni@redhat.com, pablo@netfilter.org, elver@google.com,
kpsingh@kernel.org,
Yuri Benditovich <yuri.benditovich@daynix.com>,
cai@lca.pw, kuba@kernel.org, willemb@google.com,
netdev@vger.kernel.org, rdunlap@infradead.org,
linux-kernel@vger.kernel.org, davem@davemloft.net,
nogikh@google.com, bpf@vger.kernel.org, kafai@fb.com
Subject: Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature
Date: Mon, 9 Oct 2023 07:50:10 -0400 [thread overview]
Message-ID: <20231009074840-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <48e20be1-b658-4117-8856-89ff1df6f48f@daynix.com>
On Mon, Oct 09, 2023 at 05:44:20PM +0900, Akihiko Odaki wrote:
> On 2023/10/09 17:13, Willem de Bruijn wrote:
> > On Sun, Oct 8, 2023 at 12:22 AM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
> > >
> > > virtio-net have two usage of hashes: one is RSS and another is hash
> > > reporting. Conventionally the hash calculation was done by the VMM.
> > > However, computing the hash after the queue was chosen defeats the
> > > purpose of RSS.
> > >
> > > Another approach is to use eBPF steering program. This approach has
> > > another downside: it cannot report the calculated hash due to the
> > > restrictive nature of eBPF.
> > >
> > > Introduce the code to compute hashes to the kernel in order to overcome
> > > thse challenges. An alternative solution is to extend the eBPF steering
> > > program so that it will be able to report to the userspace, but it makes
> > > little sense to allow to implement different hashing algorithms with
> > > eBPF since the hash value reported by virtio-net is strictly defined by
> > > the specification.
> > >
> > > The hash value already stored in sk_buff is not used and computed
> > > independently since it may have been computed in a way not conformant
> > > with the specification.
> > >
> > > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> >
> > > @@ -2116,31 +2172,49 @@ static ssize_t tun_put_user(struct tun_struct *tun,
> > > }
> > >
> > > if (vnet_hdr_sz) {
> > > - struct virtio_net_hdr gso;
> > > + union {
> > > + struct virtio_net_hdr hdr;
> > > + struct virtio_net_hdr_v1_hash v1_hash_hdr;
> > > + } hdr;
> > > + int ret;
> > >
> > > if (iov_iter_count(iter) < vnet_hdr_sz)
> > > return -EINVAL;
> > >
> > > - if (virtio_net_hdr_from_skb(skb, &gso,
> > > - tun_is_little_endian(tun), true,
> > > - vlan_hlen)) {
> > > + if ((READ_ONCE(tun->vnet_hash.flags) & TUN_VNET_HASH_REPORT) &&
> > > + vnet_hdr_sz >= sizeof(hdr.v1_hash_hdr) &&
> > > + skb->tun_vnet_hash) {
> >
> > Isn't vnet_hdr_sz guaranteed to be >= hdr.v1_hash_hdr, by virtue of
> > the set hash ioctl failing otherwise?
> >
> > Such checks should be limited to control path where possible
>
> There is a potential race since tun->vnet_hash.flags and vnet_hdr_sz are not
> read at once.
And then it's a complete mess and you get inconsistent
behaviour with packets getting sent all over the place, right?
So maybe keep a pointer to this struct so it can be
changed atomically then. Maybe even something with rcu I donnu.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-10-09 11:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231008052101.144422-1-akihiko.odaki@daynix.com>
2023-10-08 18:36 ` [RFC PATCH 0/7] tun: Introduce virtio-net hashing feature Willem de Bruijn
[not found] ` <20231008052101.144422-2-akihiko.odaki@daynix.com>
2023-10-08 18:39 ` [RFC PATCH 1/7] net: skbuff: Add tun_vnet_hash flag Willem de Bruijn
[not found] ` <20231008052101.144422-6-akihiko.odaki@daynix.com>
2023-10-08 19:07 ` [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature Willem de Bruijn
[not found] ` <8f4ad5bc-b849-4ef4-ac1f-8d5a796205e9@daynix.com>
2023-10-08 20:08 ` Willem de Bruijn
[not found] ` <286508a3-3067-456d-8bbf-176b00dcc0c6@daynix.com>
2023-10-09 8:04 ` Willem de Bruijn
[not found] ` <8711b549-094d-4be2-b7af-bd93b7516c05@daynix.com>
2023-10-09 9:57 ` Willem de Bruijn
[not found] ` <695a0611-2b19-49f9-8d32-cfea3b7df0b2@daynix.com>
2023-10-09 10:06 ` Willem de Bruijn
[not found] ` <5baab0cf-7adf-475d-8968-d46ddd179f9a@daynix.com>
2023-10-09 10:44 ` Willem de Bruijn
[not found] ` <8f3ed081-134c-45a0-9208-c1cab29cdf37@daynix.com>
2023-10-10 5:45 ` Jason Wang
[not found] ` <8a44e14c-03c4-44e2-8c72-9d751c63dffe@daynix.com>
2023-10-10 6:00 ` Jason Wang
[not found] ` <0d491319-8ce9-4922-89c9-a48c4c5c03bc@daynix.com>
2023-10-11 3:18 ` Jason Wang
2023-10-09 8:13 ` Willem de Bruijn
[not found] ` <48e20be1-b658-4117-8856-89ff1df6f48f@daynix.com>
2023-10-09 9:54 ` Willem de Bruijn
[not found] ` <6a698c99-6f02-4cfb-a709-ba02296a05f7@daynix.com>
2023-10-09 10:07 ` Willem de Bruijn
[not found] ` <eab359ec-3bb9-4245-8ac3-097d66ef30a9@daynix.com>
2023-10-09 10:32 ` Willem de Bruijn
2023-10-09 11:50 ` Michael S. Tsirkin [this message]
2023-10-09 11:38 ` Michael S. Tsirkin
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=20231009074840-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cai@lca.pw \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=elver@google.com \
--cc=gustavoars@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nogikh@google.com \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=rdunlap@infradead.org \
--cc=songliubraving@fb.com \
--cc=steffen.klassert@secunet.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=yhs@fb.com \
--cc=yuri.benditovich@daynix.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;
as well as URLs for NNTP newsgroup(s).