Skip to contentSkip to conversation

xen: debugtrace cleanup and per-cpu buffer support

PATCH Superseded Juergen Gross 2 participants 24 messages Sep 5, 2019 – Sep 6, 2019

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover xen: debugtrace cleanup and per-cpu buffer support

Another debugtrace enhancement I needed for core scheduling debugging, plus some cleanup.

Changes in V5:
- several comments by Jan addressed (code: patches 1 and 4, commit message of patch 3)

Changes in V4:
- replaced patch 1 (original one was committed, new one requested by Jan Beulich)
- several comments by Jan addressed

Changes in V3:
- rebase to current staging

Changes in V2:
- added new patch 1 (preparing the move of debugtrace coding)
- patch 4 (v1 patch 3): avoid leaking buffer

Juergen Gross (4):
xen: fix debugtrace clearing
xen: move debugtrace coding to common/debugtrace.c
xen: refactor debugtrace data
xen: add per-cpu buffer option to debugtrace

 docs/misc/xen-command-line.pandoc |   7 +-
 xen/common/Makefile               |   1 +
 xen/common/debugtrace.c           | 276 ++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/console.c        | 178 +-----------------------
 4 files changed, 282 insertions(+), 180 deletions(-)
 create mode 100644 xen/common/debugtrace.c
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v5 1/4 xen: fix debugtrace clearing

After dumping the debugtrace buffer it is cleared. This results in some entries not being printed in case the buffer is dumped again before having wrapped.

While at it remove the trailing zero byte in the buffer as it is no longer needed. Commit b5e6e1ee8da59f introduced passing the number of chars to be printed in the related interfaces, so the trailing 0 byte is no longer required.

---
V5:
- invalidate last_buf instead of last_prd after printing the buffer (Jan Beulich)

---
 xen/drivers/char/console.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
xen/drivers/char/console.c +10 -9
index f49c6f29a8..8df627c84a 100644
@@ -1166,6 +1166,8 @@ int printk_ratelimit(void)
 
 #ifdef CONFIG_DEBUG_TRACE
 
+#define DEBUG_TRACE_ENTRY_SIZE   1024
+
 /* Send output direct to console, or buffer it? */
 static volatile int debugtrace_send_to_console;
 
@@ -1173,6 +1175,7 @@ static char        *debugtrace_buf; /* Debug-trace buffer */
 static unsigned int debugtrace_prd; /* Producer index     */
 static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
 static unsigned int debugtrace_used;
+static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];
 static DEFINE_SPINLOCK(debugtrace_lock);
 integer_param("debugtrace", debugtrace_kilobytes);
 
@@ -1184,16 +1187,17 @@ static void debugtrace_dump_worker(void)
     printk("debugtrace_dump() starting\n");
 
     /* Print oldest portion of the ring. */
-    ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
     if ( debugtrace_buf[debugtrace_prd] != '\0' )
         console_serial_puts(&debugtrace_buf[debugtrace_prd],
-                            debugtrace_bytes - debugtrace_prd - 1);
+                            debugtrace_bytes - debugtrace_prd);
 
     /* Print youngest portion of the ring. */
     debugtrace_buf[debugtrace_prd] = '\0';
     console_serial_puts(&debugtrace_buf[0], debugtrace_prd);
 
     memset(debugtrace_buf, '\0', debugtrace_bytes);
+    debugtrace_prd = 0;
+    debugtrace_last_entry_buf[0] = 0;
 
     printk("debugtrace_dump() finished\n");
 }
@@ -1241,15 +1245,14 @@ static void debugtrace_add_to_buf(char *buf)
     for ( p = buf; *p != '\0'; p++ )
     {
         debugtrace_buf[debugtrace_prd++] = *p;
-        /* Always leave a nul byte at the end of the buffer. */
-        if ( debugtrace_prd == (debugtrace_bytes - 1) )
+        if ( debugtrace_prd == debugtrace_bytes )
             debugtrace_prd = 0;
     }
 }
 
 void debugtrace_printk(const char *fmt, ...)
 {
-    static char buf[1024], last_buf[1024];
+    static char buf[DEBUG_TRACE_ENTRY_SIZE];
     static unsigned int count, last_count, last_prd;
 
     char          cntbuf[24];
@@ -1264,8 +1267,6 @@ void debugtrace_printk(const char *fmt, ...)
 
     spin_lock_irqsave(&debugtrace_lock, flags);
 
-    ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-
     va_start(args, fmt);
     nr = vscnprintf(buf, sizeof(buf), fmt, args);
     va_end(args);
@@ -1279,11 +1280,11 @@ void debugtrace_printk(const char *fmt, ...)
     }
     else
     {
-        if ( strcmp(buf, last_buf) )
+        if ( strcmp(buf, debugtrace_last_entry_buf) )
         {
             last_prd = debugtrace_prd;
             last_count = ++count;
-            safe_strcpy(last_buf, buf);
+            safe_strcpy(debugtrace_last_entry_buf, buf);
             snprintf(cntbuf, sizeof(cntbuf), "%u ", count);
         }
         else
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v5 1/4
#2 lore raw

Re: [Xen-devel] [PATCH v5 1/4] xen: fix debugtrace clearing

Quoted 10 lines · Juergen Gross

After dumping the debugtrace buffer it is cleared. This results in some entries not being printed in case the buffer is dumped again before having wrapped.

While at it remove the trailing zero byte in the buffer as it is no longer needed. Commit b5e6e1ee8da59f introduced passing the number of chars to be printed in the related interfaces, so the trailing 0 byte is no longer required.

Technically this is fine, so it can have my

However, ...

xen/drivers/char/console.c static char *debugtrace_buf; /* Debug-trace buffer */ · line 1178

Quoted 5 lines
xen/drivers/char/console.c +1 -0
@@ -1173,6 +1175,7 @@ static char        *debugtrace_buf; /* Debug-trace buffer */
 static unsigned int debugtrace_prd; /* Producer index     */
 static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
 static unsigned int debugtrace_used;
+static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];

... this is what I was afraid would happen, but I admit I didn't reply in a way previously indicating that I dislike such a solution. This is also why, when noticing the issue, I didn't put together a patch myself right away. In particular I'm of the opinion that the three last_* values would better all stay together, and then would better stay inside the only function using them.

xen/drivers/char/console.c void debugtrace_printk(const char *fmt, ...) · line 1283

Quoted 6 lines
xen/drivers/char/console.c +1 -1
@@ -1279,11 +1280,11 @@ void debugtrace_printk(const char *fmt, ...)
     }
     else
     {
-        if ( strcmp(buf, last_buf) )
+        if ( strcmp(buf, debugtrace_last_entry_buf) )

Wouldn't moving count to file scope and latching its value into a new dump_count when dumping work:

        if ( count == dump_count || strcmp(buf, last_buf) )

work?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

Re: [Xen-devel] [PATCH v5 1/4] xen: fix debugtrace clearing

Quoted 40 lines · Jan Beulich
Quoted 10 lines · Juergen Gross

After dumping the debugtrace buffer it is cleared. This results in some entries not being printed in case the buffer is dumped again before having wrapped.

While at it remove the trailing zero byte in the buffer as it is no longer needed. Commit b5e6e1ee8da59f introduced passing the number of chars to be printed in the related interfaces, so the trailing 0 byte is no longer required.

Technically this is fine, so it can have my

However, ...

xen/drivers/char/console.c static char *debugtrace_buf; /* Debug-trace buffer */ · line 1178

Quoted 5 lines
xen/drivers/char/console.c +1 -0
@@ -1173,6 +1175,7 @@ static char        *debugtrace_buf; /* Debug-trace buffer */
  static unsigned int debugtrace_prd; /* Producer index     */
  static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
  static unsigned int debugtrace_used;
+static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];

... this is what I was afraid would happen, but I admit I didn't reply in a way previously indicating that I dislike such a solution. This is also why, when noticing the issue, I didn't put together a patch myself right away. In particular I'm of the opinion that the three last_* values would better all stay together, and then would better stay inside the only function using them.

xen/drivers/char/console.c void debugtrace_printk(const char *fmt, ...) · line 1283

Quoted 6 lines
xen/drivers/char/console.c +1 -1
@@ -1279,11 +1280,11 @@ void debugtrace_printk(const char *fmt, ...)
      }
      else
      {
-        if ( strcmp(buf, last_buf) )
+        if ( strcmp(buf, debugtrace_last_entry_buf) )

Wouldn't moving count to file scope and latching its value into a new dump_count when dumping work:

Quoted 3 lines
         if ( count == dump_count || strcmp(buf, last_buf) )

work?

I'd rather have a bool which will be reset in above condition. This will avoid problems when count is wrapping.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH v5 2/4 xen: move debugtrace coding to common/debugtrace.c

In reply to Juergen Gross

Instead of living in drivers/char/console.c move the debugtrace related coding to a new file common/debugtrace.c

No functional change, code movement only.

---
 xen/common/Makefile        |   1 +
 xen/common/debugtrace.c    | 181 +++++++++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/console.c | 179 +-------------------------------------------
 3 files changed, 183 insertions(+), 178 deletions(-)
 create mode 100644 xen/common/debugtrace.c
xen/common/Makefile +1 -0
index eddda5daa6..62b34e69e9 100644
@@ -4,6 +4,7 @@ obj-y += bsearch.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
 obj-y += cpupool.o
+obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o
 obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o
 obj-y += domctl.o
 obj-y += domain.o
xen/common/debugtrace.c new file +181 -0

181 lines not on this page · raw message

xen/drivers/char/console.c +1 -178

185 lines not on this page · raw message

Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

Re: [Xen-devel] [PATCH v5 2/4] xen: move debugtrace coding to common/debugtrace.c

Quoted 23 lines · Juergen Gross
xen/common/debugtrace.c new file +20 -0
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * debugtrace.c
+ *
+ * Debugtrace for Xen
+ */
+
+
+#include <xen/console.h>
+#include <xen/init.h>
+#include <xen/keyhandler.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/serial.h>
+#include <xen/spinlock.h>
+#include <xen/watchdog.h>
+
+#define DEBUG_TRACE_ENTRY_SIZE   1024
+
+/* Send output direct to console, or buffer it? */
+static volatile int debugtrace_send_to_console;

xen/common/debugtrace.c line 30

Quoted 10 lines
xen/common/debugtrace.c new file +10 -0
+
+static char        *debugtrace_buf; /* Debug-trace buffer */
+static unsigned int debugtrace_prd; /* Producer index     */
+static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
+static unsigned int debugtrace_used;
+static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];
+static DEFINE_SPINLOCK(debugtrace_lock);
+integer_param("debugtrace", debugtrace_kilobytes);
+
+static void debugtrace_dump_worker(void)

And another remark here too, despite my prior ack: By moving this into its own file, the debugtrace_ prefixes of static symbols now all become redundant, at least as far as their occurrence in e.g. call stacks goes (where they'd be prefixes by the disambiguating source file name). But I know we've got ample other examples where this is also the case, and I also know there are contrary opinions on the matter, so this is not strictly a request for further change.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Re: [Xen-devel] [PATCH v5 2/4] xen: move debugtrace coding to common/debugtrace.c

Quoted 35 lines · Jan Beulich
Quoted 23 lines · Juergen Gross
xen/common/debugtrace.c new file +20 -0
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * debugtrace.c
+ *
+ * Debugtrace for Xen
+ */
+
+
+#include <xen/console.h>
+#include <xen/init.h>
+#include <xen/keyhandler.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/serial.h>
+#include <xen/spinlock.h>
+#include <xen/watchdog.h>
+
+#define DEBUG_TRACE_ENTRY_SIZE   1024
+
+/* Send output direct to console, or buffer it? */
+static volatile int debugtrace_send_to_console;

xen/common/debugtrace.c line 30

Quoted 10 lines
xen/common/debugtrace.c new file +10 -0
+
+static char        *debugtrace_buf; /* Debug-trace buffer */
+static unsigned int debugtrace_prd; /* Producer index     */
+static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
+static unsigned int debugtrace_used;
+static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];
+static DEFINE_SPINLOCK(debugtrace_lock);
+integer_param("debugtrace", debugtrace_kilobytes);
+
+static void debugtrace_dump_worker(void)
Quoted 7 lines

And another remark here too, despite my prior ack: By moving this into its own file, the debugtrace_ prefixes of static symbols now all become redundant, at least as far as their occurrence in e.g. call stacks goes (where they'd be prefixes by the disambiguating source file name). But I know we've got ample other examples where this is also the case, and I also know there are contrary opinions on the matter, so this is not strictly a request for further change.

I'm one of the "contrary opinion" guys. :-)

So I'd rather keep the prefix.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

PATCH v5 3/4 xen: refactor debugtrace data

In reply to Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

While at it switch debugtrace_send_to_console and debugtrace_used to bool and delete an empty line.

---
V4:
- renamed struct debugtrace_data_s (Jan Beulich)
- renamed debtr_data (Jan Beulich)
- remove unneeded condition (Jan Beulich)
- recalc debugtrace_bytes (Jan Beulich)

---
 xen/common/debugtrace.c | 64 ++++++++++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 27 deletions(-)
xen/common/debugtrace.c +37 -27
index c1ee3f45b9..0eeb1a77c5 100644
@@ -17,34 +17,40 @@
 #define DEBUG_TRACE_ENTRY_SIZE   1024
 
 /* Send output direct to console, or buffer it? */
-static volatile int debugtrace_send_to_console;
+static volatile bool debugtrace_send_to_console;
 
-static char        *debugtrace_buf; /* Debug-trace buffer */
-static unsigned int debugtrace_prd; /* Producer index     */
-static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
-static unsigned int debugtrace_used;
+struct debugtrace_data {
+    unsigned long bytes; /* Size of buffer. */
+    unsigned long prd;   /* Producer index. */
+    char          buf[];
+};
+
+static struct debugtrace_data *dt_data;
+
+static unsigned int debugtrace_kilobytes = 128;
+static bool debugtrace_used;
 static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE];
 static DEFINE_SPINLOCK(debugtrace_lock);
 integer_param("debugtrace", debugtrace_kilobytes);
 
 static void debugtrace_dump_worker(void)
 {
-    if ( (debugtrace_bytes == 0) || !debugtrace_used )
+    if ( !debugtrace_used )
         return;
 
     printk("debugtrace_dump() starting\n");
 
     /* Print oldest portion of the ring. */
-    if ( debugtrace_buf[debugtrace_prd] != '\0' )
-        console_serial_puts(&debugtrace_buf[debugtrace_prd],
-                            debugtrace_bytes - debugtrace_prd);
+    if ( dt_data->buf[dt_data->prd] != '\0' )
+        console_serial_puts(&dt_data->buf[dt_data->prd],
+                            dt_data->bytes - dt_data->prd);
 
     /* Print youngest portion of the ring. */
-    debugtrace_buf[debugtrace_prd] = '\0';
-    console_serial_puts(&debugtrace_buf[0], debugtrace_prd);
+    dt_data->buf[dt_data->prd] = '\0';
+    console_serial_puts(&dt_data->buf[0], dt_data->prd);
 
-    memset(debugtrace_buf, '\0', debugtrace_bytes);
-    debugtrace_prd = 0;
+    memset(dt_data->buf, '\0', dt_data->bytes);
+    dt_data->prd = 0;
     debugtrace_last_entry_buf[0] = 0;
 
     printk("debugtrace_dump() finished\n");
@@ -70,7 +76,6 @@ static void debugtrace_toggle(void)
 
     spin_unlock_irqrestore(&debugtrace_lock, flags);
     watchdog_enable();
-
 }
 
 void debugtrace_dump(void)
@@ -92,26 +97,27 @@ static void debugtrace_add_to_buf(char *buf)
 
     for ( p = buf; *p != '\0'; p++ )
     {
-        debugtrace_buf[debugtrace_prd++] = *p;
-        if ( debugtrace_prd == debugtrace_bytes )
-            debugtrace_prd = 0;
+        dt_data->buf[dt_data->prd++] = *p;
+        if ( dt_data->prd == dt_data->bytes )
+            dt_data->prd = 0;
     }
 }
 
 void debugtrace_printk(const char *fmt, ...)
 {
     static char buf[DEBUG_TRACE_ENTRY_SIZE];
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;
+    static unsigned long last_prd;
 
     char          cntbuf[24];
     va_list       args;
     unsigned long flags;
     unsigned int nr;
 
-    if ( debugtrace_bytes == 0 )
+    if ( !dt_data )
         return;
 
-    debugtrace_used = 1;
+    debugtrace_used = true;
 
     spin_lock_irqsave(&debugtrace_lock, flags);
 
@@ -130,14 +136,14 @@ void debugtrace_printk(const char *fmt, ...)
     {
         if ( strcmp(buf, debugtrace_last_entry_buf) )
         {
-            last_prd = debugtrace_prd;
+            last_prd = dt_data->prd;
             last_count = ++count;
             safe_strcpy(debugtrace_last_entry_buf, buf);
             snprintf(cntbuf, sizeof(cntbuf), "%u ", count);
         }
         else
         {
-            debugtrace_prd = last_prd;
+            dt_data->prd = last_prd;
             snprintf(cntbuf, sizeof(cntbuf), "%u-%u ", last_count, ++count);
         }
         debugtrace_add_to_buf(cntbuf);
@@ -155,7 +161,8 @@ static void debugtrace_key(unsigned char key)
 static int __init debugtrace_init(void)
 {
     int order;
-    unsigned int kbytes, bytes;
+    unsigned long kbytes, bytes;
+    struct debugtrace_data *data;
 
     /* Round size down to next power of two. */
     while ( (kbytes = (debugtrace_kilobytes & (debugtrace_kilobytes-1))) != 0 )
@@ -166,12 +173,15 @@ static int __init debugtrace_init(void)
         return 0;
 
     order = get_order_from_bytes(bytes);
-    debugtrace_buf = alloc_xenheap_pages(order, 0);
-    ASSERT(debugtrace_buf != NULL);
+    data = alloc_xenheap_pages(order, 0);
+    if ( !data )
+        return -ENOMEM;
 
-    memset(debugtrace_buf, '\0', bytes);
+    bytes = PAGE_SIZE << order;
+    memset(data, '\0', bytes);
 
-    debugtrace_bytes = bytes;
+    data->bytes = bytes - sizeof(*data);
+    dt_data = data;
 
     register_keyhandler('T', debugtrace_key,
                         "toggle debugtrace to console/buffer", 0);
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#8 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines

void debugtrace_printk(const char *fmt, ...)

 {
     static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 10 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 8 lines

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines
  void debugtrace_printk(const char *fmt, ...)
  {
      static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 20 lines · Juergen Gross
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 8 lines

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines
  void debugtrace_printk(const char *fmt, ...)
  {
      static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 21 lines · Jan Beulich
Quoted 20 lines · Juergen Gross
Quoted 18 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines
   void debugtrace_printk(const char *fmt, ...)
   {
       static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 8 lines
Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#12 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 29 lines · Juergen Gross
Quoted 28 lines · Jan Beulich
Quoted 26 lines · Juergen Gross
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 8 lines

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines
   void debugtrace_printk(const char *fmt, ...)
   {
       static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Quoted 6 lines
Quoted 1 line

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#13 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 30 lines · Jan Beulich
Quoted 29 lines · Juergen Gross
Quoted 28 lines · Jan Beulich
Quoted 26 lines · Juergen Gross
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 8 lines

xen/common/debugtrace.c static void debugtrace_add_to_buf(char *buf) · line 109

Quoted 5 lines
    void debugtrace_printk(const char *fmt, ...)
    {
        static char buf[DEBUG_TRACE_ENTRY_SIZE];
xen/common/debugtrace.c +1 -1
-    static unsigned int count, last_count, last_prd;
+    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#14 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 38 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Juergen Gross
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Juergen Gross
Quoted 18 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 5 lines

    void debugtrace_printk(const char *fmt, ...) {
        static char buf[DEBUG_TRACE_ENTRY_SIZE]; -    static unsigned int count, last_count, last_prd; +    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 8 lines
Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Quoted 7 lines
Quoted 1 line

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Another option would be to let count wrap at e.g. 4 billion (or even 1 million) and add a wrap count. Each buffer struct would contain the wrap count of the last entry, and when hitting a higher wrap count a new entry like ("wrap %u->%u", old_wrap, new_wrap) would be printed. This saves buffer space without loosing information.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#15 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 47 lines · Juergen Gross
Quoted 38 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Juergen Gross
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Juergen Gross
Quoted 18 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 5 lines

    void debugtrace_printk(const char *fmt, ...) {
        static char buf[DEBUG_TRACE_ENTRY_SIZE]; -    static unsigned int count, last_count, last_prd; +    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 8 lines
Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Quoted 7 lines
Quoted 1 line

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Quoted 5 lines

Another option would be to let count wrap at e.g. 4 billion (or even 1 million) and add a wrap count. Each buffer struct would contain the wrap count of the last entry, and when hitting a higher wrap count a new entry like ("wrap %u->%u", old_wrap, new_wrap) would be printed. This saves buffer space without loosing information.

This sounds quite neat.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#16 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 48 lines · Jan Beulich
Quoted 47 lines · Juergen Gross
Quoted 45 lines · Juergen Gross
Quoted 30 lines · Jan Beulich
Quoted 29 lines · Juergen Gross
Quoted 28 lines · Jan Beulich
Quoted 26 lines · Juergen Gross
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 8 lines
Quoted 5 lines

    void debugtrace_printk(const char *fmt, ...) {
        static char buf[DEBUG_TRACE_ENTRY_SIZE];
-    static unsigned int count, last_count, last_prd; +    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Quoted 7 lines
Quoted 5 lines

Another option would be to let count wrap at e.g. 4 billion (or even 1 million) and add a wrap count. Each buffer struct would contain the wrap count of the last entry, and when hitting a higher wrap count a new entry like ("wrap %u->%u", old_wrap, new_wrap) would be printed. This saves buffer space without loosing information.

This sounds quite neat.

I'm adding a new patch for that purpose, as it is adding a new feature.

Any preferences for the max value of count? I'm in favor of limiting it to 6-digit numbers as those are much easier to compare by just looking at them.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#17 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 55 lines · Juergen Gross
Quoted 54 lines · Jan Beulich
Quoted 52 lines · Juergen Gross
Quoted 38 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Juergen Gross
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Juergen Gross
Quoted 18 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 5 lines

    void debugtrace_printk(const char *fmt, ...) {
        static char buf[DEBUG_TRACE_ENTRY_SIZE];
-    static unsigned int count, last_count, last_prd; +    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 8 lines
Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Quoted 7 lines
Quoted 1 line

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Another option would be to let count wrap at e.g. 4 billion (or even 1 million) and add a wrap count. Each buffer struct would contain the wrap count of the last entry, and when hitting a higher wrap count a new entry like ("wrap %u->%u", old_wrap, new_wrap) would be printed. This saves buffer space without loosing information.

Quoted 7 lines
Quoted 1 line

This sounds quite neat.

I'm adding a new patch for that purpose, as it is adding a new feature.

Any preferences for the max value of count? I'm in favor of limiting it to 6-digit numbers as those are much easier to compare by just looking at them.

I'm not overly fussed; personally I'd probably wrap at 30 bits, making it generally up to 8 digits, just very slightly going into the 9-digit range.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#18 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 58 lines · Jan Beulich
Quoted 57 lines · Juergen Gross
Quoted 55 lines · Jan Beulich
Quoted 47 lines · Juergen Gross
Quoted 38 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Juergen Gross
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Juergen Gross
Quoted 18 lines · Jan Beulich
Quoted 6 lines · Juergen Gross

As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. In order not to limit buffer size switch the related fields from unsigned int to unsigned long, as on huge machines with RAM in the TB range it might be interesting to support buffers >4GB.

Just as a further remark in this regard:

Quoted 5 lines

    void debugtrace_printk(const char *fmt, ...) {
        static char buf[DEBUG_TRACE_ENTRY_SIZE];
-    static unsigned int count, last_count, last_prd; +    static unsigned int count, last_count;

How long do we think will it take until their wrapping will become an issue with such huge buffers?

Quoted 8 lines
Quoted 6 lines

Count wrapping will not result in any misbehavior of tracing. With per-cpu buffers it might result in ambiguity regarding sorting the entries, but I guess chances are rather low this being a real issue.

BTW: wrapping of count is not related to buffer size, but to the amount of trace data written.

Sure, but the chance of ambiguity increases with larger buffer sizes.

Well, better safe than sorry. Switching to unsigned long will rarely hurt, so I'm going to do just that. The only downside will be some waste of buffer space for very long running traces with huge amounts of entries.

Quoted 7 lines
Quoted 1 line

Hmm, true. Maybe we could get someone else's opinion on this - anyone?

TBH, I wouldn't be concerned about the buffer space. In case there are really billions of entries, the difference between a 10-digit count value and maybe a 15 digit one (and that is already a massive amount) isn't that large. The average printed size of count with about 4 billion entries is 9.75 digits (and not just 5 :-) ).

Quoted 5 lines

Another option would be to let count wrap at e.g. 4 billion (or even 1 million) and add a wrap count. Each buffer struct would contain the wrap count of the last entry, and when hitting a higher wrap count a new entry like ("wrap %u->%u", old_wrap, new_wrap) would be printed. This saves buffer space without loosing information.

This sounds quite neat.

Quoted 8 lines
Quoted 5 lines

I'm adding a new patch for that purpose, as it is adding a new feature.

Any preferences for the max value of count? I'm in favor of limiting it to 6-digit numbers as those are much easier to compare by just looking at them.

I'm not overly fussed; personally I'd probably wrap at 30 bits, making it generally up to 8 digits, just very slightly going into the 9-digit range.

2^30 is a 10-digit number. :-)

But wrapping at 100.000.000 is fine, too, as it is just

if ( count == 100000000 )

and that is not required to be a nice binary number.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#19 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

In reply to Juergen Gross
Quoted 5 lines · Juergen Gross
xen/common/debugtrace.c +0 -0
@@ -17,34 +17,40 @@
 #define DEBUG_TRACE_ENTRY_SIZE   1024
 

xen/common/debugtrace.c line 23

Quoted 10 lines
xen/common/debugtrace.c +3 -5
 /* Send output direct to console, or buffer it? */
-static volatile int debugtrace_send_to_console;
+static volatile bool debugtrace_send_to_console;
 
-static char        *debugtrace_buf; /* Debug-trace buffer */
-static unsigned int debugtrace_prd; /* Producer index     */
-static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
-static unsigned int debugtrace_used;
+struct debugtrace_data {
+    unsigned long bytes; /* Size of buffer. */

Hmm, I'm sorry for recognizing this only now, but why does this field need replicating? It's the same in all instances of the structure afaict.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#20 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 10 lines · Jan Beulich
Quoted 9 lines · Juergen Gross
xen/common/debugtrace.c +1 -1
@@ -17,34 +17,40 @@
  #define DEBUG_TRACE_ENTRY_SIZE   1024
 
  /* Send output direct to console, or buffer it? */
-static volatile int debugtrace_send_to_console;
+static volatile bool debugtrace_send_to_console;
 
Quoted 10 lines

xen/common/debugtrace.c line 23

Quoted 6 lines
xen/common/debugtrace.c +2 -4
-static char        *debugtrace_buf; /* Debug-trace buffer */
-static unsigned int debugtrace_prd; /* Producer index     */
-static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
-static unsigned int debugtrace_used;
+struct debugtrace_data {
+    unsigned long bytes; /* Size of buffer. */

Hmm, I'm sorry for recognizing this only now, but why does this field need replicating? It's the same in all instances of the structure afaict.

Oh, right. In the beginning I had plans to support modifying the buffer size at runtime.

Okay, I'll change it.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#21 lore raw

Re: [Xen-devel] [PATCH v5 3/4] xen: refactor debugtrace data

Quoted 22 lines · Juergen Gross
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Juergen Gross
xen/common/debugtrace.c +1 -1
@@ -17,34 +17,40 @@
  #define DEBUG_TRACE_ENTRY_SIZE   1024
 
  /* Send output direct to console, or buffer it? */
-static volatile int debugtrace_send_to_console;
+static volatile bool debugtrace_send_to_console;
 
Quoted 10 lines

xen/common/debugtrace.c line 23

Quoted 6 lines
xen/common/debugtrace.c +2 -4
-static char        *debugtrace_buf; /* Debug-trace buffer */
-static unsigned int debugtrace_prd; /* Producer index     */
-static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes;
-static unsigned int debugtrace_used;
+struct debugtrace_data {
+    unsigned long bytes; /* Size of buffer. */

Hmm, I'm sorry for recognizing this only now, but why does this field need replicating? It's the same in all instances of the structure afaict.

Quoted 4 lines

Oh, right. In the beginning I had plans to support modifying the buffer size at runtime.

Okay, I'll change it.

Thanks. FAOD this is not going to invalidate any of my acks.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#22 lore raw

PATCH v5 4/4 xen: add per-cpu buffer option to debugtrace

In reply to Juergen Gross

debugtrace is normally writing trace entries into a single trace buffer. There are cases where this is not optimal, e.g. when hunting a bug which requires writing lots of trace entries and one cpu is stuck. This will result in other cpus filling the trace buffer and finally overwriting the interesting trace entries of the hanging cpu.

In order to be able to debug such situations add the capability to use per-cpu trace buffers. This can be selected by specifying the debugtrace boot parameter with the modifier "cpu:", like:

debugtrace=cpu:16

At the same time switch the parsing function to accept size modifiers (e.g. 4M or 1G).

Printing out the trace entries is done for each buffer in order to minimize the effort needed during printing. As each entry is prefixed with its sequence number sorting the entries can easily be done when analyzing them.

---
V2:
- only allocate buffer if not already done so
V4:
- unsigned int -> unsigned long (Jan Beulich)
- replace check for bytes < PAGE_SIZE by !bytes (Jan Beulich)
- print info which buffer allocation failed (Jan Beulich)
- replace switch by if in cpu notifier handler (Jan Beulich) V5:
- don't silently ignore trailing characters when parsing buffer size (Jan Beulich)
- limit scope of some variables (Jan Beulich)
- adjust error message format (Jan Beulich)

---
 docs/misc/xen-command-line.pandoc |   7 +-
 xen/common/debugtrace.c           | 159 +++++++++++++++++++++++++++++---------
 2 files changed, 126 insertions(+), 40 deletions(-)
docs/misc/xen-command-line.pandoc +4 -3
index 7c72e31032..832797e2e2 100644
@@ -644,12 +644,13 @@ over the PCI busses sequentially) or by PCI device (must be on segment 0).
 Limits the number lines printed in Xen stack traces.
 
 ### debugtrace
-> `= <integer>`
+> `= [cpu:]<size>`
 
 > Default: `128`
 
-Specify the size of the console debug trace buffer in KiB. The debug
-trace feature is only enabled in debugging builds of Xen.
+Specify the size of the console debug trace buffer. By specifying `cpu:`
+additionally a trace buffer of the specified size is allocated per cpu.
+The debug trace feature is only enabled in debugging builds of Xen.
 
 ### dma_bits
 > `= <integer>`
xen/common/debugtrace.c +122 -37

240 lines not on this page · raw message

Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v5 4/4
#23 lore raw

Re: [Xen-devel] [PATCH v5 4/4] xen: add per-cpu buffer option to debugtrace

Quoted 15 lines · Juergen Gross

debugtrace is normally writing trace entries into a single trace buffer. There are cases where this is not optimal, e.g. when hunting a bug which requires writing lots of trace entries and one cpu is stuck. This will result in other cpus filling the trace buffer and finally overwriting the interesting trace entries of the hanging cpu.

In order to be able to debug such situations add the capability to use per-cpu trace buffers. This can be selected by specifying the debugtrace boot parameter with the modifier "cpu:", like:

debugtrace=cpu:16

At the same time switch the parsing function to accept size modifiers (e.g. 4M or 1G).

Quoted 6 lines

Printing out the trace entries is done for each buffer in order to minimize the effort needed during printing. As each entry is prefixed with its sequence number sorting the entries can easily be done when analyzing them.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel