From 7adc359067081518dc323419172855e37f227652 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Wed, 23 Mar 2011 11:35:44 -0400 Subject: [PATCH] add virtio_net-add-schedule-check-to-napi_enable-call.patch --- kernel.spec | 7 ++ ...d-schedule-check-to-napi_enable-call.patch | 76 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 virtio_net-add-schedule-check-to-napi_enable-call.patch diff --git a/kernel.spec b/kernel.spec index ee1608576..d1e94e005 100644 --- a/kernel.spec +++ b/kernel.spec @@ -891,6 +891,8 @@ Patch13951: bridge-fix-mglist-corruption-that-leads-to-memory-corruption.patch # rhbz#649871 Patch13952: drm-hold-the-mutex-when-dropping-the-last-gem-reference-v2.patch +Patch13955: virtio_net-add-schedule-check-to-napi_enable-call.patch + %endif BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root @@ -1694,6 +1696,8 @@ ApplyPatch bridge-fix-mglist-corruption-that-leads-to-memory-corruption.patch # rhbz#649871 ApplyPatch drm-hold-the-mutex-when-dropping-the-last-gem-reference-v2.patch +ApplyPatch virtio_net-add-schedule-check-to-napi_enable-call.patch + # END OF PATCH APPLICATIONS %endif @@ -2314,6 +2318,9 @@ fi %kernel_variant_files %{with_pae_debug} PAEdebug %changelog +* Wed Mar 23 2011 Kyle McMartin +- Backport 3e9d08e: "virtio_net: Add schedule check to napi_enable call" + * Fri Mar 11 2011 Chuck Ebbert - Drop linux-2.6-defaults-aspm.patch; fixing ASPM properly will be too difficult in this old kernel. diff --git a/virtio_net-add-schedule-check-to-napi_enable-call.patch b/virtio_net-add-schedule-check-to-napi_enable-call.patch new file mode 100644 index 000000000..743c41006 --- /dev/null +++ b/virtio_net-add-schedule-check-to-napi_enable-call.patch @@ -0,0 +1,76 @@ +From 0d043d4e014306398b5aae1aebbeb9c258e2d5f1 Mon Sep 17 00:00:00 2001 +From: Bruce Rogers +Date: Thu, 10 Feb 2011 11:03:31 -0800 +Subject: [PATCH] virtio_net: Add schedule check to napi_enable call + +Under harsh testing conditions, including low memory, the guest would +stop receiving packets. With this patch applied we no longer see any +problems in the driver while performing these tests for extended periods +of time. + +Make sure napi is scheduled subsequent to each napi_enable. + +Signed-off-by: Bruce Rogers +Signed-off-by: Olaf Kirch +Cc: stable@kernel.org +Signed-off-by: Rusty Russell +Signed-off-by: David S. Miller +--- + drivers/net/virtio_net.c | 27 ++++++++++++++++----------- + 1 files changed, 16 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c +index f5b5d74..195104d 100644 +--- a/drivers/net/virtio_net.c ++++ b/drivers/net/virtio_net.c +@@ -448,6 +448,20 @@ static void skb_recv_done(struct virtqueue *rvq) + } + } + ++static void virtnet_napi_enable(struct virtnet_info *vi) ++{ ++ napi_enable(&vi->napi); ++ ++ /* If all buffers were filled by other side before we napi_enabled, we ++ * won't get another interrupt, so process any outstanding packets ++ * now. virtnet_poll wants re-enable the queue, so we disable here. ++ * We synchronize against interrupts via NAPI_STATE_SCHED */ ++ if (napi_schedule_prep(&vi->napi)) { ++ virtqueue_disable_cb(vi->rvq); ++ __napi_schedule(&vi->napi); ++ } ++} ++ + static void refill_work(struct work_struct *work) + { + struct virtnet_info *vi; +@@ -456,7 +470,7 @@ static void refill_work(struct work_struct *work) + vi = container_of(work, struct virtnet_info, refill.work); + napi_disable(&vi->napi); + still_empty = !try_fill_recv(vi, GFP_KERNEL); +- napi_enable(&vi->napi); ++ virtnet_napi_enable(vi); + + /* In theory, this can happen: if we don't get any buffers in + * we will *never* try to fill again. */ +@@ -642,16 +656,7 @@ static int virtnet_open(struct net_device *dev) + { + struct virtnet_info *vi = netdev_priv(dev); + +- napi_enable(&vi->napi); +- +- /* If all buffers were filled by other side before we napi_enabled, we +- * won't get another interrupt, so process any outstanding packets +- * now. virtnet_poll wants re-enable the queue, so we disable here. +- * We synchronize against interrupts via NAPI_STATE_SCHED */ +- if (napi_schedule_prep(&vi->napi)) { +- virtqueue_disable_cb(vi->rvq); +- __napi_schedule(&vi->napi); +- } ++ virtnet_napi_enable(vi); + return 0; + } + +-- +1.7.4.1 +