[v2,4/6] linux-user: log page table changes under -d page

Message ID 20191205122518.10010-5-alex.bennee@linaro.org
State Superseded
Headers show
Series
  • linux-user mmap debug cleanup
Related show

Commit Message

Alex Bennée Dec. 5, 2019, 12:25 p.m.
The CPU_LOG_PAGE flag is woefully underused and could stand to do
extra duty tracking page changes. If the user doesn't want to see the
details as things change they still have the tracepoints available.

We push the locking into log_page_dump and pass a reason for the
banner text.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>


---
  v2
    - reworded banner text
    - moved locking into helper
    - converted stray calls of page_dump
---
 include/exec/log.h | 5 ++++-
 bsd-user/main.c    | 2 +-
 linux-user/main.c  | 2 +-
 linux-user/mmap.c  | 8 ++++----
 4 files changed, 10 insertions(+), 7 deletions(-)

-- 
2.20.1

Comments

Richard Henderson Dec. 5, 2019, 3:45 p.m. | #1
On 12/5/19 4:25 AM, Alex Bennée wrote:
> The CPU_LOG_PAGE flag is woefully underused and could stand to do

> extra duty tracking page changes. If the user doesn't want to see the

> details as things change they still have the tracepoints available.

> 

> We push the locking into log_page_dump and pass a reason for the

> banner text.

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> 

> ---

>   v2

>     - reworded banner text

>     - moved locking into helper

>     - converted stray calls of page_dump

> ---

>  include/exec/log.h | 5 ++++-

>  bsd-user/main.c    | 2 +-

>  linux-user/main.c  | 2 +-

>  linux-user/mmap.c  | 8 ++++----

>  4 files changed, 10 insertions(+), 7 deletions(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
Laurent Vivier Dec. 11, 2019, 2:53 p.m. | #2
Le 05/12/2019 à 13:25, Alex Bennée a écrit :
> The CPU_LOG_PAGE flag is woefully underused and could stand to do

> extra duty tracking page changes. If the user doesn't want to see the

> details as things change they still have the tracepoints available.

> 

> We push the locking into log_page_dump and pass a reason for the

> banner text.

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> 

> ---

>   v2

>     - reworded banner text

>     - moved locking into helper

>     - converted stray calls of page_dump

> ---

>  include/exec/log.h | 5 ++++-

>  bsd-user/main.c    | 2 +-

>  linux-user/main.c  | 2 +-

>  linux-user/mmap.c  | 8 ++++----

>  4 files changed, 10 insertions(+), 7 deletions(-)


Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Patch

diff --git a/include/exec/log.h b/include/exec/log.h
index e2cfd436e61..012af09f9b3 100644
--- a/include/exec/log.h
+++ b/include/exec/log.h
@@ -50,9 +50,12 @@  static inline void log_disas(void *code, unsigned long size)
 
 #if defined(CONFIG_USER_ONLY)
 /* page_dump() output to the log file: */
-static inline void log_page_dump(void)
+static inline void log_page_dump(const char *operation)
 {
+    qemu_log_lock();
+    qemu_log("page layout changed following %s\n", operation);
     page_dump(qemu_logfile);
+    qemu_log_unlock();
 }
 #endif
 #endif
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 470a8bf79ed..7f4e3cd6271 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -963,7 +963,7 @@  int main(int argc, char **argv)
 
     if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
         qemu_log("guest_base  0x%lx\n", guest_base);
-        log_page_dump();
+        log_page_dump("binary load");
 
         qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
         qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
diff --git a/linux-user/main.c b/linux-user/main.c
index 6ff7851e86f..8718d03ee21 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -826,7 +826,7 @@  int main(int argc, char **argv, char **envp)
 
     if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
         qemu_log("guest_base  0x%lx\n", guest_base);
-        log_page_dump();
+        log_page_dump("binary load");
 
         qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
         qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 0b1b43ac3c0..3d90fa459ca 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -18,6 +18,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "trace.h"
+#include "exec/log.h"
 #include "qemu.h"
 
 //#define DEBUG_MMAP
@@ -539,10 +540,9 @@  abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     page_set_flags(start, start + len, prot | PAGE_VALID);
  the_end:
     trace_target_mmap_complete(start);
-#ifdef DEBUG_MMAP
-    page_dump(stdout);
-    printf("\n");
-#endif
+    if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
+        log_page_dump(__func__);
+    }
     tb_invalidate_phys_range(start, start + len);
     mmap_unlock();
     return start;