[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen-netback: Remove set but unused variable 'pending_idx'



Hi Jiapeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.1-rc8 next-20221208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    
https://github.com/intel-lab-lkp/linux/commits/Jiapeng-Chong/xen-netback-Remove-set-but-unused-variable-pending_idx/20221209-121717
patch link:    
https://lore.kernel.org/r/20221209034036.37280-1-jiapeng.chong%40linux.alibaba.com
patch subject: [PATCH] xen-netback: Remove set but unused variable 'pending_idx'
config: x86_64-allyesconfig
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # 
https://github.com/intel-lab-lkp/linux/commit/0a9a4de740b57dfd72a5afe13c96a048ece79171
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review 
Jiapeng-Chong/xen-netback-Remove-set-but-unused-variable-pending_idx/20221209-121717
        git checkout 0a9a4de740b57dfd72a5afe13c96a048ece79171
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/net/xen-netback/netback.c: In function 'xenvif_tx_build_gops':
>> drivers/net/xen-netback/netback.c:889:36: warning: variable 'index' set but 
>> not used [-Wunused-but-set-variable]
     889 |                 pending_ring_idx_t index;
         |                                    ^~~~~


vim +/index +889 drivers/net/xen-netback/netback.c

210c34dcd8d912 Paul Durrant   2015-09-02   871  
e9ce7cb6b10740 Wei Liu        2014-06-04   872  static void 
xenvif_tx_build_gops(struct xenvif_queue *queue,
bdab82759b8e36 Zoltan Kiss    2014-04-02   873                                  
     int budget,
bdab82759b8e36 Zoltan Kiss    2014-04-02   874                                  
     unsigned *copy_ops,
bdab82759b8e36 Zoltan Kiss    2014-04-02   875                                  
     unsigned *map_ops)
f942dc2552b8bf Ian Campbell   2011-03-15   876  {
2475b22526d702 Ross Lagerwall 2015-08-03   877          struct sk_buff *skb, 
*nskb;
f942dc2552b8bf Ian Campbell   2011-03-15   878          int ret;
2475b22526d702 Ross Lagerwall 2015-08-03   879          unsigned int 
frag_overflow;
f942dc2552b8bf Ian Campbell   2011-03-15   880  
e9ce7cb6b10740 Wei Liu        2014-06-04   881          while 
(skb_queue_len(&queue->tx_queue) < budget) {
f942dc2552b8bf Ian Campbell   2011-03-15   882                  struct 
xen_netif_tx_request txreq;
376414945d15aa Wei Liu        2013-05-02   883                  struct 
xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX];
f942dc2552b8bf Ian Campbell   2011-03-15   884                  struct 
xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX-1];
562abd39a19027 Paul Durrant   2016-03-10   885                  unsigned int 
extra_count;
f942dc2552b8bf Ian Campbell   2011-03-15   886                  RING_IDX idx;
f942dc2552b8bf Ian Campbell   2011-03-15   887                  int work_to_do;
f942dc2552b8bf Ian Campbell   2011-03-15   888                  unsigned int 
data_len;
f942dc2552b8bf Ian Campbell   2011-03-15  @889                  
pending_ring_idx_t index;
f942dc2552b8bf Ian Campbell   2011-03-15   890  
e9ce7cb6b10740 Wei Liu        2014-06-04   891                  if 
(queue->tx.sring->req_prod - queue->tx.req_cons >
48856286b64e4b Ian Campbell   2013-02-06   892                      
XEN_NETIF_TX_RING_SIZE) {
e9ce7cb6b10740 Wei Liu        2014-06-04   893                          
netdev_err(queue->vif->dev,
48856286b64e4b Ian Campbell   2013-02-06   894                                  
   "Impossible number of requests. "
48856286b64e4b Ian Campbell   2013-02-06   895                                  
   "req_prod %d, req_cons %d, size %ld\n",
e9ce7cb6b10740 Wei Liu        2014-06-04   896                                  
   queue->tx.sring->req_prod, queue->tx.req_cons,
48856286b64e4b Ian Campbell   2013-02-06   897                                  
   XEN_NETIF_TX_RING_SIZE);
e9ce7cb6b10740 Wei Liu        2014-06-04   898                          
xenvif_fatal_tx_err(queue->vif);
e9d8b2c2968499 Wei Liu        2014-04-01   899                          break;
48856286b64e4b Ian Campbell   2013-02-06   900                  }
48856286b64e4b Ian Campbell   2013-02-06   901  
09e545f7381459 Juergen Gross  2022-05-30   902                  work_to_do = 
XEN_RING_NR_UNCONSUMED_REQUESTS(&queue->tx);
b3f980bd827e6e Wei Liu        2013-08-26   903                  if (!work_to_do)
b3f980bd827e6e Wei Liu        2013-08-26   904                          break;
f942dc2552b8bf Ian Campbell   2011-03-15   905  
e9ce7cb6b10740 Wei Liu        2014-06-04   906                  idx = 
queue->tx.req_cons;
f942dc2552b8bf Ian Campbell   2011-03-15   907                  rmb(); /* 
Ensure that we see the request before we copy it. */
68a33bfd8403e4 David Vrabel   2015-10-30   908                  
RING_COPY_REQUEST(&queue->tx, idx, &txreq);
f942dc2552b8bf Ian Campbell   2011-03-15   909  
f942dc2552b8bf Ian Campbell   2011-03-15   910                  /* Credit-based 
scheduling. */
e9ce7cb6b10740 Wei Liu        2014-06-04   911                  if (txreq.size 
> queue->remaining_credit &&
e9ce7cb6b10740 Wei Liu        2014-06-04   912                      
tx_credit_exceeded(queue, txreq.size))
b3f980bd827e6e Wei Liu        2013-08-26   913                          break;
f942dc2552b8bf Ian Campbell   2011-03-15   914  
e9ce7cb6b10740 Wei Liu        2014-06-04   915                  
queue->remaining_credit -= txreq.size;
f942dc2552b8bf Ian Campbell   2011-03-15   916  
f942dc2552b8bf Ian Campbell   2011-03-15   917                  work_to_do--;
e9ce7cb6b10740 Wei Liu        2014-06-04   918                  
queue->tx.req_cons = ++idx;
f942dc2552b8bf Ian Campbell   2011-03-15   919  
f942dc2552b8bf Ian Campbell   2011-03-15   920                  memset(extras, 
0, sizeof(extras));
562abd39a19027 Paul Durrant   2016-03-10   921                  extra_count = 0;
f942dc2552b8bf Ian Campbell   2011-03-15   922                  if (txreq.flags 
& XEN_NETTXF_extra_info) {
e9ce7cb6b10740 Wei Liu        2014-06-04   923                          
work_to_do = xenvif_get_extras(queue, extras,
562abd39a19027 Paul Durrant   2016-03-10   924                                  
                       &extra_count,
f942dc2552b8bf Ian Campbell   2011-03-15   925                                  
                       work_to_do);
e9ce7cb6b10740 Wei Liu        2014-06-04   926                          idx = 
queue->tx.req_cons;
48856286b64e4b Ian Campbell   2013-02-06   927                          if 
(unlikely(work_to_do < 0))
b3f980bd827e6e Wei Liu        2013-08-26   928                                  
break;
f942dc2552b8bf Ian Campbell   2011-03-15   929                  }
f942dc2552b8bf Ian Campbell   2011-03-15   930  
210c34dcd8d912 Paul Durrant   2015-09-02   931                  if 
(extras[XEN_NETIF_EXTRA_TYPE_MCAST_ADD - 1].type) {
210c34dcd8d912 Paul Durrant   2015-09-02   932                          struct 
xen_netif_extra_info *extra;
210c34dcd8d912 Paul Durrant   2015-09-02   933  
210c34dcd8d912 Paul Durrant   2015-09-02   934                          extra = 
&extras[XEN_NETIF_EXTRA_TYPE_MCAST_ADD - 1];
210c34dcd8d912 Paul Durrant   2015-09-02   935                          ret = 
xenvif_mcast_add(queue->vif, extra->u.mcast.addr);
210c34dcd8d912 Paul Durrant   2015-09-02   936  
562abd39a19027 Paul Durrant   2016-03-10   937                          
make_tx_response(queue, &txreq, extra_count,
210c34dcd8d912 Paul Durrant   2015-09-02   938                                  
         (ret == 0) ?
210c34dcd8d912 Paul Durrant   2015-09-02   939                                  
         XEN_NETIF_RSP_OKAY :
210c34dcd8d912 Paul Durrant   2015-09-02   940                                  
         XEN_NETIF_RSP_ERROR);
210c34dcd8d912 Paul Durrant   2015-09-02   941                          
push_tx_responses(queue);
210c34dcd8d912 Paul Durrant   2015-09-02   942                          
continue;
210c34dcd8d912 Paul Durrant   2015-09-02   943                  }
210c34dcd8d912 Paul Durrant   2015-09-02   944  
210c34dcd8d912 Paul Durrant   2015-09-02   945                  if 
(extras[XEN_NETIF_EXTRA_TYPE_MCAST_DEL - 1].type) {
210c34dcd8d912 Paul Durrant   2015-09-02   946                          struct 
xen_netif_extra_info *extra;
210c34dcd8d912 Paul Durrant   2015-09-02   947  
210c34dcd8d912 Paul Durrant   2015-09-02   948                          extra = 
&extras[XEN_NETIF_EXTRA_TYPE_MCAST_DEL - 1];
210c34dcd8d912 Paul Durrant   2015-09-02   949                          
xenvif_mcast_del(queue->vif, extra->u.mcast.addr);
210c34dcd8d912 Paul Durrant   2015-09-02   950  
562abd39a19027 Paul Durrant   2016-03-10   951                          
make_tx_response(queue, &txreq, extra_count,
562abd39a19027 Paul Durrant   2016-03-10   952                                  
         XEN_NETIF_RSP_OKAY);
210c34dcd8d912 Paul Durrant   2015-09-02   953                          
push_tx_responses(queue);
210c34dcd8d912 Paul Durrant   2015-09-02   954                          
continue;
210c34dcd8d912 Paul Durrant   2015-09-02   955                  }
210c34dcd8d912 Paul Durrant   2015-09-02   956  
ad7f402ae4f466 Ross Lagerwall 2022-11-22   957                  data_len = 
(txreq.size > XEN_NETBACK_TX_COPY_LEN) ?
ad7f402ae4f466 Ross Lagerwall 2022-11-22   958                          
XEN_NETBACK_TX_COPY_LEN : txreq.size;
ad7f402ae4f466 Ross Lagerwall 2022-11-22   959  
562abd39a19027 Paul Durrant   2016-03-10   960                  ret = 
xenvif_count_requests(queue, &txreq, extra_count,
562abd39a19027 Paul Durrant   2016-03-10   961                                  
            txfrags, work_to_do);
ad7f402ae4f466 Ross Lagerwall 2022-11-22   962  
48856286b64e4b Ian Campbell   2013-02-06   963                  if 
(unlikely(ret < 0))
b3f980bd827e6e Wei Liu        2013-08-26   964                          break;
48856286b64e4b Ian Campbell   2013-02-06   965  
f942dc2552b8bf Ian Campbell   2011-03-15   966                  idx += ret;
f942dc2552b8bf Ian Campbell   2011-03-15   967  
f942dc2552b8bf Ian Campbell   2011-03-15   968                  if 
(unlikely(txreq.size < ETH_HLEN)) {
e9ce7cb6b10740 Wei Liu        2014-06-04   969                          
netdev_dbg(queue->vif->dev,
f942dc2552b8bf Ian Campbell   2011-03-15   970                                  
   "Bad packet size: %d\n", txreq.size);
562abd39a19027 Paul Durrant   2016-03-10   971                          
xenvif_tx_err(queue, &txreq, extra_count, idx);
b3f980bd827e6e Wei Liu        2013-08-26   972                          break;
f942dc2552b8bf Ian Campbell   2011-03-15   973                  }
f942dc2552b8bf Ian Campbell   2011-03-15   974  
f942dc2552b8bf Ian Campbell   2011-03-15   975                  /* No crossing 
a page as the payload mustn't fragment. */
d0089e8a0e4c97 Julien Grall   2015-05-05   976                  if 
(unlikely((txreq.offset + txreq.size) > XEN_PAGE_SIZE)) {
e9ce7cb6b10740 Wei Liu        2014-06-04   977                          
netdev_err(queue->vif->dev,
68946159da1b0b Julien Grall   2015-06-16   978                                  
   "txreq.offset: %u, size: %u, end: %lu\n",
f942dc2552b8bf Ian Campbell   2011-03-15   979                                  
   txreq.offset, txreq.size,
d0089e8a0e4c97 Julien Grall   2015-05-05   980                                  
   (unsigned long)(txreq.offset&~XEN_PAGE_MASK) + txreq.size);
e9ce7cb6b10740 Wei Liu        2014-06-04   981                          
xenvif_fatal_tx_err(queue->vif);
b3f980bd827e6e Wei Liu        2013-08-26   982                          break;
f942dc2552b8bf Ian Campbell   2011-03-15   983                  }
f942dc2552b8bf Ian Campbell   2011-03-15   984  
e9ce7cb6b10740 Wei Liu        2014-06-04   985                  index = 
pending_index(queue->pending_cons);
f942dc2552b8bf Ian Campbell   2011-03-15   986  
ad7f402ae4f466 Ross Lagerwall 2022-11-22   987                  if (ret >= 
XEN_NETBK_LEGACY_SLOTS_MAX - 1 && data_len < txreq.size)
ad7f402ae4f466 Ross Lagerwall 2022-11-22   988                          
data_len = txreq.size;
f942dc2552b8bf Ian Campbell   2011-03-15   989  
e3377f36ca20a0 Zoltan Kiss    2014-03-06   990                  skb = 
xenvif_alloc_skb(data_len);
f942dc2552b8bf Ian Campbell   2011-03-15   991                  if 
(unlikely(skb == NULL)) {
e9ce7cb6b10740 Wei Liu        2014-06-04   992                          
netdev_dbg(queue->vif->dev,
f942dc2552b8bf Ian Campbell   2011-03-15   993                                  
   "Can't allocate a skb in start_xmit.\n");
562abd39a19027 Paul Durrant   2016-03-10   994                          
xenvif_tx_err(queue, &txreq, extra_count, idx);
f942dc2552b8bf Ian Campbell   2011-03-15   995                          break;
f942dc2552b8bf Ian Campbell   2011-03-15   996                  }
f942dc2552b8bf Ian Campbell   2011-03-15   997  
2475b22526d702 Ross Lagerwall 2015-08-03   998                  
skb_shinfo(skb)->nr_frags = ret;
2475b22526d702 Ross Lagerwall 2015-08-03   999                  /* At this 
point shinfo->nr_frags is in fact the number of
2475b22526d702 Ross Lagerwall 2015-08-03  1000                   * slots, which 
can be as large as XEN_NETBK_LEGACY_SLOTS_MAX.
2475b22526d702 Ross Lagerwall 2015-08-03  1001                   */
2475b22526d702 Ross Lagerwall 2015-08-03  1002                  frag_overflow = 
0;
2475b22526d702 Ross Lagerwall 2015-08-03  1003                  nskb = NULL;
2475b22526d702 Ross Lagerwall 2015-08-03  1004                  if 
(skb_shinfo(skb)->nr_frags > MAX_SKB_FRAGS) {
2475b22526d702 Ross Lagerwall 2015-08-03  1005                          
frag_overflow = skb_shinfo(skb)->nr_frags - MAX_SKB_FRAGS;
2475b22526d702 Ross Lagerwall 2015-08-03  1006                          
BUG_ON(frag_overflow > MAX_SKB_FRAGS);
2475b22526d702 Ross Lagerwall 2015-08-03  1007                          
skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS;
2475b22526d702 Ross Lagerwall 2015-08-03  1008                          nskb = 
xenvif_alloc_skb(0);
2475b22526d702 Ross Lagerwall 2015-08-03  1009                          if 
(unlikely(nskb == NULL)) {
3a0233ddec554b Ross Lagerwall 2019-08-05  1010                                  
skb_shinfo(skb)->nr_frags = 0;
2475b22526d702 Ross Lagerwall 2015-08-03  1011                                  
kfree_skb(skb);
562abd39a19027 Paul Durrant   2016-03-10  1012                                  
xenvif_tx_err(queue, &txreq, extra_count, idx);
2475b22526d702 Ross Lagerwall 2015-08-03  1013                                  
if (net_ratelimit())
2475b22526d702 Ross Lagerwall 2015-08-03  1014                                  
        netdev_err(queue->vif->dev,
2475b22526d702 Ross Lagerwall 2015-08-03  1015                                  
                   "Can't allocate the frag_list skb.\n");
2475b22526d702 Ross Lagerwall 2015-08-03  1016                                  
break;
2475b22526d702 Ross Lagerwall 2015-08-03  1017                          }
2475b22526d702 Ross Lagerwall 2015-08-03  1018                  }
2475b22526d702 Ross Lagerwall 2015-08-03  1019  
f942dc2552b8bf Ian Campbell   2011-03-15  1020                  if 
(extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) {
f942dc2552b8bf Ian Campbell   2011-03-15  1021                          struct 
xen_netif_extra_info *gso;
f942dc2552b8bf Ian Campbell   2011-03-15  1022                          gso = 
&extras[XEN_NETIF_EXTRA_TYPE_GSO - 1];
f942dc2552b8bf Ian Campbell   2011-03-15  1023  
e9ce7cb6b10740 Wei Liu        2014-06-04  1024                          if 
(xenvif_set_skb_gso(queue->vif, skb, gso)) {
7376419a469765 Wei Liu        2013-08-26  1025                                  
/* Failure in xenvif_set_skb_gso is fatal. */
3a0233ddec554b Ross Lagerwall 2019-08-05  1026                                  
skb_shinfo(skb)->nr_frags = 0;
f942dc2552b8bf Ian Campbell   2011-03-15  1027                                  
kfree_skb(skb);
2475b22526d702 Ross Lagerwall 2015-08-03  1028                                  
kfree_skb(nskb);
b3f980bd827e6e Wei Liu        2013-08-26  1029                                  
break;
f942dc2552b8bf Ian Campbell   2011-03-15  1030                          }
f942dc2552b8bf Ian Campbell   2011-03-15  1031                  }
f942dc2552b8bf Ian Campbell   2011-03-15  1032  
c2d09fde7299f6 Paul Durrant   2016-05-13  1033                  if 
(extras[XEN_NETIF_EXTRA_TYPE_HASH - 1].type) {
c2d09fde7299f6 Paul Durrant   2016-05-13  1034                          struct 
xen_netif_extra_info *extra;
c2d09fde7299f6 Paul Durrant   2016-05-13  1035                          enum 
pkt_hash_types type = PKT_HASH_TYPE_NONE;
c2d09fde7299f6 Paul Durrant   2016-05-13  1036  
c2d09fde7299f6 Paul Durrant   2016-05-13  1037                          extra = 
&extras[XEN_NETIF_EXTRA_TYPE_HASH - 1];
c2d09fde7299f6 Paul Durrant   2016-05-13  1038  
c2d09fde7299f6 Paul Durrant   2016-05-13  1039                          switch 
(extra->u.hash.type) {
c2d09fde7299f6 Paul Durrant   2016-05-13  1040                          case 
_XEN_NETIF_CTRL_HASH_TYPE_IPV4:
c2d09fde7299f6 Paul Durrant   2016-05-13  1041                          case 
_XEN_NETIF_CTRL_HASH_TYPE_IPV6:
c2d09fde7299f6 Paul Durrant   2016-05-13  1042                                  
type = PKT_HASH_TYPE_L3;
c2d09fde7299f6 Paul Durrant   2016-05-13  1043                                  
break;
c2d09fde7299f6 Paul Durrant   2016-05-13  1044  
c2d09fde7299f6 Paul Durrant   2016-05-13  1045                          case 
_XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP:
c2d09fde7299f6 Paul Durrant   2016-05-13  1046                          case 
_XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP:
c2d09fde7299f6 Paul Durrant   2016-05-13  1047                                  
type = PKT_HASH_TYPE_L4;
c2d09fde7299f6 Paul Durrant   2016-05-13  1048                                  
break;
c2d09fde7299f6 Paul Durrant   2016-05-13  1049  
c2d09fde7299f6 Paul Durrant   2016-05-13  1050                          default:
c2d09fde7299f6 Paul Durrant   2016-05-13  1051                                  
break;
c2d09fde7299f6 Paul Durrant   2016-05-13  1052                          }
c2d09fde7299f6 Paul Durrant   2016-05-13  1053  
c2d09fde7299f6 Paul Durrant   2016-05-13  1054                          if 
(type != PKT_HASH_TYPE_NONE)
c2d09fde7299f6 Paul Durrant   2016-05-13  1055                                  
skb_set_hash(skb,
c2d09fde7299f6 Paul Durrant   2016-05-13  1056                                  
             *(u32 *)extra->u.hash.value,
c2d09fde7299f6 Paul Durrant   2016-05-13  1057                                  
             type);
c2d09fde7299f6 Paul Durrant   2016-05-13  1058                  }
c2d09fde7299f6 Paul Durrant   2016-05-13  1059  
ad7f402ae4f466 Ross Lagerwall 2022-11-22  1060                  
xenvif_get_requests(queue, skb, &txreq, txfrags, copy_ops,
ad7f402ae4f466 Ross Lagerwall 2022-11-22  1061                                  
    map_ops, frag_overflow, nskb, extra_count,
ad7f402ae4f466 Ross Lagerwall 2022-11-22  1062                                  
    data_len);
f942dc2552b8bf Ian Campbell   2011-03-15  1063  
e9ce7cb6b10740 Wei Liu        2014-06-04  1064                  
__skb_queue_tail(&queue->tx_queue, skb);
1e0b6eac6a150a Annie Li       2012-06-27  1065  
e9ce7cb6b10740 Wei Liu        2014-06-04  1066                  
queue->tx.req_cons = idx;
f942dc2552b8bf Ian Campbell   2011-03-15  1067  
ad7f402ae4f466 Ross Lagerwall 2022-11-22  1068                  if ((*map_ops 
>= ARRAY_SIZE(queue->tx_map_ops)) ||
e9ce7cb6b10740 Wei Liu        2014-06-04  1069                      (*copy_ops 
>= ARRAY_SIZE(queue->tx_copy_ops)))
f942dc2552b8bf Ian Campbell   2011-03-15  1070                          break;
f942dc2552b8bf Ian Campbell   2011-03-15  1071          }
f942dc2552b8bf Ian Campbell   2011-03-15  1072  
bdab82759b8e36 Zoltan Kiss    2014-04-02  1073          return;
f942dc2552b8bf Ian Campbell   2011-03-15  1074  }
f942dc2552b8bf Ian Campbell   2011-03-15  1075  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Attachment: config
Description: Text document


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.