* RE: [PATCH v7 bpf-next 6/6] xsk: build skb by page (aka generic zerocopy xmit) [not found] ` <20210217120003.7938-7-alobakin@pm.me> @ 2021-02-18 0:46 ` John Fastabend [not found] ` <1613615475.9629707-1-xuanzhuo@linux.alibaba.com> 0 siblings, 1 reply; 3+ messages in thread From: John Fastabend @ 2021-02-18 0:46 UTC (permalink / raw) To: Alexander Lobakin, Daniel Borkmann, Magnus Karlsson Cc: Song Liu, Michael S. Tsirkin, Alexander Lobakin, Alexei Starovoitov, virtualization, Xuan Zhuo, Eric Dumazet, John Fastabend, Andrii Nakryiko, Dust Li, Yonghong Song, Paolo Abeni, Jesper Dangaard Brouer, KP Singh, Jakub Kicinski, netdev, linux-kernel, David S. Miller, Björn Töpel, Jonathan Lemon, bpf, Martin KaFai Lau Alexander Lobakin wrote: > From: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > > This patch is used to construct skb based on page to save memory copy > overhead. > > This function is implemented based on IFF_TX_SKB_NO_LINEAR. Only the > network card priv_flags supports IFF_TX_SKB_NO_LINEAR will use page to > directly construct skb. If this feature is not supported, it is still > necessary to copy data to construct skb. > > ---------------- Performance Testing ------------ > > The test environment is Aliyun ECS server. > Test cmd: > ``` > xdpsock -i eth0 -t -S -s <msg size> > ``` > > Test result data: > > size 64 512 1024 1500 > copy 1916747 1775988 1600203 1440054 > page 1974058 1953655 1945463 1904478 > percent 3.0% 10.0% 21.58% 32.3% > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > Reviewed-by: Dust Li <dust.li@linux.alibaba.com> > [ alobakin: > - expand subject to make it clearer; > - improve skb->truesize calculation; > - reserve some headroom in skb for drivers; > - tailroom is not needed as skb is non-linear ] > Signed-off-by: Alexander Lobakin <alobakin@pm.me> > Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> > --- [...] > + buffer = xsk_buff_raw_get_data(pool, addr); > + offset = offset_in_page(buffer); > + addr = buffer - pool->addrs; > + > + for (copied = 0, i = 0; copied < len; i++) { > + page = pool->umem->pgs[addr >> PAGE_SHIFT]; Looks like we could walk off the end of pgs[] if len is larger than the number of pgs? Do we need to guard against a misconfigured socket causing a panic here? AFAIU len here is read from the user space descriptor so is under user control. Or maybe I missed a check somewhere. Thanks, John > + get_page(page); > + > + copy = min_t(u32, PAGE_SIZE - offset, len - copied); > + skb_fill_page_desc(skb, i, page, offset, copy); > + > + copied += copy; > + addr += copy; > + offset = 0; > + } > + > + skb->len += len; > + skb->data_len += len; > + skb->truesize += ts; > + > + refcount_add(ts, &xs->sk.sk_wmem_alloc); > + > + return skb; > +} > + _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <1613615475.9629707-1-xuanzhuo@linux.alibaba.com>]
* Re: RE: [PATCH v7 bpf-next 6/6] xsk: build skb by page (aka generic zerocopy xmit) [not found] ` <1613615475.9629707-1-xuanzhuo@linux.alibaba.com> @ 2021-02-18 5:51 ` John Fastabend 0 siblings, 0 replies; 3+ messages in thread From: John Fastabend @ 2021-02-18 5:51 UTC (permalink / raw) To: Xuan Zhuo, John Fastabend Cc: Song Liu, Michael S. Tsirkin, Alexander Lobakin, Alexei Starovoitov, virtualization, Eric Dumazet, John Fastabend, Andrii Nakryiko, Dust Li, Yonghong Song, Paolo Abeni, Jesper Dangaard Brouer, KP Singh, Jakub Kicinski, Magnus Karlsson, Daniel Borkmann, netdev, linux-kernel, David S. Miller, Björn Töpel, Jonathan Lemon, bpf, Martin KaFai Lau Xuan Zhuo wrote: > On Wed, 17 Feb 2021 16:46:04 -0800, John Fastabend <john.fastabend@gmail.com> wrote: > > Alexander Lobakin wrote: > > > From: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > > > > > > This patch is used to construct skb based on page to save memory copy > > > overhead. > > > > > > This function is implemented based on IFF_TX_SKB_NO_LINEAR. Only the > > > network card priv_flags supports IFF_TX_SKB_NO_LINEAR will use page to > > > directly construct skb. If this feature is not supported, it is still > > > necessary to copy data to construct skb. > > > > > > ---------------- Performance Testing ------------ > > > > > > The test environment is Aliyun ECS server. > > > Test cmd: > > > ``` > > > xdpsock -i eth0 -t -S -s <msg size> > > > ``` > > > > > > Test result data: > > > > > > size 64 512 1024 1500 > > > copy 1916747 1775988 1600203 1440054 > > > page 1974058 1953655 1945463 1904478 > > > percent 3.0% 10.0% 21.58% 32.3% > > > > > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > > > Reviewed-by: Dust Li <dust.li@linux.alibaba.com> > > > [ alobakin: > > > - expand subject to make it clearer; > > > - improve skb->truesize calculation; > > > - reserve some headroom in skb for drivers; > > > - tailroom is not needed as skb is non-linear ] > > > Signed-off-by: Alexander Lobakin <alobakin@pm.me> > > > Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> > > > --- > > > > [...] > > > > > + buffer = xsk_buff_raw_get_data(pool, addr); > > > + offset = offset_in_page(buffer); > > > + addr = buffer - pool->addrs; > > > + > > > + for (copied = 0, i = 0; copied < len; i++) { > > > + page = pool->umem->pgs[addr >> PAGE_SHIFT]; > > > > Looks like we could walk off the end of pgs[] if len is larger than > > the number of pgs? Do we need to guard against a misconfigured socket > > causing a panic here? AFAIU len here is read from the user space > > descriptor so is under user control. Or maybe I missed a check somewhere. > > > > Thanks, > > John > > > > Don't worry about this, the legality of desc has been checked. > > xskq_cons_peek_desc -> xskq_cons_read_desc -> > xskq_cons_is_valid_desc -> xp_validate_desc Ah OK I didn't dig past the cons_read_desc(). In that case LGTM. Acked-by: John Fastabend <john.fastabend@gmail.com> _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v7 bpf-next 0/6] xsk: build skb by page (aka generic zerocopy xmit) [not found] <20210217120003.7938-1-alobakin@pm.me> [not found] ` <20210217120003.7938-7-alobakin@pm.me> @ 2021-02-18 6:08 ` John Fastabend 1 sibling, 0 replies; 3+ messages in thread From: John Fastabend @ 2021-02-18 6:08 UTC (permalink / raw) To: Alexander Lobakin, Daniel Borkmann, Magnus Karlsson Cc: Song Liu, Michael S. Tsirkin, Alexander Lobakin, Alexei Starovoitov, virtualization, Xuan Zhuo, Eric Dumazet, John Fastabend, Andrii Nakryiko, Dust Li, Yonghong Song, Paolo Abeni, Jesper Dangaard Brouer, KP Singh, Jakub Kicinski, netdev, linux-kernel, David S. Miller, Björn Töpel, Jonathan Lemon, bpf, Martin KaFai Lau Alexander Lobakin wrote: > This series introduces XSK generic zerocopy xmit by adding XSK umem > pages as skb frags instead of copying data to linear space. > The only requirement for this for drivers is to be able to xmit skbs > with skb_headlen(skb) == 0, i.e. all data including hard headers > starts from frag 0. > To indicate whether a particular driver supports this, a new netdev > priv flag, IFF_TX_SKB_NO_LINEAR, is added (and declared in virtio_net > as it's already capable of doing it). So consider implementing this > in your drivers to greatly speed-up generic XSK xmit. [...] > ---------------- Performance Testing ------------ > > The test environment is Aliyun ECS server. > Test cmd: > ``` > xdpsock -i eth0 -t -S -s <msg size> > ``` > > Test result data: > > size 64 512 1024 1500 > copy 1916747 1775988 1600203 1440054 > page 1974058 1953655 1945463 1904478 > percent 3.0% 10.0% 21.58% 32.3% > For the series, but might be good to get Dave or Jakub to check 2/6 to be sure they agree. Acked-by: John Fastabend <john.fastabend@gmail.com> _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-18 6:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210217120003.7938-1-alobakin@pm.me>
[not found] ` <20210217120003.7938-7-alobakin@pm.me>
2021-02-18 0:46 ` [PATCH v7 bpf-next 6/6] xsk: build skb by page (aka generic zerocopy xmit) John Fastabend
[not found] ` <1613615475.9629707-1-xuanzhuo@linux.alibaba.com>
2021-02-18 5:51 ` John Fastabend
2021-02-18 6:08 ` [PATCH v7 bpf-next 0/6] " John Fastabend
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).