All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: jasowang@redhat.com
Cc: virtualization@lists.linux-foundation.org
Subject: [bug report] vhost_net: basic polling support
Date: Wed, 11 Aug 2021 15:13:44 +0300	[thread overview]
Message-ID: <20210811121344.GA14245@kili> (raw)

Hello Jason Wang,

The patch 030881372460: "vhost_net: basic polling support" from Mar
4, 2016, leads to the following
Smatch static checker warning:

	drivers/vhost/vhost.c:2565 vhost_new_msg()
	warn: sleeping in atomic context

vers/vhost/net.c
   509  static void vhost_net_busy_poll(struct vhost_net *net,
   510                                  struct vhost_virtqueue *rvq,
   511                                  struct vhost_virtqueue *tvq,
   512                                  bool *busyloop_intr,
   513                                  bool poll_rx)
   514  {
   515          unsigned long busyloop_timeout;
   516          unsigned long endtime;
   517          struct socket *sock;
   518          struct vhost_virtqueue *vq = poll_rx ? tvq : rvq;
   519  
   520          /* Try to hold the vq mutex of the paired virtqueue. We can't
   521           * use mutex_lock() here since we could not guarantee a
   522           * consistenet lock ordering.
   523           */
   524          if (!mutex_trylock(&vq->mutex))
   525                  return;
   526  
   527          vhost_disable_notify(&net->dev, vq);
   528          sock = vhost_vq_get_backend(rvq);
   529  
   530          busyloop_timeout = poll_rx ? rvq->busyloop_timeout:
   531                                       tvq->busyloop_timeout;
   532  
   533          preempt_disable();
                ^^^^^^^^^^^^^^^^^
This bumps the preemp_count.

I guess this is to disable page faults?

   534          endtime = busy_clock() + busyloop_timeout;
   535  
   536          while (vhost_can_busy_poll(endtime)) {
   537                  if (vhost_has_work(&net->dev)) {
   538                          *busyloop_intr = true;
   539                          break;
   540                  }
   541  
   542                  if ((sock_has_rx_data(sock) &&
   543                       !vhost_vq_avail_empty(&net->dev, rvq)) ||

The call tree from here to the GFP_KERNEL is very long...

vhost_vq_avail_empty()
-> vhost_get_avail_idx()
   -> __vhost_get_user()
      -> __vhost_get_user_slow()
         -> translate_desc()
            -> vhost_iotlb_miss vhost_new_msg()  <-- GFP_KERNEL

   544                      !vhost_vq_avail_empty(&net->dev, tvq))
   545                          break;
   546  
   547                  cpu_relax();
   548          }
   549  
   550          preempt_enable();
   551  
   552          if (poll_rx || sock_has_rx_data(sock))
   553                  vhost_net_busy_poll_try_queue(net, vq);

regards,
dan carpenter
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

             reply	other threads:[~2021-08-11 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 12:13 Dan Carpenter [this message]
2021-08-11 12:51 ` [bug report] vhost_net: basic polling support Jason Wang
2021-08-11 13:32   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210811121344.GA14245@kili \
    --to=dan.carpenter@oracle.com \
    --cc=jasowang@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.