Hi Jason,

[auto build test WARNING on vhost/linux-next]
[also build test WARNING on v4.14-rc1 next-20170915]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:    
https://github.com/0day-ci/linux/commits/Jason-Wang/vhost_net-conditionally-enable-tx-polling/20170918-112041
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: x86_64-randconfig-x009-201738 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers//vhost/net.c: In function 'handle_tx':
>> drivers//vhost/net.c:565:4: warning: suggest parentheses around assignment 
>> used as truth value [-Wparentheses]
       if (err = -EAGAIN)
       ^~

vim +565 drivers//vhost/net.c

   442  
   443  /* Expects to be always run from workqueue - which acts as
   444   * read-size critical section for our kind of RCU. */
   445  static void handle_tx(struct vhost_net *net)
   446  {
   447          struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
   448          struct vhost_virtqueue *vq = &nvq->vq;
   449          unsigned out, in;
   450          int head;
   451          struct msghdr msg = {
   452                  .msg_name = NULL,
   453                  .msg_namelen = 0,
   454                  .msg_control = NULL,
   455                  .msg_controllen = 0,
   456                  .msg_flags = MSG_DONTWAIT,
   457          };
   458          size_t len, total_len = 0;
   459          int err;
   460          size_t hdr_size;
   461          struct socket *sock;
   462          struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
   463          bool zcopy, zcopy_used;
   464  
   465          mutex_lock(&vq->mutex);
   466          sock = vq->private_data;
   467          if (!sock)
   468                  goto out;
   469  
   470          if (!vq_iotlb_prefetch(vq))
   471                  goto out;
   472  
   473          vhost_disable_notify(&net->dev, vq);
   474          vhost_net_disable_vq(net, vq);
   475  
   476          hdr_size = nvq->vhost_hlen;
   477          zcopy = nvq->ubufs;
   478  
   479          for (;;) {
   480                  /* Release DMAs done buffers first */
   481                  if (zcopy)
   482                          vhost_zerocopy_signal_used(net, vq);
   483  
   484                  /* If more outstanding DMAs, queue the work.
   485                   * Handle upend_idx wrap around
   486                   */
   487                  if (unlikely(vhost_exceeds_maxpend(net)))
   488                          break;
   489  
   490                  head = vhost_net_tx_get_vq_desc(net, vq, vq->iov,
   491                                                  ARRAY_SIZE(vq->iov),
   492                                                  &out, &in);
   493                  /* On error, stop handling until the next kick. */
   494                  if (unlikely(head < 0))
   495                          break;
   496                  /* Nothing new?  Wait for eventfd to tell us they 
refilled. */
   497                  if (head == vq->num) {
   498                          if (unlikely(vhost_enable_notify(&net->dev, 
vq))) {
   499                                  vhost_disable_notify(&net->dev, vq);
   500                                  continue;
   501                          }
   502                          break;
   503                  }
   504                  if (in) {
   505                          vq_err(vq, "Unexpected descriptor format for 
TX: "
   506                                 "out %d, int %d\n", out, in);
   507                          break;
   508                  }
   509                  /* Skip header. TODO: support TSO. */
   510                  len = iov_length(vq->iov, out);
   511                  iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len);
   512                  iov_iter_advance(&msg.msg_iter, hdr_size);
   513                  /* Sanity check */
   514                  if (!msg_data_left(&msg)) {
   515                          vq_err(vq, "Unexpected header len for TX: "
   516                                 "%zd expected %zd\n",
   517                                 len, hdr_size);
   518                          break;
   519                  }
   520                  len = msg_data_left(&msg);
   521  
   522                  zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN
   523                                     && (nvq->upend_idx + 1) % UIO_MAXIOV 
!=
   524                                        nvq->done_idx
   525                                     && vhost_net_tx_select_zcopy(net);
   526  
   527                  /* use msg_control to pass vhost zerocopy ubuf info to 
skb */
   528                  if (zcopy_used) {
   529                          struct ubuf_info *ubuf;
   530                          ubuf = nvq->ubuf_info + nvq->upend_idx;
   531  
   532                          vq->heads[nvq->upend_idx].id = 
cpu_to_vhost32(vq, head);
   533                          vq->heads[nvq->upend_idx].len = 
VHOST_DMA_IN_PROGRESS;
   534                          ubuf->callback = vhost_zerocopy_callback;
   535                          ubuf->ctx = nvq->ubufs;
   536                          ubuf->desc = nvq->upend_idx;
   537                          msg.msg_control = ubuf;
   538                          msg.msg_controllen = sizeof(ubuf);
   539                          ubufs = nvq->ubufs;
   540                          atomic_inc(&ubufs->refcount);
   541                          nvq->upend_idx = (nvq->upend_idx + 1) % 
UIO_MAXIOV;
   542                  } else {
   543                          msg.msg_control = NULL;
   544                          ubufs = NULL;
   545                  }
   546  
   547                  total_len += len;
   548                  if (total_len < VHOST_NET_WEIGHT &&
   549                      !vhost_vq_avail_empty(&net->dev, vq) &&
   550                      likely(!vhost_exceeds_maxpend(net))) {
   551                          msg.msg_flags |= MSG_MORE;
   552                  } else {
   553                          msg.msg_flags &= ~MSG_MORE;
   554                  }
   555  
   556                  /* TODO: Check specific error and bomb out unless 
ENOBUFS? */
   557                  err = sock->ops->sendmsg(sock, &msg, len);
   558                  if (unlikely(err < 0)) {
   559                          if (zcopy_used) {
   560                                  vhost_net_ubuf_put(ubufs);
   561                                  nvq->upend_idx = 
((unsigned)nvq->upend_idx - 1)
   562                                          % UIO_MAXIOV;
   563                          }
   564                          vhost_discard_vq_desc(vq, 1);
 > 565                          if (err = -EAGAIN)
   566                                  vhost_net_enable_vq(net, vq);
   567                          break;
   568                  }
   569                  if (err != len)
   570                          pr_debug("Truncated TX packet: "
   571                                   " len %d != %zd\n", err, len);
   572                  if (!zcopy_used)
   573                          vhost_add_used_and_signal(&net->dev, vq, head, 
0);
   574                  else
   575                          vhost_zerocopy_signal_used(net, vq);
   576                  vhost_net_tx_packet(net);
   577                  if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
   578                          vhost_poll_queue(&vq->poll);
   579                          break;
   580                  }
   581          }
   582  out:
   583          mutex_unlock(&vq->mutex);
   584  }
   585  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to