Skip to content

Commit

Permalink
rionet: fix page allocation order of rionet_active
Browse files Browse the repository at this point in the history
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: Akinobu 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: David S. Miller <davem@davemloft.net>
  • Loading branch information
Akinobu Mita authored and David S. Miller committed Apr 2, 2012
1 parent 3f8c91a commit acc6563
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/rionet.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = rio_get_drvdata(rdev);
struct rionet_peer *peer, *tmp;

free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
__fls(sizeof(void *)) + 4 : 0);
free_pages((unsigned long)rionet_active, get_order(sizeof(void *) *
RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size)));
unregister_netdev(ndev);
free_netdev(ndev);

Expand Down Expand Up @@ -432,15 +432,16 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
int rc = 0;
struct rionet_private *rnet;
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,
mport->sys_size ? __fls(sizeof(void *)) + 4 : 0);
get_order(rionet_active_bytes));
if (!rionet_active) {
rc = -ENOMEM;
goto out;
}
memset((void *)rionet_active, 0, sizeof(void *) *
RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
memset((void *)rionet_active, 0, rionet_active_bytes);

/* Set up private area */
rnet = netdev_priv(ndev);
Expand Down

0 comments on commit acc6563

Please sign in to comment.