diff mbox

[2/2] linux-generic: reword messages for odp_shm_reserve

Message ID 1424780647-10250-2-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Feb. 24, 2015, 12:24 p.m. UTC
"mmap HP failed" is confusing message. It's not error it's
just debug hint that memory will be allocated with normal pages,
not huge pages. Also all ODP_DBG and etc macro already print
function name, no need to have it in message.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_shared_memory.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Mike Holmes Feb. 26, 2015, 2:02 p.m. UTC | #1
On 24 February 2015 at 07:24, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> "mmap HP failed" is confusing message. It's not error it's
> just debug hint that memory will be allocated with normal pages,
> not huge pages. Also all ODP_DBG and etc macro already print
> function name, no need to have it in message.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  platform/linux-generic/odp_shared_memory.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/platform/linux-generic/odp_shared_memory.c
> b/platform/linux-generic/odp_shared_memory.c
> index 251bf97..602e42f 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -209,7 +209,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>                 fd = shm_open(name, oflag,
>                               S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
>                 if (fd == -1) {
> -                       ODP_DBG("odp_shm_reserve: shm_open failed\n");
> +                       ODP_DBG("shm_open failed\n");
>

Can we display the name of the shm that failed.


>                         return ODP_SHM_INVALID;
>                 }
>         } else {
> @@ -221,7 +221,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>         if (find_block(name, NULL)) {
>                 /* Found a block with the same name */
>                 odp_spinlock_unlock(&odp_shm_tbl->lock);
> -               ODP_DBG("odp_shm_reserve: name already used\n");
> +               ODP_DBG("name already used\n");
>

Which name, can it be more specific ? looks like the original might be more
useful, add the actual name  used


>                 return ODP_SHM_INVALID;
>         }
>
> @@ -235,7 +235,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>         if (i > ODP_SHM_NUM_BLOCKS - 1) {
>                 /* Table full */
>                 odp_spinlock_unlock(&odp_shm_tbl->lock);
> -               ODP_DBG("odp_shm_reserve: no more blocks\n");
> +               ODP_DBG("no more blocks\n");
>

name ?


>                 return ODP_SHM_INVALID;
>         }
>
> @@ -250,14 +250,16 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>                 if ((flags & ODP_SHM_PROC) &&
>                     (ftruncate(fd, alloc_hp_size) == -1)) {
>                         odp_spinlock_unlock(&odp_shm_tbl->lock);
> -                       ODP_DBG("odp_shm_reserve: ftruncate HP failed\n");
> +                       ODP_DBG("ftruncate huge pages failed\n");
>

name ?


>                         return ODP_SHM_INVALID;
>                 }
>
>                 addr = mmap(NULL, alloc_hp_size, PROT_READ | PROT_WRITE,
>                                 map_flag | MAP_HUGETLB, fd, 0);
>                 if (addr == MAP_FAILED) {
> -                       ODP_DBG("odp_shm_reserve: mmap HP failed\n");
> +                       ODP_DBG("\n"
> +                               "\tNo huge pages, fall back to normal
> pages.\n"
> +                               "\tCheck: /proc/sys/vm/nr_hugepages\n");
>

name ?


>                 } else {
>                         block->alloc_size = alloc_hp_size;
>                         block->huge = 1;
> @@ -271,7 +273,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>                 if ((flags & ODP_SHM_PROC) &&
>                     (ftruncate(fd, alloc_size) == -1)) {
>                         odp_spinlock_unlock(&odp_shm_tbl->lock);
> -                       ODP_ERR("odp_shm_reserve: ftruncate failed\n");
> +                       ODP_ERR("ftruncate failed\n");
>
name ?



>                         return ODP_SHM_INVALID;
>                 }
>
> @@ -279,7 +281,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
> size, uint64_t align,
>                                 map_flag, fd, 0);
>                 if (addr == MAP_FAILED) {
>                         odp_spinlock_unlock(&odp_shm_tbl->lock);
> -                       ODP_DBG("odp_shm_reserve: mmap failed\n");
> +                       ODP_DBG("mmap failed\n");
>

name ?


>                         return ODP_SHM_INVALID;
>                 } else {
>                         block->alloc_size = alloc_size;
> --
> 1.8.5.1.163.gd7aced9
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 251bf97..602e42f 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -209,7 +209,7 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 		fd = shm_open(name, oflag,
 			      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 		if (fd == -1) {
-			ODP_DBG("odp_shm_reserve: shm_open failed\n");
+			ODP_DBG("shm_open failed\n");
 			return ODP_SHM_INVALID;
 		}
 	} else {
@@ -221,7 +221,7 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 	if (find_block(name, NULL)) {
 		/* Found a block with the same name */
 		odp_spinlock_unlock(&odp_shm_tbl->lock);
-		ODP_DBG("odp_shm_reserve: name already used\n");
+		ODP_DBG("name already used\n");
 		return ODP_SHM_INVALID;
 	}
 
@@ -235,7 +235,7 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 	if (i > ODP_SHM_NUM_BLOCKS - 1) {
 		/* Table full */
 		odp_spinlock_unlock(&odp_shm_tbl->lock);
-		ODP_DBG("odp_shm_reserve: no more blocks\n");
+		ODP_DBG("no more blocks\n");
 		return ODP_SHM_INVALID;
 	}
 
@@ -250,14 +250,16 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 		if ((flags & ODP_SHM_PROC) &&
 		    (ftruncate(fd, alloc_hp_size) == -1)) {
 			odp_spinlock_unlock(&odp_shm_tbl->lock);
-			ODP_DBG("odp_shm_reserve: ftruncate HP failed\n");
+			ODP_DBG("ftruncate huge pages failed\n");
 			return ODP_SHM_INVALID;
 		}
 
 		addr = mmap(NULL, alloc_hp_size, PROT_READ | PROT_WRITE,
 				map_flag | MAP_HUGETLB, fd, 0);
 		if (addr == MAP_FAILED) {
-			ODP_DBG("odp_shm_reserve: mmap HP failed\n");
+			ODP_DBG("\n"
+				"\tNo huge pages, fall back to normal pages.\n"
+				"\tCheck: /proc/sys/vm/nr_hugepages\n");
 		} else {
 			block->alloc_size = alloc_hp_size;
 			block->huge = 1;
@@ -271,7 +273,7 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 		if ((flags & ODP_SHM_PROC) &&
 		    (ftruncate(fd, alloc_size) == -1)) {
 			odp_spinlock_unlock(&odp_shm_tbl->lock);
-			ODP_ERR("odp_shm_reserve: ftruncate failed\n");
+			ODP_ERR("ftruncate failed\n");
 			return ODP_SHM_INVALID;
 		}
 
@@ -279,7 +281,7 @@  odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 				map_flag, fd, 0);
 		if (addr == MAP_FAILED) {
 			odp_spinlock_unlock(&odp_shm_tbl->lock);
-			ODP_DBG("odp_shm_reserve: mmap failed\n");
+			ODP_DBG("mmap failed\n");
 			return ODP_SHM_INVALID;
 		} else {
 			block->alloc_size = alloc_size;