DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] eal/bsd: enable contigmem blocks >1GB in size
Date: Mon,  2 Mar 2015 16:34:20 +0000	[thread overview]
Message-ID: <1425314060-2072-1-git-send-email-bruce.richardson@intel.com> (raw)

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   | 8 ++++----
 lib/librte_eal/bsdapp/eal/eal_hugepage_info.c | 9 +++++----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c b/lib/librte_eal/bsdapp/contigmem/contigmem.c
index b1a23fa..6634daa 100644
--- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
+++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
@@ -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);
 	}
diff --git a/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c b/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
index 24248fb..8a33c30 100644
--- a/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
@@ -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;
-- 
2.1.0

             reply	other threads:[~2015-03-02 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 16:34 Bruce Richardson [this message]
2015-03-10 15:20 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425314060-2072-1-git-send-email-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).