Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
Hi Mina, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Mina-Almasry/vsock-virtio-use-skb_frag_-helpers/20231222-164637 base: net-next/main patch link: https://lore.kernel.org/r/20231220214505.2303297-4-almasrymina%40google.com patch subject: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t :: branch date: 15 hours ago :: commit date: 15 hours ago config: x86_64-randconfig-121-20231223 (https://download.01.org/0day-ci/archive/20231223/202312230726.4xapn84e-...@intel.com/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231223/202312230726.4xapn84e-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/r/202312230726.4xapn84e-...@intel.com/ sparse warnings: (new ones prefixed by >>) net/core/netevent.c: note: in included file (through include/linux/skbuff.h, include/net/net_namespace.h, include/linux/netdevice.h, ...): >> include/net/netmem.h:28:54: sparse: sparse: invalid modifier include/net/netmem.h:36:26: sparse: sparse: invalid modifier include/net/netmem.h:38:27: sparse: sparse: invalid modifier net/core/netevent.c: note: in included file (through include/net/net_namespace.h, include/linux/netdevice.h, include/linux/rtnetlink.h): >> include/linux/skbuff.h:364:20: sparse: sparse: invalid modifier include/linux/skbuff.h:2440:57: sparse: sparse: invalid modifier include/linux/skbuff.h:2456:67: sparse: sparse: invalid modifier include/linux/skbuff.h:2498:54: sparse: sparse: invalid modifier include/linux/skbuff.h:2521:52: sparse: sparse: invalid modifier include/linux/skbuff.h:2571:68: sparse: sparse: invalid modifier -- net/core/request_sock.c: note: in included file (through include/linux/skbuff.h, include/linux/tcp.h): >> include/net/netmem.h:28:54: sparse: sparse: invalid modifier include/net/netmem.h:36:26: sparse: sparse: invalid modifier include/net/netmem.h:38:27: sparse: sparse: invalid modifier net/core/request_sock.c: note: in included file (through include/linux/tcp.h): >> include/linux/skbuff.h:364:20: sparse: sparse: invalid modifier include/linux/skbuff.h:2440:57: sparse: sparse: invalid modifier include/linux/skbuff.h:2456:67: sparse: sparse: invalid modifier include/linux/skbuff.h:2498:54: sparse: sparse: invalid modifier include/linux/skbuff.h:2521:52: sparse: sparse: invalid modifier include/linux/skbuff.h:2571:68: sparse: sparse: invalid modifier -- net/core/utils.c: note: in included file (through include/linux/skbuff.h, include/net/net_namespace.h, include/linux/inet.h): >> include/net/netmem.h:28:54: sparse: sparse: invalid modifier include/net/netmem.h:36:26: sparse: sparse: invalid modifier include/net/netmem.h:38:27: sparse: sparse: invalid modifier net/core/utils.c: note: in included file (through include/net/net_namespace.h, include/linux/inet.h): >> include/linux/skbuff.h:364:20: sparse: sparse: invalid modifier include/linux/skbuff.h:2440:57: sparse: sparse: invalid modifier include/linux/skbuff.h:2456:67: sparse: sparse: invalid modifier include/linux/skbuff.h:2498:54: sparse: sparse: invalid modifier include/linux/skbuff.h:2521:52: sparse: sparse: invalid modifier include/linux/skbuff.h:2571:68: sparse: sparse: invalid modifier -- net/core/secure_seq.c: note: in included file (through include/linux/skbuff.h, include/linux/tcp.h, include/net/tcp.h): >> include/net/netmem.h:28:54: sparse: sparse: invalid modifier include/net/netmem.h:36:26: sparse: sparse: invalid modifier include/net/netmem.h:38:27: sparse: sparse: invalid modifier net/core/secure_seq.c: note: in included file (through include/linux/tcp.h, include/net/tcp.h): >> include/linux/skbuff.h:364:20: sparse: sparse: invalid modifier include/linux/skbuff.h:2440:57: sparse: sparse: invalid modifier include/linux/skbuff.h:2456:67: sparse: sparse: invalid modifier include/linux/skbuff.h:2498:54: sparse: sparse: invalid modifier include/linux/skbuff.h:2521:52: sparse: sparse: invalid modifier include/linux/skbuff.h:2571:68: sparse: sparse: invalid modifier -- net/core/net_namespace.c: note: in included file (through include/linux/skbuff.h, include/net/net_namespace.h, include/linux/netdevice.h, ...): >> include/net/netmem.h:28:54: sparse: sparse: invalid modifier include/net/netmem.h:36:26: sparse: sparse: invalid modifier include/net/netmem.h:38:27: sparse: sparse: invalid modifier net/core/net_namespace.c: note: in included file (through include/net/net_namespace.h, include/linux/netdevice.h, include/linux/rtnetlink.h): >> include/linux/skbuff.h:364:20: sparse: sparse: invalid modifier
Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
Hi Mina, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Mina-Almasry/vsock-virtio-use-skb_frag_-helpers/20231222-164637 base: net-next/main patch link: https://lore.kernel.org/r/20231220214505.2303297-4-almasrymina%40google.com patch subject: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t config: i386-randconfig-141-20231222 (https://download.01.org/0day-ci/archive/20231223/202312230739.g0tfssdt-...@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231223/202312230739.g0tfssdt-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312230739.g0tfssdt-...@intel.com/ All errors (new ones prefixed by >>): net/kcm/kcmsock.c: In function 'kcm_write_msgs': >> net/kcm/kcmsock.c:637:59: error: 'skb_frag_t' {aka 'struct skb_frag'} has no >> member named 'bv_len' 637 | msize += skb_shinfo(skb)->frags[i].bv_len; | ^ vim +637 net/kcm/kcmsock.c cd6e111bf5be5c Tom Herbert 2016-03-07 578 ab7ac4eb9832e3 Tom Herbert 2016-03-07 579 /* Write any messages ready on the kcm socket. Called with kcm sock lock ab7ac4eb9832e3 Tom Herbert 2016-03-07 580 * held. Return bytes actually sent or error. ab7ac4eb9832e3 Tom Herbert 2016-03-07 581 */ ab7ac4eb9832e3 Tom Herbert 2016-03-07 582 static int kcm_write_msgs(struct kcm_sock *kcm) ab7ac4eb9832e3 Tom Herbert 2016-03-07 583 { c31a25e1db486f David Howells 2023-06-09 584unsigned int total_sent = 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 585struct sock *sk = >sk; ab7ac4eb9832e3 Tom Herbert 2016-03-07 586struct kcm_psock *psock; c31a25e1db486f David Howells 2023-06-09 587struct sk_buff *head; ab7ac4eb9832e3 Tom Herbert 2016-03-07 588int ret = 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 589 ab7ac4eb9832e3 Tom Herbert 2016-03-07 590kcm->tx_wait_more = false; ab7ac4eb9832e3 Tom Herbert 2016-03-07 591psock = kcm->tx_psock; ab7ac4eb9832e3 Tom Herbert 2016-03-07 592if (unlikely(psock && psock->tx_stopped)) { ab7ac4eb9832e3 Tom Herbert 2016-03-07 593/* A reserved psock was aborted asynchronously. Unreserve ab7ac4eb9832e3 Tom Herbert 2016-03-07 594 * it and we'll retry the message. ab7ac4eb9832e3 Tom Herbert 2016-03-07 595 */ ab7ac4eb9832e3 Tom Herbert 2016-03-07 596 unreserve_psock(kcm); cd6e111bf5be5c Tom Herbert 2016-03-07 597 kcm_report_tx_retry(kcm); ab7ac4eb9832e3 Tom Herbert 2016-03-07 598if (skb_queue_empty(>sk_write_queue)) ab7ac4eb9832e3 Tom Herbert 2016-03-07 599return 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 600 c31a25e1db486f David Howells 2023-06-09 601 kcm_tx_msg(skb_peek(>sk_write_queue))->started_tx = false; ab7ac4eb9832e3 Tom Herbert 2016-03-07 602} ab7ac4eb9832e3 Tom Herbert 2016-03-07 603 c31a25e1db486f David Howells 2023-06-09 604 retry: c31a25e1db486f David Howells 2023-06-09 605while ((head = skb_peek(>sk_write_queue))) { c31a25e1db486f David Howells 2023-06-09 606struct msghdr msg = { c31a25e1db486f David Howells 2023-06-09 607 .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, c31a25e1db486f David Howells 2023-06-09 608}; c31a25e1db486f David Howells 2023-06-09 609struct kcm_tx_msg *txm = kcm_tx_msg(head); c31a25e1db486f David Howells 2023-06-09 610struct sk_buff *skb; c31a25e1db486f David Howells 2023-06-09 611unsigned int msize; c31a25e1db486f David Howells 2023-06-09 612int i; ab7ac4eb9832e3 Tom Herbert 2016-03-07 613 c31a25e1db486f David Howells 2023-06-09 614if (!txm->started_tx) { c31a25e1db486f David Howells 2023-06-09 615psock = reserve_psock(kcm); c31a25e1db486f David Howells 2023-06-09 616if (!psock) c31a25e1db486f David Howells 2023-06-09 617 goto out; c31a25e1db486f David Howells 2023-06-09 618skb = head; c31a25e1db486f David Howells 2023-06-09 619 txm->frag_offset = 0; c31a25e1db486f David Howells 2023-06-09 620 txm->sent = 0; c31a25e1db486f David Howells 2023-06-09 621
Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
Hi Mina, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Mina-Almasry/vsock-virtio-use-skb_frag_-helpers/20231222-164637 base: net-next/main patch link: https://lore.kernel.org/r/20231220214505.2303297-4-almasrymina%40google.com patch subject: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20231223/202312230340.icf8soop-...@intel.com/config) compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project d3ef86708241a3bee902615c190dead1638c4e09) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231223/202312230340.icf8soop-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312230340.icf8soop-...@intel.com/ All errors (new ones prefixed by >>): >> net/kcm/kcmsock.c:637:39: error: no member named 'bv_len' in 'struct >> skb_frag' 637 | msize += skb_shinfo(skb)->frags[i].bv_len; | ~ ^ 1 error generated. vim +637 net/kcm/kcmsock.c cd6e111bf5be5c Tom Herbert 2016-03-07 578 ab7ac4eb9832e3 Tom Herbert 2016-03-07 579 /* Write any messages ready on the kcm socket. Called with kcm sock lock ab7ac4eb9832e3 Tom Herbert 2016-03-07 580 * held. Return bytes actually sent or error. ab7ac4eb9832e3 Tom Herbert 2016-03-07 581 */ ab7ac4eb9832e3 Tom Herbert 2016-03-07 582 static int kcm_write_msgs(struct kcm_sock *kcm) ab7ac4eb9832e3 Tom Herbert 2016-03-07 583 { c31a25e1db486f David Howells 2023-06-09 584unsigned int total_sent = 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 585struct sock *sk = >sk; ab7ac4eb9832e3 Tom Herbert 2016-03-07 586struct kcm_psock *psock; c31a25e1db486f David Howells 2023-06-09 587struct sk_buff *head; ab7ac4eb9832e3 Tom Herbert 2016-03-07 588int ret = 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 589 ab7ac4eb9832e3 Tom Herbert 2016-03-07 590kcm->tx_wait_more = false; ab7ac4eb9832e3 Tom Herbert 2016-03-07 591psock = kcm->tx_psock; ab7ac4eb9832e3 Tom Herbert 2016-03-07 592if (unlikely(psock && psock->tx_stopped)) { ab7ac4eb9832e3 Tom Herbert 2016-03-07 593/* A reserved psock was aborted asynchronously. Unreserve ab7ac4eb9832e3 Tom Herbert 2016-03-07 594 * it and we'll retry the message. ab7ac4eb9832e3 Tom Herbert 2016-03-07 595 */ ab7ac4eb9832e3 Tom Herbert 2016-03-07 596 unreserve_psock(kcm); cd6e111bf5be5c Tom Herbert 2016-03-07 597 kcm_report_tx_retry(kcm); ab7ac4eb9832e3 Tom Herbert 2016-03-07 598if (skb_queue_empty(>sk_write_queue)) ab7ac4eb9832e3 Tom Herbert 2016-03-07 599return 0; ab7ac4eb9832e3 Tom Herbert 2016-03-07 600 c31a25e1db486f David Howells 2023-06-09 601 kcm_tx_msg(skb_peek(>sk_write_queue))->started_tx = false; ab7ac4eb9832e3 Tom Herbert 2016-03-07 602} ab7ac4eb9832e3 Tom Herbert 2016-03-07 603 c31a25e1db486f David Howells 2023-06-09 604 retry: c31a25e1db486f David Howells 2023-06-09 605while ((head = skb_peek(>sk_write_queue))) { c31a25e1db486f David Howells 2023-06-09 606struct msghdr msg = { c31a25e1db486f David Howells 2023-06-09 607 .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, c31a25e1db486f David Howells 2023-06-09 608}; c31a25e1db486f David Howells 2023-06-09 609struct kcm_tx_msg *txm = kcm_tx_msg(head); c31a25e1db486f David Howells 2023-06-09 610struct sk_buff *skb; c31a25e1db486f David Howells 2023-06-09 611unsigned int msize; c31a25e1db486f David Howells 2023-06-09 612int i; ab7ac4eb9832e3 Tom Herbert 2016-03-07 613 c31a25e1db486f David Howells 2023-06-09 614if (!txm->started_tx) { c31a25e1db486f David Howells 2023-06-09 615psock = reserve_psock(kcm); c31a25e1db486f David Howells 2023-06-09 616if (!psock) c31a25e1db486f David Howells 2023-06-09 617 goto out; c31a25e1db486f David Howells 2023-06-09 618skb = head; c31a25e1db486f David Howells 2023-06-09 619 txm->frag_offset = 0; c31a25e1db486f David Howells 2023-06-09 620 txm->sent = 0; c31a25e1db486f David Howells
Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
On Wed, Dec 20, 2023 at 01:45:02PM -0800, Mina Almasry wrote: > diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c > index 65d1f6755f98..3180a54b2c68 100644 > --- a/net/kcm/kcmsock.c > +++ b/net/kcm/kcmsock.c > @@ -636,9 +636,15 @@ static int kcm_write_msgs(struct kcm_sock *kcm) > for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) > msize += skb_shinfo(skb)->frags[i].bv_len; Don't you need the above to cast to bio_vec to get bv_len? skb_frag_t does not have bv_len anymore. > > + /* The cast to struct bio_vec* here assumes the frags are > + * struct page based. WARN if there is no page in this skb. > + */ > + DEBUG_NET_WARN_ON_ONCE( > + !skb_frag_page(_shinfo(skb)->frags[0])); > + > iov_iter_bvec(_iter, ITER_SOURCE, > - skb_shinfo(skb)->frags, skb_shinfo(skb)->nr_frags, > - msize); > + (const struct bio_vec *)skb_shinfo(skb)->frags, > + skb_shinfo(skb)->nr_frags, msize); > iov_iter_advance(_iter, txm->frag_offset); > > do { > -- > 2.43.0.472.g3155946c3a-goog >
Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
Mina Almasry wrote: > Use netmem_ref instead of page in skb_frag_t. Currently netmem_ref > is always a struct page underneath, but the abstraction allows efforts > to add support for skb frags not backed by pages. > > There is unfortunately 1 instance where the skb_frag_t is assumed to be > a bio_vec in kcm. For this case, add a debug assert that the skb frag is > indeed backed by a page, and do a cast. > > Add skb[_frag]_fill_netmem_*() and skb_add_rx_frag_netmem() helpers so > that the API can be used to create netmem skbs. > > Signed-off-by: Mina Almasry > > --- > > v3; > - Renamed the fields in skb_frag_t. > > v2: > - Add skb frag filling helpers. > > --- > include/linux/skbuff.h | 92 +- > net/core/skbuff.c | 22 +++--- > net/kcm/kcmsock.c | 10 - > 3 files changed, 89 insertions(+), 35 deletions(-) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index 7ce38874dbd1..729c95e97be1 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -37,6 +37,7 @@ > #endif > #include > #include > +#include > > /** > * DOC: skb checksums > @@ -359,7 +360,11 @@ extern int sysctl_max_skb_frags; > */ > #define GSO_BY_FRAGS 0x > > -typedef struct bio_vec skb_frag_t; > +typedef struct skb_frag { > + netmem_ref netmem; > + unsigned int len; > + unsigned int offset; > +} skb_frag_t; > > /** > * skb_frag_size() - Returns the size of a skb fragment > @@ -367,7 +372,7 @@ typedef struct bio_vec skb_frag_t; > */ > static inline unsigned int skb_frag_size(const skb_frag_t *frag) > { > - return frag->bv_len; > + return frag->len; > } > > /** > @@ -377,7 +382,7 @@ static inline unsigned int skb_frag_size(const skb_frag_t > *frag) > */ > static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size) > { > - frag->bv_len = size; > + frag->len = size; > } > > /** > @@ -387,7 +392,7 @@ static inline void skb_frag_size_set(skb_frag_t *frag, > unsigned int size) > */ > static inline void skb_frag_size_add(skb_frag_t *frag, int delta) > { > - frag->bv_len += delta; > + frag->len += delta; > } > > /** > @@ -397,7 +402,7 @@ static inline void skb_frag_size_add(skb_frag_t *frag, > int delta) > */ > static inline void skb_frag_size_sub(skb_frag_t *frag, int delta) > { > - frag->bv_len -= delta; > + frag->len -= delta; > } > > /** > @@ -417,7 +422,7 @@ static inline bool skb_frag_must_loop(struct page *p) > * skb_frag_foreach_page - loop over pages in a fragment > * > * @f: skb frag to operate on > - * @f_off: offset from start of f->bv_page > + * @f_off: offset from start of f->netmem > * @f_len: length from f_off to loop over > * @p: (temp var) current page > * @p_off: (temp var) offset from start of current page, > @@ -2431,22 +2436,37 @@ static inline unsigned int skb_pagelen(const struct > sk_buff *skb) > return skb_headlen(skb) + __skb_pagelen(skb); > } > > +static inline void skb_frag_fill_netmem_desc(skb_frag_t *frag, > + netmem_ref netmem, int off, > + int size) > +{ > + frag->netmem = netmem; > + frag->offset = off; > + skb_frag_size_set(frag, size); > +} > + > static inline void skb_frag_fill_page_desc(skb_frag_t *frag, > struct page *page, > int off, int size) > { > - frag->bv_page = page; > - frag->bv_offset = off; > - skb_frag_size_set(frag, size); > + skb_frag_fill_netmem_desc(frag, page_to_netmem(page), off, size); > +} > + > +static inline void __skb_fill_netmem_desc_noacc(struct skb_shared_info > *shinfo, > + int i, netmem_ref netmem, > + int off, int size) > +{ > + skb_frag_t *frag = >frags[i]; > + > + skb_frag_fill_netmem_desc(frag, netmem, off, size); > } > > static inline void __skb_fill_page_desc_noacc(struct skb_shared_info *shinfo, > int i, struct page *page, > int off, int size) > { > - skb_frag_t *frag = >frags[i]; > - > - skb_frag_fill_page_desc(frag, page, off, size); > + __skb_fill_netmem_desc_noacc(shinfo, i, page_to_netmem(page), off, > + size); > } > > /** > @@ -2462,10 +2482,10 @@ static inline void skb_len_add(struct sk_buff *skb, > int delta) > } > > /** > - * __skb_fill_page_desc - initialise a paged fragment in an skb > + * __skb_fill_netmem_desc - initialise a fragment in an skb > * @skb: buffer containing fragment to be initialised > - * @i: paged fragment index to initialise > - * @page: the page to use for this fragment > + * @i: fragment index to initialise > + *
Re: [PATCH net-next v3 3/3] net: add netmem_ref to skb_frag_t
On Wed, Dec 20, 2023 at 01:45:02PM -0800, Mina Almasry wrote: > Use netmem_ref instead of page in skb_frag_t. Currently netmem_ref > is always a struct page underneath, but the abstraction allows efforts > to add support for skb frags not backed by pages. > > There is unfortunately 1 instance where the skb_frag_t is assumed to be > a bio_vec in kcm. For this case, add a debug assert that the skb frag is > indeed backed by a page, and do a cast. > > Add skb[_frag]_fill_netmem_*() and skb_add_rx_frag_netmem() helpers so > that the API can be used to create netmem skbs. > > Signed-off-by: Mina Almasry ... > diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c > index 65d1f6755f98..3180a54b2c68 100644 > --- a/net/kcm/kcmsock.c > +++ b/net/kcm/kcmsock.c > @@ -636,9 +636,15 @@ static int kcm_write_msgs(struct kcm_sock *kcm) > for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) > msize += skb_shinfo(skb)->frags[i].bv_len; > > + /* The cast to struct bio_vec* here assumes the frags are > + * struct page based. WARN if there is no page in this skb. > + */ > + DEBUG_NET_WARN_ON_ONCE( > + !skb_frag_page(_shinfo(skb)->frags[0])); > + > iov_iter_bvec(_iter, ITER_SOURCE, > - skb_shinfo(skb)->frags, skb_shinfo(skb)->nr_frags, > - msize); > + (const struct bio_vec *)skb_shinfo(skb)->frags, > + skb_shinfo(skb)->nr_frags, msize); > iov_iter_advance(_iter, txm->frag_offset); > > do { Hi Mina, something isn't quite right here. ...//kcmsock.c:637:39: error: no member named 'bv_len' in 'struct skb_frag' 637 | msize += skb_shinfo(skb)->frags[i].bv_len; | ~ ^ -- pw-bot: changes-requested