eal/bsd: enable contigmem blocks >1GB in size
PATCH 1/1 eal/bsd: enable contigmem blocks >1GB in size
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.
--- lib/librte_eal/bsdapp/contigmem/contigmem.c | 8 ++++---- lib/librte_eal/bsdapp/eal/eal_hugepage_info.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/contigmem/contigmem.c +4 -4
@@ -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 ); }
lib/librte_eal/bsdapp/eal/eal_hugepage_info.c +5 -4
@@ -70,7 +70,8 @@ inteal_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 ;
Signature · 1 line
2.1.0
A message that is not in the archive (sent off-list or not yet received): 1425314060-2072-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Thomas Monjalon
AppliedQuoted 8 lines
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 <[email protected]>
Applied, thanks