[v2,1/1] linux-gen: odp_shm_print_all: refine output spreadsheet

Message ID 1536076812-7642-2-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 Sept. 4, 2018, 4 p.m.
From: Maxim Uvarov <maxim.uvarov@linaro.org>


Refine output print to make output spreadsheet more
readable:
Memory allocation status:
    name                      flag range                         user_len   unused   seq ref fd  file
 0  odp_thread_globals        ..N  0x7f59e1b74000-0x7f59e1b75000 3472       624      1   1   3  (none)
 1  _odp_pool_table           ..N  0x7f59bf40d000-0x7f59c0514000 17850432   4032     1   1   4  (none)
 2  _odp_queue_gbl            ..N  0x7f59e1ab0000-0x7f59e1b11000 393344     3968     1   1   5  (none)
 3  _odp_queue_rings          ..N  0x7f59bd40d000-0x7f59bf40d000 33554432   0        1   1   6  (none)
 4  odp_queues_lf             ..N  0x7f59e1a9f000-0x7f59e1ab0000 67648      1984     1   1   7  (none)
 5  odp_scheduler             ..N  0x7f59bcbb9000-0x7f59bd40d000 8730624    2048     1   1   9  (none)
 6  odp_pktio_entries         S.N  0x7f59c0600000-0x7f59c0651000 327744     4032     1   1   10 (none)
 7  crypto_pool               ..N  0x7f59e1b6f000-0x7f59e1b74000 19800      680      1   1   11 (none)
 8  shm_odp_cos_tbl           ..N  0x7f59e1a9a000-0x7f59e1a9f000 20480      0        1   1   12 (none)
 9  shm_odp_pmr_tbl           ..N  0x7f59e1a7e000-0x7f59e1a9a000 114688     0        1   1   13 (none)
10  shm_odp_cls_queue_grp_tbl ..N  0x7f59e1b6b000-0x7f59e1b6f000 16384      0        1   1   14 (none)
11  pool_ring_0               ..N  0x7f59bc7b8000-0x7f59bcbb9000 4194432    3968     1   1   15 (none)
12  ipsec_status_pool         ..N  0x7f59e19be000-0x7f59e1a7e000 786432     0        1   1   16 (none)
13  ipsec_sa_table            ..N  0x7f59e19bd000-0x7f59e19be000 2112       1984     1   1   17 (none)
14  test_shmem                ..N  0x7f59e19bb000-0x7f59e19bd000 4120       4072     7   1   18 (none)
TOTAL:                                                           66113536   27392
                                                                 (63MB)     (0MB)

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: 0a5d67beda902557056d5b5146d8cbe86e5001b0
 ** Merge commit sha: 2c557397820d67b1fcb7c7283da5506a114da186
 **/
 platform/linux-generic/odp_ishm.c | 33 ++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

Patch

diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index fc2f948cc..59d1fe534 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 %-29s %-08s   %-08s %-3s %-3s %-3s file\n",
+		  max_name_len, "name", "range", "user_len", "unused",
+		  "seq", "ref", "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,36 @@  int _odp_ishm_status(const char *title)
 			huge = '?';
 		}
 		proc_index = procfind_block(i);
-		ODP_PRINT("%2i  %-*s %s%c  0x%-08lx %-8lu %-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 %-08ld   %-08ld %-3lu %-3lu",
 			  i, max_name_len, ishm_tbl->block[i].name,
 			  flags, huge,
-			  ishm_tbl->block[i].len,
+			  ishm_proctable->entry[proc_index].start,
+			  (uintptr_t)ishm_proctable->entry[proc_index].start +
+				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",
-			  ishm_proctable->entry[proc_index].start,
+		ODP_PRINT(" %-3d",
 			  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: %58s%-08ld %2s%-08ld\n",
+		  "", len_total,
+		  "", lost_total);
+	ODP_PRINT("%65s(%dMB) %4s(%dMB)\n",
+		  "", len_total / 1024 / 1024,
+		  "", lost_total / 1024 / 1024);
+
 
 	/* display the virtual space allocations... : */
 	ODP_PRINT("\nishm virtual space:\n");