Skip to contentSkip to conversation

memory: dump HPA and access type of ramblocks

PATCH In review Ted Chen 4 participants 7 messages Dec 5, 2022 – Mar 9, 2023

lore
Share & tools
lore

Ted Chen

author
#0 lore raw

PATCH 1/1 memory: dump HPA and access type of ramblocks

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

---
 softmmu/physmem.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
softmmu/physmem.c +10 -4
index 1b606a3002..fed4dfb72c 100644
@@ -1316,15 +1316,21 @@ GString *ram_block_format(void)
     GString *buf = g_string_new("");
 
     RCU_READ_LOCK_GUARD();
-    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s\n",
-                           "Block Name", "PSize", "Offset", "Used", "Total");
+    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s %18s %3s\n",
+                           "Block Name", "PSize", "Offset", "Used", "Total",
+                           "HVA", "RO");
+
     RAMBLOCK_FOREACH(block) {
         psize = size_to_str(block->page_size);
         g_string_append_printf(buf, "%24s %8s  0x%016" PRIx64 " 0x%016" PRIx64
-                               " 0x%016" PRIx64 "\n", block->idstr, psize,
+                               " 0x%016" PRIx64 " 0x%016" PRIx64 " %3s\n",
+                               block->idstr, psize,
                                (uint64_t)block->offset,
                                (uint64_t)block->used_length,
-                               (uint64_t)block->max_length);
+                               (uint64_t)block->max_length,
+                               (uint64_t)block->host,
+                               block->mr->readonly ? "ro" : "rw");
+
         g_free(psize);
     }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Ted Chen

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

Quoted 8 lines

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

---
  softmmu/physmem.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ted Chen
Quoted 36 lines · Ted Chen

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

---
  softmmu/physmem.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)
softmmu/physmem.c +6 -3
index 1b606a3002..fed4dfb72c 100644
@@ -1316,15 +1316,21 @@ GString *ram_block_format(void)
      GString *buf = g_string_new("");
 
      RCU_READ_LOCK_GUARD();
-    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s\n",
-                           "Block Name", "PSize", "Offset", "Used", "Total");
+    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s %18s %3s\n",
+                           "Block Name", "PSize", "Offset", "Used", "Total",
+                           "HVA", "RO");
+
      RAMBLOCK_FOREACH(block) {
          psize = size_to_str(block->page_size);
          g_string_append_printf(buf, "%24s %8s  0x%016" PRIx64 " 0x%016" PRIx64
-                               " 0x%016" PRIx64 "\n", block->idstr, psize,
+                               " 0x%016" PRIx64 " 0x%016" PRIx64 " %3s\n",
+                               block->idstr, psize,

softmmu/physmem.c GString *ram_block_format(void) · line 1336

Quoted 10 lines
softmmu/physmem.c +4 -1
                                 (uint64_t)block->offset,
                                 (uint64_t)block->used_length,
-                               (uint64_t)block->max_length);
+                               (uint64_t)block->max_length,
+                               (uint64_t)block->host,
+                               block->mr->readonly ? "ro" : "rw");
+
          g_free(psize);
      }
 
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 1/1
#3 lore raw
In reply to Ted Chen
Quoted 7 lines · Ted Chen

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

Quoted 5 lines

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

Signature · 1 line
Peter Xu
#4 lore raw
In reply to Ted Chen

Since I applied this twice already to my local trees, let me ping for Ted to make sure it's not lost..

Quoted 49 lines · Ted Chen

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

---
 softmmu/physmem.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
softmmu/physmem.c +10 -4
index 1b606a3002..fed4dfb72c 100644
@@ -1316,15 +1316,21 @@ GString *ram_block_format(void)
     GString *buf = g_string_new("");
 
     RCU_READ_LOCK_GUARD();
-    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s\n",
-                           "Block Name", "PSize", "Offset", "Used", "Total");
+    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s %18s %3s\n",
+                           "Block Name", "PSize", "Offset", "Used", "Total",
+                           "HVA", "RO");
+
     RAMBLOCK_FOREACH(block) {
         psize = size_to_str(block->page_size);
         g_string_append_printf(buf, "%24s %8s  0x%016" PRIx64 " 0x%016" PRIx64
-                               " 0x%016" PRIx64 "\n", block->idstr, psize,
+                               " 0x%016" PRIx64 " 0x%016" PRIx64 " %3s\n",
+                               block->idstr, psize,
                                (uint64_t)block->offset,
                                (uint64_t)block->used_length,
-                               (uint64_t)block->max_length);
+                               (uint64_t)block->max_length,
+                               (uint64_t)block->host,
+                               block->mr->readonly ? "ro" : "rw");
+
         g_free(psize);
     }
 
Signature · 1 line
2.34.1
Signature · 1 line
Peter Xu
author
#5 lore raw

Thanks, Peter.

hi Paolo,
A gentle ping:)
May I know what's your opinion to this patch? Any concern or further improvement required?

Thanks
Ted

Quoted 57 lines · Peter Xu

Since I applied this twice already to my local trees, let me ping for Ted to make sure it's not lost..

Quoted 49 lines · Ted Chen

It's convenient to dump HVA and RW/RO status of a ramblock in "info ramblock" for debug purpose.

Before:
Offset Used Total
0x0000000000000000 0x0000000400000000 0x0000000400000000

After:
Offset Used Total HVA RO
0x0000000000000000 0x0000000400000000 0x0000000400000000 0x00007f12ebe00000 rw

---
 softmmu/physmem.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
softmmu/physmem.c +10 -4
index 1b606a3002..fed4dfb72c 100644
@@ -1316,15 +1316,21 @@ GString *ram_block_format(void)
     GString *buf = g_string_new("");
 
     RCU_READ_LOCK_GUARD();
-    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s\n",
-                           "Block Name", "PSize", "Offset", "Used", "Total");
+    g_string_append_printf(buf, "%24s %8s  %18s %18s %18s %18s %3s\n",
+                           "Block Name", "PSize", "Offset", "Used", "Total",
+                           "HVA", "RO");
+
     RAMBLOCK_FOREACH(block) {
         psize = size_to_str(block->page_size);
         g_string_append_printf(buf, "%24s %8s  0x%016" PRIx64 " 0x%016" PRIx64
-                               " 0x%016" PRIx64 "\n", block->idstr, psize,
+                               " 0x%016" PRIx64 " 0x%016" PRIx64 " %3s\n",
+                               block->idstr, psize,
                                (uint64_t)block->offset,
                                (uint64_t)block->used_length,
-                               (uint64_t)block->max_length);
+                               (uint64_t)block->max_length,
+                               (uint64_t)block->host,
+                               block->mr->readonly ? "ro" : "rw");
+
         g_free(psize);
     }
 
Signature · 1 line
2.34.1
Signature · 1 line
Peter Xu
#6 lore raw
Quoted 5 lines · Ted Chen

Thanks, Peter.

hi Paolo,
A gentle ping:)
May I know what's your opinion to this patch? Any concern or further improvement required?

Merged as commit dbc6ae9c3b (fixing format string on 32-bit hosts).