diff mbox

[net-next,v10,1/7] xen-netback: Move grant_copy_op array back into struct xenvif.

Message ID 1401874247-3202-2-git-send-email-wei.liu2@citrix.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Wei Liu June 4, 2014, 9:30 a.m. UTC
From: "Andrew J. Bennieston" <andrew.bennieston@citrix.com>

This array was allocated separately in commit ac3d5ac2 ("xen-netback:
fix guest-receive-side array sizes") due to it being very large, and a
struct xenvif is allocated as the netdev_priv part of a struct
net_device, i.e. via kmalloc() but falling back to vmalloc() if the
initial alloc. fails.

In preparation for the multi-queue patches, where this array becomes
part of struct xenvif_queue and is always allocated through vzalloc(),
move this back into the struct xenvif.

Signed-off-by: Andrew J. Bennieston <andrew.bennieston@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 drivers/net/xen-netback/common.h    |    3 +--
 drivers/net/xen-netback/interface.c |    9 ---------
 2 files changed, 1 insertion(+), 11 deletions(-)

Comments

Sergei Shtylyov June 4, 2014, 2:46 p.m. UTC | #1
Hello.

On 06/04/2014 01:30 PM, Wei Liu wrote:

> From: "Andrew J. Bennieston" <andrew.bennieston@citrix.com>

> This array was allocated separately in commit ac3d5ac2 ("xen-netback:
> fix guest-receive-side array sizes") due to it being very large, and a
> struct xenvif is allocated as the netdev_priv part of a struct
> net_device, i.e. via kmalloc() but falling back to vmalloc() if the
> initial alloc. fails.

> In preparation for the multi-queue patches, where this array becomes
> part of struct xenvif_queue and is always allocated through vzalloc(),
> move this back into the struct xenvif.

    Won't this cause an allocation failure and so break bisection at this patch?

> Signed-off-by: Andrew J. Bennieston <andrew.bennieston@citrix.com>
> Acked-by: Wei Liu <wei.liu2@citrix.com>

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Vrabel June 4, 2014, 2:52 p.m. UTC | #2
On 04/06/14 15:46, Sergei Shtylyov wrote:
> Hello.
> 
> On 06/04/2014 01:30 PM, Wei Liu wrote:
> 
>> From: "Andrew J. Bennieston" <andrew.bennieston@citrix.com>
> 
>> This array was allocated separately in commit ac3d5ac2 ("xen-netback:
>> fix guest-receive-side array sizes") due to it being very large, and a
>> struct xenvif is allocated as the netdev_priv part of a struct
>> net_device, i.e. via kmalloc() but falling back to vmalloc() if the
>> initial alloc. fails.
> 
>> In preparation for the multi-queue patches, where this array becomes
>> part of struct xenvif_queue and is always allocated through vzalloc(),
>> move this back into the struct xenvif.
> 
>    Won't this cause an allocation failure and so break bisection at this
> patch?

No. As Andrew already said: "...falling back to vmalloc() if the
initial alloc. fails."

David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov June 4, 2014, 3 p.m. UTC | #3
Hello.

On 06/04/2014 06:52 PM, David Vrabel wrote:

>>> This array was allocated separately in commit ac3d5ac2 ("xen-netback:
>>> fix guest-receive-side array sizes") due to it being very large, and a
>>> struct xenvif is allocated as the netdev_priv part of a struct
>>> net_device, i.e. via kmalloc() but falling back to vmalloc() if the
>>> initial alloc. fails.

>>> In preparation for the multi-queue patches, where this array becomes
>>> part of struct xenvif_queue and is always allocated through vzalloc(),
>>> move this back into the struct xenvif.

>>     Won't this cause an allocation failure and so break bisection at this
>> patch?

> No. As Andrew already said: "...falling back to vmalloc() if the
> initial alloc. fails."

    Ah, sorry, I've managed to forget about that part. :-/

> David

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wei Liu June 4, 2014, 3:03 p.m. UTC | #4
On Wed, Jun 04, 2014 at 06:46:42PM +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 06/04/2014 01:30 PM, Wei Liu wrote:
> 
> >From: "Andrew J. Bennieston" <andrew.bennieston@citrix.com>
> 
> >This array was allocated separately in commit ac3d5ac2 ("xen-netback:
> >fix guest-receive-side array sizes") due to it being very large, and a
> >struct xenvif is allocated as the netdev_priv part of a struct
> >net_device, i.e. via kmalloc() but falling back to vmalloc() if the
> >initial alloc. fails.
> 
> >In preparation for the multi-queue patches, where this array becomes
> >part of struct xenvif_queue and is always allocated through vzalloc(),
> >move this back into the struct xenvif.
> 
>    Won't this cause an allocation failure and so break bisection at this patch?
> 

As stated in the commit message, this array is now allocated with
vzalloc, which is no different from what it was done before (with
vmalloc in ac3d5ac2).

Wei.

> >Signed-off-by: Andrew J. Bennieston <andrew.bennieston@citrix.com>
> >Acked-by: Wei Liu <wei.liu2@citrix.com>
> 
> WBR, Sergei
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 0d4a285..2c283d6 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -158,8 +158,7 @@  struct xenvif {
 
 	struct timer_list wake_queue;
 
-	/* This array is allocated seperately as it is large */
-	struct gnttab_copy *grant_copy_op;
+	struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS];
 
 	/* We create one meta structure per ring request we consume, so
 	 * the maximum number is the same as the ring size.
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 53cdcdf..8fdedac 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -334,14 +334,6 @@  struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
 
 	vif = netdev_priv(dev);
 
-	vif->grant_copy_op = vmalloc(sizeof(struct gnttab_copy) *
-				     MAX_GRANT_COPY_OPS);
-	if (vif->grant_copy_op == NULL) {
-		pr_warn("Could not allocate grant copy space for %s\n", name);
-		free_netdev(dev);
-		return ERR_PTR(-ENOMEM);
-	}
-
 	vif->domid  = domid;
 	vif->handle = handle;
 	vif->can_sg = 1;
@@ -601,7 +593,6 @@  void xenvif_free(struct xenvif *vif)
 
 	unregister_netdev(vif->dev);
 
-	vfree(vif->grant_copy_op);
 	free_netdev(vif->dev);
 
 	module_put(THIS_MODULE);