[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200908121626.31531.rusty@rustcorp.com.au>
Date: Wed, 12 Aug 2009 16:26:30 +0930
From: Rusty Russell <rusty@...tcorp.com.au>
To: Avi Kivity <avi@...hat.com>
Cc: Pierre Ossman <drzeus-list@...eus.cx>,
Minchan Kim <minchan.kim@...il.com>, kvm@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org,
Wu Fengguang <fengguang.wu@...el.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Rik van Riel <riel@...hat.com>, netdev@...r.kernel.org
Subject: Re: Page allocation failures in guest
On Wed, 12 Aug 2009 03:11:21 pm Avi Kivity wrote:
> > + /* In theory, this can happen: if we don't get any buffers in
> > + * we will*never* try to fill again. Sleeping in keventd if
> > + * bad, but that is worse. */
> > + if (still_empty) {
> > + msleep(100);
> > + schedule_work(&vi->refill);
> > + }
> > +}
> > +
>
> schedule_delayed_work()?
Hmm, might as well, although this is v. unlikely to happen.
Thanks,
Rusty.
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -72,7 +72,7 @@ struct virtnet_info
struct sk_buff_head send;
/* Work struct for refilling if we run low on memory. */
- struct work_struct refill;
+ struct delayed_work refill;
/* Chain pages by the private ptr. */
struct page *pages;
@@ -402,19 +402,16 @@ static void refill_work(struct work_stru
struct virtnet_info *vi;
bool still_empty;
- vi = container_of(work, struct virtnet_info, refill);
+ vi = container_of(work, struct virtnet_info, refill.work);
napi_disable(&vi->napi);
try_fill_recv(vi, GFP_KERNEL);
still_empty = (vi->num == 0);
napi_enable(&vi->napi);
/* In theory, this can happen: if we don't get any buffers in
- * we will *never* try to fill again. Sleeping in keventd if
- * bad, but that is worse. */
- if (still_empty) {
- msleep(100);
- schedule_work(&vi->refill);
- }
+ * we will *never* try to fill again. */
+ if (still_empty)
+ schedule_delayed_work(&vi->refill, HZ/2);
}
static int virtnet_poll(struct napi_struct *napi, int budget)
@@ -434,7 +431,7 @@ again:
if (vi->num < vi->max / 2) {
if (!try_fill_recv(vi, GFP_ATOMIC))
- schedule_work(&vi->refill);
+ schedule_delayed_work(&vi->refill, 0);
}
/* Out of packets? */
@@ -925,7 +922,7 @@ static int virtnet_probe(struct virtio_d
vi->vdev = vdev;
vdev->priv = vi;
vi->pages = NULL;
- INIT_WORK(&vi->refill, refill_work);
+ INIT_DELAYED_WORK(&vi->refill, refill_work);
/* If they give us a callback when all buffers are done, we don't need
* the timer. */
@@ -991,7 +988,7 @@ static int virtnet_probe(struct virtio_d
unregister:
unregister_netdev(dev);
- cancel_work_sync(&vi->refill);
+ cancel_delayed_work_sync(&vi->refill);
free_vqs:
vdev->config->del_vqs(vdev);
free:
@@ -1020,7 +1017,7 @@ static void virtnet_remove(struct virtio
BUG_ON(vi->num != 0);
unregister_netdev(vi->dev);
- cancel_work_sync(&vi->refill);
+ cancel_delayed_work_sync(&vi->refill);
vdev->config->del_vqs(vi->vdev);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists