[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] xen: refactor debugtrace data
commit af5793cac20cff6f60fb2f8ed19c5af1201943be Author: Juergen Gross <jgross@xxxxxxxx> AuthorDate: Mon Sep 9 14:37:25 2019 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Sep 9 14:37:25 2019 +0200 xen: refactor debugtrace data 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. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/common/debugtrace.c | 70 ++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/xen/common/debugtrace.c b/xen/common/debugtrace.c index 93cdddb61c..a66aa39103 100644 --- a/xen/common/debugtrace.c +++ b/xen/common/debugtrace.c @@ -15,34 +15,40 @@ #include <xen/watchdog.h> /* 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 prd; /* Producer index. */ + char buf[]; +}; + +static struct debugtrace_data *dt_data; + +static unsigned int debugtrace_kilobytes = 128; +static unsigned long debugtrace_bytes; static bool debugtrace_buf_empty = true; +static bool debugtrace_used; 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], + debugtrace_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', debugtrace_bytes); + dt_data->prd = 0; debugtrace_buf_empty = true; printk("debugtrace_dump() finished\n"); @@ -68,7 +74,6 @@ static void debugtrace_toggle(void) spin_unlock_irqrestore(&debugtrace_lock, flags); watchdog_enable(); - } void debugtrace_dump(void) @@ -90,26 +95,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 == debugtrace_bytes ) + dt_data->prd = 0; } } void debugtrace_printk(const char *fmt, ...) { static char buf[1024], last_buf[1024]; - 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); @@ -129,14 +135,14 @@ void debugtrace_printk(const char *fmt, ...) if ( debugtrace_buf_empty || strcmp(buf, last_buf) ) { debugtrace_buf_empty = false; - last_prd = debugtrace_prd; + last_prd = dt_data->prd; last_count = ++count; safe_strcpy(last_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); @@ -154,23 +160,27 @@ static void debugtrace_key(unsigned char key) static int __init debugtrace_init(void) { int order; - unsigned int kbytes, bytes; + unsigned long kbytes; + struct debugtrace_data *data; /* Round size down to next power of two. */ while ( (kbytes = (debugtrace_kilobytes & (debugtrace_kilobytes-1))) != 0 ) debugtrace_kilobytes = kbytes; - bytes = debugtrace_kilobytes << 10; - if ( bytes == 0 ) + debugtrace_bytes = debugtrace_kilobytes << 10; + if ( debugtrace_bytes == 0 ) return 0; - order = get_order_from_bytes(bytes); - debugtrace_buf = alloc_xenheap_pages(order, 0); - ASSERT(debugtrace_buf != NULL); + order = get_order_from_bytes(debugtrace_bytes); + data = alloc_xenheap_pages(order, 0); + if ( !data ) + return -ENOMEM; - memset(debugtrace_buf, '\0', bytes); + debugtrace_bytes = PAGE_SIZE << order; + memset(data, '\0', debugtrace_bytes); + debugtrace_bytes -= sizeof(*data); - debugtrace_bytes = bytes; + dt_data = data; register_keyhandler('T', debugtrace_key, "toggle debugtrace to console/buffer", 0); -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |