Subject: Re: [PATCH net-next 2/3] net: use skb_for_each_frag() helper where possible

From: kernel test robot <[email-masked]>
Date: Sat, 10 Apr 2021 08:27:15 +0800

Hi Matteo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Matteo-Croce/introduce-skb_for_each_frag/20210410-020828
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4438669eb703d1a7416c2b19a8a15b0400b36738
config: um-allmodconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/9a46b324d3f1ca289db31c0011a6bbfd5ae06918
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Matteo-Croce/introduce-skb_for_each_frag/20210410-020828
        git checkout 9a46b324d3f1ca289db31c0011a6bbfd5ae06918
        # save the attached .config to linux build tree
        make W=1 ARCH=um 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

   cc1: warning: arch/um/include/uapi: No such file or directory [-Wmissing-include-dirs]
   arch/um/drivers/vector_kern.c: In function 'get_bpf_flash':
   arch/um/drivers/vector_kern.c:145:18: warning: ordered comparison of pointer with integer zero [-Wextra]
     145 |    return (allow > 0);
         |                  ^
   arch/um/drivers/vector_kern.c: In function 'prep_skb':
>> arch/um/drivers/vector_kern.c:627:11: warning: variable 'nr_frags' set but not used [-Wunused-but-set-variable]
     627 |  int err, nr_frags, frag;
         |           ^~~~~~~~
   arch/um/drivers/vector_kern.c: In function 'vector_parse':
   arch/um/drivers/vector_kern.c:719:9: warning: variable 'len' set but not used [-Wunused-but-set-variable]
     719 |  int n, len, err;
         |         ^~~

vim +/nr_frags +627 arch/um/drivers/vector_kern.c

49da7e64f33e80 Anton Ivanov 2017-11-20  609  
49da7e64f33e80 Anton Ivanov 2017-11-20  610  /*
49da7e64f33e80 Anton Ivanov 2017-11-20  611   * We do not use the RX queue as a proper wraparound queue for now
49da7e64f33e80 Anton Ivanov 2017-11-20  612   * This is not necessary because the consumption via netif_rx()
49da7e64f33e80 Anton Ivanov 2017-11-20  613   * happens in-line. While we can try using the return code of
49da7e64f33e80 Anton Ivanov 2017-11-20  614   * netif_rx() for flow control there are no drivers doing this today.
49da7e64f33e80 Anton Ivanov 2017-11-20  615   * For this RX specific use we ignore the tail/head locks and
49da7e64f33e80 Anton Ivanov 2017-11-20  616   * just read into a prepared queue filled with skbuffs.
49da7e64f33e80 Anton Ivanov 2017-11-20  617   */
49da7e64f33e80 Anton Ivanov 2017-11-20  618  
49da7e64f33e80 Anton Ivanov 2017-11-20  619  static struct sk_buff *prep_skb(
49da7e64f33e80 Anton Ivanov 2017-11-20  620  	struct vector_private *vp,
49da7e64f33e80 Anton Ivanov 2017-11-20  621  	struct user_msghdr *msg)
49da7e64f33e80 Anton Ivanov 2017-11-20  622  {
49da7e64f33e80 Anton Ivanov 2017-11-20  623  	int linear = vp->max_packet + vp->headroom + SAFETY_MARGIN;
49da7e64f33e80 Anton Ivanov 2017-11-20  624  	struct sk_buff *result;
49da7e64f33e80 Anton Ivanov 2017-11-20  625  	int iov_index = 0, len;
49da7e64f33e80 Anton Ivanov 2017-11-20  626  	struct iovec *iov = msg->msg_iov;
49da7e64f33e80 Anton Ivanov 2017-11-20 @627  	int err, nr_frags, frag;
49da7e64f33e80 Anton Ivanov 2017-11-20  628  	skb_frag_t *skb_frag;
49da7e64f33e80 Anton Ivanov 2017-11-20  629  
49da7e64f33e80 Anton Ivanov 2017-11-20  630  	if (vp->req_size <= linear)
49da7e64f33e80 Anton Ivanov 2017-11-20  631  		len = linear;
49da7e64f33e80 Anton Ivanov 2017-11-20  632  	else
49da7e64f33e80 Anton Ivanov 2017-11-20  633  		len = vp->req_size;
49da7e64f33e80 Anton Ivanov 2017-11-20  634  	result = alloc_skb_with_frags(
49da7e64f33e80 Anton Ivanov 2017-11-20  635  		linear,
49da7e64f33e80 Anton Ivanov 2017-11-20  636  		len - vp->max_packet,
49da7e64f33e80 Anton Ivanov 2017-11-20  637  		3,
49da7e64f33e80 Anton Ivanov 2017-11-20  638  		&err,
49da7e64f33e80 Anton Ivanov 2017-11-20  639  		GFP_ATOMIC
49da7e64f33e80 Anton Ivanov 2017-11-20  640  	);
49da7e64f33e80 Anton Ivanov 2017-11-20  641  	if (vp->header_size > 0)
49da7e64f33e80 Anton Ivanov 2017-11-20  642  		iov_index++;
49da7e64f33e80 Anton Ivanov 2017-11-20  643  	if (result == NULL) {
49da7e64f33e80 Anton Ivanov 2017-11-20  644  		iov[iov_index].iov_base = NULL;
49da7e64f33e80 Anton Ivanov 2017-11-20  645  		iov[iov_index].iov_len = 0;
49da7e64f33e80 Anton Ivanov 2017-11-20  646  		goto done;
49da7e64f33e80 Anton Ivanov 2017-11-20  647  	}
49da7e64f33e80 Anton Ivanov 2017-11-20  648  	skb_reserve(result, vp->headroom);
49da7e64f33e80 Anton Ivanov 2017-11-20  649  	result->dev = vp->dev;
49da7e64f33e80 Anton Ivanov 2017-11-20  650  	skb_put(result, vp->max_packet);
49da7e64f33e80 Anton Ivanov 2017-11-20  651  	result->data_len = len - vp->max_packet;
49da7e64f33e80 Anton Ivanov 2017-11-20  652  	result->len += len - vp->max_packet;
49da7e64f33e80 Anton Ivanov 2017-11-20  653  	skb_reset_mac_header(result);
49da7e64f33e80 Anton Ivanov 2017-11-20  654  	result->ip_summed = CHECKSUM_NONE;
49da7e64f33e80 Anton Ivanov 2017-11-20  655  	iov[iov_index].iov_base = result->data;
49da7e64f33e80 Anton Ivanov 2017-11-20  656  	iov[iov_index].iov_len = vp->max_packet;
49da7e64f33e80 Anton Ivanov 2017-11-20  657  	iov_index++;
49da7e64f33e80 Anton Ivanov 2017-11-20  658  
49da7e64f33e80 Anton Ivanov 2017-11-20  659  	nr_frags = skb_shinfo(result)->nr_frags;
9a46b324d3f1ca Matteo Croce 2021-04-09  660  	skb_for_each_frag(result, frag) {
49da7e64f33e80 Anton Ivanov 2017-11-20  661  		skb_frag = &skb_shinfo(result)->frags[frag];
49da7e64f33e80 Anton Ivanov 2017-11-20  662  		iov[iov_index].iov_base = skb_frag_address_safe(skb_frag);
49da7e64f33e80 Anton Ivanov 2017-11-20  663  		if (iov[iov_index].iov_base != NULL)
49da7e64f33e80 Anton Ivanov 2017-11-20  664  			iov[iov_index].iov_len = skb_frag_size(skb_frag);
49da7e64f33e80 Anton Ivanov 2017-11-20  665  		else
49da7e64f33e80 Anton Ivanov 2017-11-20  666  			iov[iov_index].iov_len = 0;
49da7e64f33e80 Anton Ivanov 2017-11-20  667  		iov_index++;
49da7e64f33e80 Anton Ivanov 2017-11-20  668  	}
49da7e64f33e80 Anton Ivanov 2017-11-20  669  done:
49da7e64f33e80 Anton Ivanov 2017-11-20  670  	msg->msg_iovlen = iov_index;
49da7e64f33e80 Anton Ivanov 2017-11-20  671  	return result;
49da7e64f33e80 Anton Ivanov 2017-11-20  672  }
49da7e64f33e80 Anton Ivanov 2017-11-20  673  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]