Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>, netdev@vger.kernel.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
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 2/2] virtio_net: get build_skb() buf by data ptr
Date: Tue, 1 Jun 2021 16:55:46 +0800 [thread overview]
Message-ID: <3e0f4152-b41f-5cd4-ee38-95bae89ad1b2@redhat.com> (raw)
In-Reply-To: <20210601064000.66909-3-xuanzhuo@linux.alibaba.com>
在 2021/6/1 下午2:40, Xuan Zhuo 写道:
> In the case of merge, the page passed into page_to_skb() may be a head
> page, not the page where the current data is located. So when trying to
> get the buf where the data is located, we should get buf based on
> headroom instead of offset.
>
> This patch solves this problem. But if you don't use this patch, the
> original code can also run, because if the page is not the page of the
> current data, the calculated tailroom will be less than 0, and will not
> enter the logic of build_skb() . The significance of this patch is to
> modify this logical problem, allowing more situations to use
> build_skb().
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
> drivers/net/virtio_net.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
Acked-by: Jason Wang <jasowang@redhat.com>
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 6b929aca155a..fa407eb8b457 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -401,18 +401,13 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> /* 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 (headroom) {
> - /* Buffers with headroom use PAGE_SIZE as alloc size,
> - * see add_recvbuf_mergeable() + get_mergeable_buf_len()
> - */
> - truesize = PAGE_SIZE;
> - tailroom = truesize - len - offset;
> - buf = page_address(page);
> - } 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;
next prev parent reply other threads:[~2021-06-01 8:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 6:39 [PATCH net v2 0/2] virtio-net: fix for build_skb() 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 [this message]
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
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=3e0f4152-b41f-5cd4-ee38-95bae89ad1b2@redhat.com \
--to=jasowang@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.com \
--subject='Re: [PATCH net v2 2/2] virtio_net: get build_skb() buf by data ptr' \
/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).