aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@voltaire.com>2008-01-29 05:56:18 -0500
committerRoland Dreier <rolandd@cisco.com>2008-02-04 23:20:44 -0500
commit1d96354e617990799b1cb5d7ff8f7c467b8767c8 (patch)
tree7d106bf836c8cd99ee844845e71216e83c004248 /drivers/infiniband
parent9fe4bcf45ece0b0081031edaaa41581c85ef7049 (diff)
IB/fmr_pool: Allocate page list for pool FMRs only when caching enabled
Allocate memory for the page_list field of struct ib_pool_fmr only when caching is enabled for the FMR pool, since the field is not used otherwise. This can save significant amounts of memory for large pools with caching turned off. Signed-off-by: Or Gerlitz <ogerlitz@voltaire.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/fmr_pool.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 6c7aa59794d..7f00347364f 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -320,10 +320,13 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
320 .max_maps = pool->max_remaps, 320 .max_maps = pool->max_remaps,
321 .page_shift = params->page_shift 321 .page_shift = params->page_shift
322 }; 322 };
323 int bytes_per_fmr = sizeof *fmr;
324
325 if (pool->cache_bucket)
326 bytes_per_fmr += params->max_pages_per_fmr * sizeof (u64);
323 327
324 for (i = 0; i < params->pool_size; ++i) { 328 for (i = 0; i < params->pool_size; ++i) {
325 fmr = kmalloc(sizeof *fmr + params->max_pages_per_fmr * sizeof (u64), 329 fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
326 GFP_KERNEL);
327 if (!fmr) { 330 if (!fmr) {
328 printk(KERN_WARNING PFX "failed to allocate fmr " 331 printk(KERN_WARNING PFX "failed to allocate fmr "
329 "struct for FMR %d\n", i); 332 "struct for FMR %d\n", i);