From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Jason Wang <jasowang@redhat.com>
Cc: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>,
netdev@vger.kernel.org,
virtualization@lists.linux-foundation.org, tglx@linutronix.de,
"Michael S. Tsirkin" <mst@redhat.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [RFC] virtio_net: add local_bh_disable() around u64_stats_update_begin
Date: Thu, 18 Oct 2018 10:47:53 +0200 [thread overview]
Message-ID: <20181018084753.wefvsypdevbzoadg@linutronix.de> (raw)
In-Reply-To: <a281371f-dd20-2036-d0a8-1081c2f6a452@redhat.com>
On 2018-10-17 14:48:02 [+0800], Jason Wang wrote:
>
> On 2018/10/17 上午9:13, Toshiaki Makita wrote:
> > I'm not sure what condition triggered this warning.
If the seqlock is acquired once in softirq and then in process context
again it is enough evidence for lockdep to trigger this warning.
> > Toshiaki Makita
>
>
> Or maybe NAPI is enabled unexpectedly somewhere?
>
> Btw, the schedule_delayed_work() in virtnet_open() is also suspicious, if
> the work is executed before virtnet_napi_enable(), there will be a deadloop
> for napi_disable().
something like this? It is also likely if it runs OOM on queue 2, it
will run OOM again on queue 3.
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fbcfb4d272336..87d6ec4765270 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1263,22 +1263,22 @@ static void refill_work(struct work_struct *work)
{
struct virtnet_info *vi =
container_of(work, struct virtnet_info, refill.work);
- bool still_empty;
+ int still_empty = 0;
int i;
for (i = 0; i < vi->curr_queue_pairs; i++) {
struct receive_queue *rq = &vi->rq[i];
napi_disable(&rq->napi);
- still_empty = !try_fill_recv(vi, rq, GFP_KERNEL);
+ if (!try_fill_recv(vi, rq, GFP_KERNEL))
+ still_empty++;
virtnet_napi_enable(rq->vq, &rq->napi);
-
- /* In theory, this can happen: if we don't get any buffers in
- * we will *never* try to fill again.
- */
- if (still_empty)
- schedule_delayed_work(&vi->refill, HZ/2);
}
+ /* In theory, this can happen: if we don't get any buffers in
+ * we will *never* try to fill again.
+ */
+ if (still_empty)
+ schedule_delayed_work(&vi->refill, HZ/2);
}
static int virtnet_receive(struct receive_queue *rq, int budget,
@@ -1407,12 +1407,13 @@ static int virtnet_open(struct net_device *dev)
{
struct virtnet_info *vi = netdev_priv(dev);
int i, err;
+ int need_refill = 0;
for (i = 0; i < vi->max_queue_pairs; i++) {
if (i < vi->curr_queue_pairs)
/* Make sure we have some buffers: if oom use wq. */
if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL))
- schedule_delayed_work(&vi->refill, 0);
+ need_refill++;
err = xdp_rxq_info_reg(&vi->rq[i].xdp_rxq, dev, i);
if (err < 0)
@@ -1428,6 +1429,8 @@ static int virtnet_open(struct net_device *dev)
virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
virtnet_napi_tx_enable(vi, vi->sq[i].vq, &vi->sq[i].napi);
}
+ if (need_refill)
+ schedule_delayed_work(&vi->refill, 0);
return 0;
}
@@ -2236,6 +2239,7 @@ static int virtnet_restore_up(struct virtio_device *vdev)
{
struct virtnet_info *vi = vdev->priv;
int err, i;
+ int need_refill = 0;
err = init_vqs(vi);
if (err)
@@ -2246,13 +2250,15 @@ static int virtnet_restore_up(struct virtio_device *vdev)
if (netif_running(vi->dev)) {
for (i = 0; i < vi->curr_queue_pairs; i++)
if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL))
- schedule_delayed_work(&vi->refill, 0);
+ need_refill++;
for (i = 0; i < vi->max_queue_pairs; i++) {
virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
virtnet_napi_tx_enable(vi, vi->sq[i].vq,
&vi->sq[i].napi);
}
+ if (need_refill)
+ schedule_delayed_work(&vi->refill, 0);
}
netif_device_attach(vi->dev);
> Thanks
Sebastian
next prev parent reply other threads:[~2018-10-18 16:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 16:55 [RFC] virtio_net: add local_bh_disable() around u64_stats_update_begin Sebastian Andrzej Siewior
2018-10-16 17:59 ` Stephen Hemminger
2018-10-16 18:21 ` Sebastian Andrzej Siewior
2018-10-16 18:01 ` Stephen Hemminger
2018-10-16 18:42 ` Sebastian Andrzej Siewior
2018-10-16 18:44 ` Stephen Hemminger
2018-10-18 8:43 ` [PATCH] " Sebastian Andrzej Siewior
2018-10-18 9:06 ` Toshiaki Makita
2018-10-18 9:11 ` Sebastian Andrzej Siewior
2018-10-18 9:26 ` Toshiaki Makita
2018-10-18 23:23 ` David Miller
2018-10-19 2:19 ` Jason Wang
2018-10-17 1:13 ` [RFC] " Toshiaki Makita
2018-10-17 6:48 ` Jason Wang
2018-10-18 8:47 ` Sebastian Andrzej Siewior [this message]
2018-10-18 9:00 ` Toshiaki Makita
2018-10-18 9:08 ` Sebastian Andrzej Siewior
2018-10-18 9:19 ` Toshiaki Makita
2018-10-18 9:30 ` Sebastian Andrzej Siewior
2018-10-18 9:53 ` Toshiaki Makita
2018-10-18 13:21 ` Rafael David Tinoco
2018-10-19 2:17 ` Jason Wang
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=20181018084753.wefvsypdevbzoadg@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=jasowang@redhat.com \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).