[v1,2/2] linux-gen: shm: odp_shm_print_all add total counters

Message ID 1535576407-32067-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • linux-gen: odp_shm_print_all() refine shm stats print
Related show

Commit Message

Github ODP bot Aug. 29, 2018, 9 p.m.
From: Maxim Uvarov <maxim.uvarov@linaro.org>


Add total allocated and total lost counters. That also requires
a little bit cleanup format string so output spreadshet looks
more nicely.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 686 (muvarov:devel/master_shm_print_all)
 ** https://github.com/Linaro/odp/pull/686
 ** Patch: https://github.com/Linaro/odp/pull/686.patch
 ** Base sha: 97fc51b1e5b3fcea9db99ba63c10bda47f79341a
 ** Merge commit sha: f69e295240994a3f642957c1a78d208242d066dd
 **/
 platform/linux-generic/odp_ishm.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Patch

diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index 131dd7057..effac7d6d 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -1730,6 +1730,8 @@  int _odp_ishm_status(const char *title)
 	int nb_blocks = 0;
 	int single_va_blocks = 0;
 	int max_name_len = 0;
+	uint64_t lost_total = 0; /* statistics for total unused memory */
+	uint64_t len_total = 0;  /* statistics for total allocated memory */
 
 	odp_spinlock_lock(&ishm_tbl->lock);
 	procsync();
@@ -1747,10 +1749,10 @@  int _odp_ishm_status(const char *title)
 			max_name_len = str_len;
 	}
 
-	ODP_PRINT("ishm blocks allocated at: %s\n", title);
-
-	ODP_PRINT("    %-*s flag len        user_len seq ref start        fd"
-		  "  file\n", max_name_len, "name");
+	ODP_PRINT("%s\n", title);
+	ODP_PRINT("    %-*s flag %-08s   %-08s   %-08s   %-3s %-3s  %-08s       %-3s file\n",
+		  max_name_len, "name", "len", "user_len", "lost",
+		  "seq", "ref", "start", "fd");
 
 	/* display block table: 1 line per entry +1 extra line if mapped here */
 	for (i = 0; i < ISHM_MAX_NB_BLOCKS; i++) {
@@ -1780,23 +1782,30 @@  int _odp_ishm_status(const char *title)
 			huge = '?';
 		}
 		proc_index = procfind_block(i);
-		ODP_PRINT("%2i  %-*s %s%c  0x%-08lx 0x%-08lx %-3lu %-3lu",
+		lost_total += ishm_tbl->block[i].len -
+			      ishm_tbl->block[i].user_len;
+		len_total += ishm_tbl->block[i].len;
+		ODP_PRINT("%2i  %-*s %s%c  0x%-08lx 0x%-08lx 0x%-08lx %-3lu %-3lu",
 			  i, max_name_len, ishm_tbl->block[i].name,
 			  flags, huge,
 			  ishm_tbl->block[i].len,
 			  ishm_tbl->block[i].user_len,
+			  ishm_tbl->block[i].len - ishm_tbl->block[i].user_len,
 			  ishm_tbl->block[i].seq,
 			  ishm_tbl->block[i].refcnt);
 
 		if (proc_index < 0)
 			continue;
 
-		ODP_PRINT("%-08lx %-3d",
+		ODP_PRINT("  0x%-08lx %-3d",
 			  ishm_proctable->entry[proc_index].start,
 			  ishm_proctable->entry[proc_index].fd);
 
-		ODP_PRINT("%s\n", ishm_tbl->block[i].filename);
+		ODP_PRINT("%s\n", ishm_tbl->block[i].filename[0] ?
+			  ishm_tbl->block[i].filename : "(none)");
 	}
+	ODP_PRINT("TOTAL: %41s%-08lx 0x%-08lx\n",
+		  "0x", len_total, lost_total);
 
 	/* display the virtual space allocations... : */
 	ODP_PRINT("\nishm virtual space:\n");