[Crash-utility] [PATCH 07/16] MIPS: Fix display memory size issue

Youling Tang tangyouling at loongson.cn
Tue Jan 26 11:13:31 UTC 2021


"__node_data" instead of "node_data" is used in the MIPS architecture,
so "__node_data" is used to replace "node_data" to improve the use of
next_online_pgdat() functions in the MIPS architecture.

E.g. Without this patch:
...
MEMORY: 0
...

With this patch:
...
MEMORY: 7.5 GB
...

Signed-off-by: Huacai Chen <chenhuacai at loongson.cn>
Signed-off-by: Youling Tang <tangyouling at loongson.cn>
---
 memory.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/memory.c b/memory.c
index 33b0ca7..5347958 100644
--- a/memory.c
+++ b/memory.c
@@ -17820,22 +17820,28 @@ next_online_pgdat(int node)
         char buf[BUFSIZE];
 	ulong pgdat;
 
+#ifndef __mips__
+#define NODE_DATA_VAR "node_data"
+#else
+#define NODE_DATA_VAR "__node_data"
+#endif
+
 	/*
-  	 *  Default -- look for type: struct pglist_data node_data[]
+	 *  Default -- look for type:  node_data[]/__node_data[]
 	 */
 	if (LKCD_KERNTYPES()) {
-		if (!kernel_symbol_exists("node_data"))
+		if (!kernel_symbol_exists(NODE_DATA_VAR))
 			goto pgdat2;
 		/* 
-		 *  Just index into node_data[] without checking that it is
-		 *  an array; kerntypes have no such symbol information.
+		 *  Just index into node_data[]/__node_data[] without checking that
+		 *  it is an array; kerntypes have no such symbol information.
 	 	 */
 	} else {
-		if (get_symbol_type("node_data", NULL, NULL) != TYPE_CODE_ARRAY)
+		if (get_symbol_type(NODE_DATA_VAR, NULL, NULL) != TYPE_CODE_ARRAY)
 			goto pgdat2;
 
 	        open_tmpfile();
-	        sprintf(buf, "whatis node_data");
+	        sprintf(buf, "whatis " NODE_DATA_VAR);
 	        if (!gdb_pass_through(buf, fp, GNU_RETURN_ON_ERROR)) {
 	                close_tmpfile();
 			goto pgdat2;
@@ -17848,14 +17854,15 @@ next_online_pgdat(int node)
 	        close_tmpfile();
 
 		if ((!strstr(buf, "struct pglist_data *") &&
-		     !strstr(buf, "pg_data_t *")) ||
+		     !strstr(buf, "pg_data_t *") &&
+		     !strstr(buf, "struct node_data *")) ||
 		    (count_chars(buf, '[') != 1) ||
 		    (count_chars(buf, ']') != 1))
 			goto pgdat2;
 	}
 
-	if (!readmem(symbol_value("node_data") + (node * sizeof(void *)), 
-	    KVADDR, &pgdat, sizeof(void *), "node_data", RETURN_ON_ERROR) ||
+	if (!readmem(symbol_value(NODE_DATA_VAR) + (node * sizeof(void *)),
+	    KVADDR, &pgdat, sizeof(void *), NODE_DATA_VAR, RETURN_ON_ERROR) ||
 	    !IS_KVADDR(pgdat))
 		goto pgdat2;
 
@@ -17883,7 +17890,8 @@ pgdat2:
 	        close_tmpfile();
 
 		if ((!strstr(buf, "struct pglist_data *") &&
-		     !strstr(buf, "pg_data_t *")) ||
+		     !strstr(buf, "pg_data_t *") &&
+		     !strstr(buf, "struct node_data *")) ||
 		    (count_chars(buf, '[') != 1) ||
 		    (count_chars(buf, ']') != 1))
 			goto pgdat3;
-- 
2.1.0




More information about the Crash-utility mailing list