eal/bsd: enable contigmem blocks >1GB in size
authorBruce Richardson <bruce.richardson@intel.com>
Mon, 2 Mar 2015 16:34:20 +0000 (16:34 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 10 Mar 2015 15:19:43 +0000 (16:19 +0100)
The contigmem module was using an "int" type for specifying the
size of blocks of memory to be reserved. A 2GB block was therefore
overflowing the signed 32-bit value, making 1GB the largest block
size that could be reserved as a single unit.
The fix is to change the type used for the buffer/block size to
an "int64_t" value.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/bsdapp/contigmem/contigmem.c
lib/librte_eal/bsdapp/eal/eal_hugepage_info.c

index b1a23fa..6634daa 100644 (file)
@@ -63,20 +63,20 @@ static d_mmap_single_t  contigmem_mmap_single;
 static d_open_t         contigmem_open;
 
 static int              contigmem_num_buffers = RTE_CONTIGMEM_DEFAULT_NUM_BUFS;
-static int              contigmem_buffer_size = RTE_CONTIGMEM_DEFAULT_BUF_SIZE;
+static int64_t          contigmem_buffer_size = RTE_CONTIGMEM_DEFAULT_BUF_SIZE;
 
 static eventhandler_tag contigmem_eh_tag;
 static void            *contigmem_buffers[RTE_CONTIGMEM_MAX_NUM_BUFS];
 static struct cdev     *contigmem_cdev = NULL;
 
 TUNABLE_INT("hw.contigmem.num_buffers", &contigmem_num_buffers);
-TUNABLE_INT("hw.contigmem.buffer_size", &contigmem_buffer_size);
+TUNABLE_QUAD("hw.contigmem.buffer_size", &contigmem_buffer_size);
 
 static SYSCTL_NODE(_hw, OID_AUTO, contigmem, CTLFLAG_RD, 0, "contigmem");
 
 SYSCTL_INT(_hw_contigmem, OID_AUTO, num_buffers, CTLFLAG_RD,
        &contigmem_num_buffers, 0, "Number of contigmem buffers allocated");
-SYSCTL_INT(_hw_contigmem, OID_AUTO, buffer_size, CTLFLAG_RD,
+SYSCTL_QUAD(_hw_contigmem, OID_AUTO, buffer_size, CTLFLAG_RD,
        &contigmem_buffer_size, 0, "Size of each contiguous buffer");
 
 static SYSCTL_NODE(_hw_contigmem, OID_AUTO, physaddr, CTLFLAG_RD, 0,
@@ -133,7 +133,7 @@ contigmem_load()
 
        if (contigmem_buffer_size < PAGE_SIZE ||
                        (contigmem_buffer_size & (contigmem_buffer_size - 1)) != 0) {
-               printf("buffer size 0x%x is not greater than PAGE_SIZE and "
+               printf("buffer size 0x%lx is not greater than PAGE_SIZE and "
                                "power of two\n", contigmem_buffer_size);
                return (EINVAL);
        }
index 24248fb..8a33c30 100644 (file)
@@ -70,7 +70,8 @@ int
 eal_hugepage_info_init(void)
 {
        size_t sysctl_size;
-       int buffer_size, num_buffers, fd, error;
+       int num_buffers, fd, error;
+       int64_t buffer_size;
        /* re-use the linux "internal config" structure for our memory data */
        struct hugepage_info *hpi = &internal_config.hugepage_info[0];
        struct hugepage_info *tmp_hpi;
@@ -101,13 +102,13 @@ eal_hugepage_info_init(void)
 
        if (buffer_size >= 1<<30)
                RTE_LOG(INFO, EAL, "Contigmem driver has %d buffers, each of size %dGB\n",
-                               num_buffers, buffer_size>>30);
+                               num_buffers, (int)(buffer_size>>30));
        else if (buffer_size >= 1<<20)
                RTE_LOG(INFO, EAL, "Contigmem driver has %d buffers, each of size %dMB\n",
-                               num_buffers, buffer_size>>20);
+                               num_buffers, (int)(buffer_size>>20));
        else
                RTE_LOG(INFO, EAL, "Contigmem driver has %d buffers, each of size %dKB\n",
-                               num_buffers, buffer_size>>10);
+                               num_buffers, (int)(buffer_size>>10));
 
        internal_config.num_hugepage_sizes = 1;
        hpi->hugedir = CONTIGMEM_DEV;