@@ -69,6 +69,9 @@ static int xenvif_poll(struct napi_struct *napi, int budget)
struct xenvif *vif = container_of(napi, struct xenvif, napi);
int work_done = 0;
+ /* N.B.: work_done may be -ENOMEM, indicating scratch space on
+ * this CPU is not usable. In this situation, we shutdown
+ * NAPI. See __napi_complete check below.*/
work_done = xenvif_tx_action(vif, budget);
if (work_done < budget) {
@@ -78,7 +81,7 @@ static int xenvif_poll(struct napi_struct *napi, int budget)
local_irq_save(flag);
RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, more_to_do);
- if (!more_to_do)
+ if (!more_to_do || work_done < 0)
__napi_complete(napi);
local_irq_restore(flag);
@@ -490,6 +490,15 @@ void xenvif_rx_action(struct xenvif *vif)
.meta = m,
};
+ if (gco == NULL || m == NULL) {
+ put_cpu_var(grant_copy_op);
+ put_cpu_var(meta);
+ printk(KERN_ALERT "netback: CPU %x scratch space is not usable,"
+ " not doing any TX work for vif%u.%u\n",
+ smp_processor_id(), vif->domid, vif->handle);
+ return;
+ }
+
skb_queue_head_init(&rxq);
count = 0;
@@ -1290,6 +1299,14 @@ int xenvif_tx_action(struct xenvif *vif, int budget)
tco = get_cpu_var(tx_copy_ops);
+ if (tco == NULL) {
+ put_cpu_var(tx_copy_ops);
+ printk(KERN_ALERT "netback: CPU %x scratch space is not usable,"
+ " not doing any RX work for vif%u.%u\n",
+ smp_processor_id(), vif->domid, vif->handle);
+ return -ENOMEM;
+ }
+
nr_gops = xenvif_tx_build_gops(vif, tco);
if (nr_gops == 0) {
CPU online event causes our callback to allocate scratch space for this CPU, which may fail. The simplest and best action when NAPI or kthread is scheduled on that CPU is to bail. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- drivers/net/xen-netback/interface.c | 5 ++++- drivers/net/xen-netback/netback.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-)