]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
IB/fmr_pool: Allocate page list for pool FMRs only when caching enabled
authorOr Gerlitz <ogerlitz@voltaire.com>
Tue, 29 Jan 2008 10:56:18 +0000 (12:56 +0200)
committerRoland Dreier <rolandd@cisco.com>
Tue, 5 Feb 2008 04:20:44 +0000 (20:20 -0800)
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>
drivers/infiniband/core/fmr_pool.c

index 6c7aa59794d4ebb248f8e16fe789e7bdace6f81d..7f00347364f7a4b07f4b0237cb77ab45983c2732 100644 (file)
@@ -320,10 +320,13 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd             *pd,
                        .max_maps   = pool->max_remaps,
                        .page_shift = params->page_shift
                };
+               int bytes_per_fmr = sizeof *fmr;
+
+               if (pool->cache_bucket)
+                       bytes_per_fmr += params->max_pages_per_fmr * sizeof (u64);
 
                for (i = 0; i < params->pool_size; ++i) {
-                       fmr = kmalloc(sizeof *fmr + params->max_pages_per_fmr * sizeof (u64),
-                                     GFP_KERNEL);
+                       fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
                        if (!fmr) {
                                printk(KERN_WARNING PFX "failed to allocate fmr "
                                       "struct for FMR %d\n", i);