diff options
author | Paul Durrant <Paul.Durrant@citrix.com> | 2013-12-23 04:27:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-29 22:31:30 -0500 |
commit | ac3d5ac277352fe6e27809286768e9f1f8aa388d (patch) | |
tree | 1291e41ffe15d90e5e7f6b6d019b62b9d1bbdaa6 /drivers/net/xen-netback/interface.c | |
parent | 7a399e3a2e05bc580a78ea72371b3896827f72e1 (diff) |
xen-netback: fix guest-receive-side array sizes
The sizes chosen for the metadata and grant_copy_op arrays on the guest
receive size are wrong;
- The meta array is needlessly twice the ring size, when we only ever
consume a single array element per RX ring slot
- The grant_copy_op array is way too small. It's sized based on a bogus
assumption: that at most two copy ops will be used per ring slot. This
may have been true at some point in the past but it's clear from looking
at start_new_rx_buffer() that a new ring slot is only consumed if a frag
would overflow the current slot (plus some other conditions) so the actual
limit is MAX_SKB_FRAGS grant_copy_ops per ring slot.
This patch fixes those two sizing issues and, because grant_copy_ops grows
so much, it pulls it out into a separate chunk of vmalloc()ed memory.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netback/interface.c')
-rw-r--r-- | drivers/net/xen-netback/interface.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index 870f1fa58370..34ca4e58a43d 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c | |||
@@ -307,6 +307,15 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, | |||
307 | SET_NETDEV_DEV(dev, parent); | 307 | SET_NETDEV_DEV(dev, parent); |
308 | 308 | ||
309 | vif = netdev_priv(dev); | 309 | vif = netdev_priv(dev); |
310 | |||
311 | vif->grant_copy_op = vmalloc(sizeof(struct gnttab_copy) * | ||
312 | MAX_GRANT_COPY_OPS); | ||
313 | if (vif->grant_copy_op == NULL) { | ||
314 | pr_warn("Could not allocate grant copy space for %s\n", name); | ||
315 | free_netdev(dev); | ||
316 | return ERR_PTR(-ENOMEM); | ||
317 | } | ||
318 | |||
310 | vif->domid = domid; | 319 | vif->domid = domid; |
311 | vif->handle = handle; | 320 | vif->handle = handle; |
312 | vif->can_sg = 1; | 321 | vif->can_sg = 1; |
@@ -487,6 +496,7 @@ void xenvif_free(struct xenvif *vif) | |||
487 | 496 | ||
488 | unregister_netdev(vif->dev); | 497 | unregister_netdev(vif->dev); |
489 | 498 | ||
499 | vfree(vif->grant_copy_op); | ||
490 | free_netdev(vif->dev); | 500 | free_netdev(vif->dev); |
491 | 501 | ||
492 | module_put(THIS_MODULE); | 502 | module_put(THIS_MODULE); |