Commit acc65632 authored by Akinobu Mita's avatar Akinobu Mita Committed by David S. Miller

rionet: fix page allocation order of rionet_active

rionet_active is allocated from the page allocator and the allocation
order is calculated on the assumption that the page size is 4KB, so it
wastes memory on more than 4K page systems.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3f8c91a7
...@@ -375,8 +375,8 @@ static void rionet_remove(struct rio_dev *rdev) ...@@ -375,8 +375,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = rio_get_drvdata(rdev); struct net_device *ndev = rio_get_drvdata(rdev);
struct rionet_peer *peer, *tmp; struct rionet_peer *peer, *tmp;
free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ? free_pages((unsigned long)rionet_active, get_order(sizeof(void *) *
__fls(sizeof(void *)) + 4 : 0); RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size)));
unregister_netdev(ndev); unregister_netdev(ndev);
free_netdev(ndev); free_netdev(ndev);
...@@ -432,15 +432,16 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) ...@@ -432,15 +432,16 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
int rc = 0; int rc = 0;
struct rionet_private *rnet; struct rionet_private *rnet;
u16 device_id; u16 device_id;
const size_t rionet_active_bytes = sizeof(void *) *
RIO_MAX_ROUTE_ENTRIES(mport->sys_size);
rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
mport->sys_size ? __fls(sizeof(void *)) + 4 : 0); get_order(rionet_active_bytes));
if (!rionet_active) { if (!rionet_active) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
memset((void *)rionet_active, 0, sizeof(void *) * memset((void *)rionet_active, 0, rionet_active_bytes);
RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
/* Set up private area */ /* Set up private area */
rnet = netdev_priv(ndev); rnet = netdev_priv(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment