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>

authored by Or Gerlitz and committed by Roland Dreier 1d96354e 9fe4bcf4

+5 -2
+5 -2
drivers/infiniband/core/fmr_pool.c
··· 320 320 .max_maps = pool->max_remaps, 321 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 328 for (i = 0; i < params->pool_size; ++i) { 325 - fmr = kmalloc(sizeof *fmr + params->max_pages_per_fmr * sizeof (u64), 326 - GFP_KERNEL); 329 + fmr = kmalloc(bytes_per_fmr, GFP_KERNEL); 327 330 if (!fmr) { 328 331 printk(KERN_WARNING PFX "failed to allocate fmr " 329 332 "struct for FMR %d\n", i);