From: Nikolay Aleksandrov <razor@blackwall.org> To: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Cc: kuba@kernel.org, davem@davemloft.net, stable@vger.kernel.org, Jason Wang <jasowang@redhat.com>, Daniel Borkmann <daniel@iogearbox.net>, "Michael S. Tsirkin" <mst@redhat.com>, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: Re: [PATCH net] virtio_net: fix wrong buf address calculation when using xdp Date: Sat, 23 Apr 2022 18:55:51 +0300 [thread overview] Message-ID: <9e7db66d-8925-be38-c740-b7e3d21c2060@blackwall.org> (raw) In-Reply-To: <1650726113.2334588-1-xuanzhuo@linux.alibaba.com> On 23/04/2022 18:01, Xuan Zhuo wrote: > On Sat, 23 Apr 2022 17:58:05 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: >> On 23/04/2022 17:36, Xuan Zhuo wrote: >>> On Sat, 23 Apr 2022 17:30:11 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: >>>> On 23/04/2022 17:16, Nikolay Aleksandrov wrote: >>>>> On 23/04/2022 16:31, Xuan Zhuo wrote: >>>>>> On Sat, 23 Apr 2022 14:26:12 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: [snip] metasize, >>>>>> - VIRTIO_XDP_HEADROOM); >>>>>> + VIRTIO_XDP_HEADROOM - metazie); >>>>>> return head_skb; >>>>>> } >>>>>> break; >>>>> >>>>> That patch doesn't fix it, as I said with xdp you can move both data and data_meta. >>>>> So just doing that would take care of the meta, but won't take care of moving data. >>>>> >>>> >>>> Also it doesn't take care of the case where page_to_skb() is called with the original page >>>> i.e. when we already have headroom, so we hit the next/standard page_to_skb() call (xdp_page == page). >>> >>> Yes, you are right. >>> >>>> >>>> The above change guarantees that buf and p will be in the same page >>> >>> >>> How can this be guaranteed? >>> >>> 1. For example, we applied for a 32k buffer first, and took away 1500 + hdr_len >>> from the allocation. >>> 2. set xdp >>> 3. alloc for new buffer >>> >> >> p = page_address(page) + offset; >> buf = p & PAGE_MASK; // whatever page p lands in is where buf is set >> >> => p and buf are always in the same page, no? > > I don't think it is, it's entirely possible to split on two pages. > Ahhh, I completely misinterpreted page_address(). You're right.
WARNING: multiple messages have this Message-ID (diff)
From: Nikolay Aleksandrov <razor@blackwall.org> To: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Cc: Daniel Borkmann <daniel@iogearbox.net>, "Michael S. Tsirkin" <mst@redhat.com>, netdev@vger.kernel.org, stable@vger.kernel.org, virtualization@lists.linux-foundation.org, kuba@kernel.org, davem@davemloft.net Subject: Re: [PATCH net] virtio_net: fix wrong buf address calculation when using xdp Date: Sat, 23 Apr 2022 18:55:51 +0300 [thread overview] Message-ID: <9e7db66d-8925-be38-c740-b7e3d21c2060@blackwall.org> (raw) In-Reply-To: <1650726113.2334588-1-xuanzhuo@linux.alibaba.com> On 23/04/2022 18:01, Xuan Zhuo wrote: > On Sat, 23 Apr 2022 17:58:05 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: >> On 23/04/2022 17:36, Xuan Zhuo wrote: >>> On Sat, 23 Apr 2022 17:30:11 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: >>>> On 23/04/2022 17:16, Nikolay Aleksandrov wrote: >>>>> On 23/04/2022 16:31, Xuan Zhuo wrote: >>>>>> On Sat, 23 Apr 2022 14:26:12 +0300, Nikolay Aleksandrov <razor@blackwall.org> wrote: [snip] metasize, >>>>>> - VIRTIO_XDP_HEADROOM); >>>>>> + VIRTIO_XDP_HEADROOM - metazie); >>>>>> return head_skb; >>>>>> } >>>>>> break; >>>>> >>>>> That patch doesn't fix it, as I said with xdp you can move both data and data_meta. >>>>> So just doing that would take care of the meta, but won't take care of moving data. >>>>> >>>> >>>> Also it doesn't take care of the case where page_to_skb() is called with the original page >>>> i.e. when we already have headroom, so we hit the next/standard page_to_skb() call (xdp_page == page). >>> >>> Yes, you are right. >>> >>>> >>>> The above change guarantees that buf and p will be in the same page >>> >>> >>> How can this be guaranteed? >>> >>> 1. For example, we applied for a 32k buffer first, and took away 1500 + hdr_len >>> from the allocation. >>> 2. set xdp >>> 3. alloc for new buffer >>> >> >> p = page_address(page) + offset; >> buf = p & PAGE_MASK; // whatever page p lands in is where buf is set >> >> => p and buf are always in the same page, no? > > I don't think it is, it's entirely possible to split on two pages. > Ahhh, I completely misinterpreted page_address(). You're right. _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2022-04-23 15:55 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-23 11:26 [PATCH net] virtio_net: fix wrong buf address calculation when using xdp Nikolay Aleksandrov 2022-04-23 11:26 ` Nikolay Aleksandrov 2022-04-23 13:31 ` Xuan Zhuo 2022-04-23 13:31 ` Xuan Zhuo 2022-04-23 14:16 ` Nikolay Aleksandrov 2022-04-23 14:16 ` Nikolay Aleksandrov 2022-04-23 14:20 ` Xuan Zhuo 2022-04-23 14:20 ` Xuan Zhuo 2022-04-23 14:30 ` Nikolay Aleksandrov 2022-04-23 14:30 ` Nikolay Aleksandrov 2022-04-23 14:36 ` Xuan Zhuo 2022-04-23 14:36 ` Xuan Zhuo 2022-04-23 14:58 ` Nikolay Aleksandrov 2022-04-23 14:58 ` Nikolay Aleksandrov 2022-04-23 15:01 ` Xuan Zhuo 2022-04-23 15:01 ` Xuan Zhuo 2022-04-23 15:23 ` Nikolay Aleksandrov 2022-04-23 15:23 ` Nikolay Aleksandrov 2022-04-23 15:35 ` Nikolay Aleksandrov 2022-04-23 15:35 ` Nikolay Aleksandrov 2022-04-24 10:21 ` [PATCH net v2] " Nikolay Aleksandrov 2022-04-24 10:21 ` Nikolay Aleksandrov 2022-04-24 10:42 ` Xuan Zhuo 2022-04-24 10:42 ` Xuan Zhuo 2022-04-24 10:56 ` Nikolay Aleksandrov 2022-04-24 10:56 ` Nikolay Aleksandrov 2022-04-24 11:18 ` Xuan Zhuo 2022-04-24 11:18 ` Xuan Zhuo 2022-04-24 14:53 ` Nikolay Aleksandrov 2022-04-24 14:53 ` Nikolay Aleksandrov 2022-04-23 15:55 ` Nikolay Aleksandrov [this message] 2022-04-23 15:55 ` [PATCH net] " Nikolay Aleksandrov 2022-04-23 14:46 ` Nikolay Aleksandrov 2022-04-23 14:46 ` Nikolay Aleksandrov 2022-04-23 15:10 ` Nikolay Aleksandrov 2022-04-23 15:10 ` Nikolay Aleksandrov
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=9e7db66d-8925-be38-c740-b7e3d21c2060@blackwall.org \ --to=razor@blackwall.org \ --cc=daniel@iogearbox.net \ --cc=davem@davemloft.net \ --cc=jasowang@redhat.com \ --cc=kuba@kernel.org \ --cc=mst@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=stable@vger.kernel.org \ --cc=virtualization@lists.linux-foundation.org \ --cc=xuanzhuo@linux.alibaba.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.