Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Jason Wang <jasowang@redhat.com>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
virtualization@lists.linux-foundation.org, bpf@vger.kernel.org
Subject: Re: [PATCH net v2 0/2] virtio-net: fix for build_skb()
Date: Mon, 2 Aug 2021 12:58:18 -0400 [thread overview]
Message-ID: <20210802125720-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210730051643.54198a9e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On Fri, Jul 30, 2021 at 05:16:43AM -0700, Jakub Kicinski wrote:
> On Tue, 1 Jun 2021 07:06:43 -0400 Michael S. Tsirkin wrote:
> > On Tue, Jun 01, 2021 at 02:39:58PM +0800, Xuan Zhuo wrote:
> > > #1 Fixed a serious error.
> > > #2 Fixed a logical error, but this error did not cause any serious consequences.
> > >
> > > The logic of this piece is really messy. Fortunately, my refactored patch can be
> > > completed with a small amount of testing.
> >
> > Looks good, thanks!
> > Also needed for stable I think.
> >
> > Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> Just a heads up folks, looks like we ended up merging both this and the
> net-next version of the patch set:
>
> 8fb7da9e9907 virtio_net: get build_skb() buf by data ptr
> 5c37711d9f27 virtio-net: fix for unable to handle page fault for address
>
> and
>
> 7bf64460e3b2 virtio-net: get build_skb() buf by data ptr
> 6c66c147b9a4 virtio-net: fix for unable to handle page fault for address
>
> Are you okay with the code as is or should we commit something like:
Yes:
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Will you post this one then?
> ---
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 56c3f8519093..74482a52f076 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -380,7 +380,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> struct page *page, unsigned int offset,
> unsigned int len, unsigned int truesize,
> bool hdr_valid, unsigned int metasize,
> - bool whole_page)
> + unsigned int headroom)
> {
> struct sk_buff *skb;
> struct virtio_net_hdr_mrg_rxbuf *hdr;
> @@ -398,28 +398,16 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> else
> hdr_padded_len = sizeof(struct padded_vnet_hdr);
>
> - /* If whole_page, there is an offset between the beginning of the
> + /* If headroom is not 0, there is an offset between the beginning of the
> * data and the allocated space, otherwise the data and the allocated
> * space are aligned.
> *
> * Buffers with headroom use PAGE_SIZE as alloc size, see
> * add_recvbuf_mergeable() + get_mergeable_buf_len()
> */
> - if (whole_page) {
> - /* Buffers with whole_page use PAGE_SIZE as alloc size,
> - * see add_recvbuf_mergeable() + get_mergeable_buf_len()
> - */
> - truesize = PAGE_SIZE;
> -
> - /* page maybe head page, so we should get the buf by p, not the
> - * page
> - */
> - tailroom = truesize - len - offset_in_page(p);
> - buf = (char *)((unsigned long)p & PAGE_MASK);
> - } else {
> - tailroom = truesize - len;
> - buf = p;
> - }
> + truesize = headroom ? PAGE_SIZE : truesize;
> + tailroom = truesize - len - headroom;
> + buf = p - headroom;
>
> len -= hdr_len;
> offset += hdr_padded_len;
> @@ -978,7 +966,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
> put_page(page);
> head_skb = page_to_skb(vi, rq, xdp_page, offset,
> len, PAGE_SIZE, false,
> - metasize, true);
> + metasize,
> + VIRTIO_XDP_HEADROOM);
> return head_skb;
> }
> break;
> @@ -1029,7 +1018,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
> rcu_read_unlock();
>
> head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog,
> - metasize, !!headroom);
> + metasize, headroom);
> curr_skb = head_skb;
>
> if (unlikely(!curr_skb))
next prev parent reply other threads:[~2021-08-02 16:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 6:39 Xuan Zhuo
2021-06-01 6:39 ` [PATCH net v2 1/2] virtio-net: fix for unable to handle page fault for address Xuan Zhuo
2021-06-01 8:53 ` Jason Wang
2021-06-01 6:40 ` [PATCH net v2 2/2] virtio_net: get build_skb() buf by data ptr Xuan Zhuo
2021-06-01 8:55 ` Jason Wang
2021-06-01 11:06 ` [PATCH net v2 0/2] virtio-net: fix for build_skb() Michael S. Tsirkin
2021-07-30 12:16 ` Jakub Kicinski
2021-08-02 4:45 ` Jason Wang
2021-08-02 16:58 ` Michael S. Tsirkin [this message]
2021-06-01 22:30 ` patchwork-bot+netdevbpf
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=20210802125720-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.com \
--subject='Re: [PATCH net v2 0/2] virtio-net: fix for build_skb()' \
/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
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).