x86/pagewalk: Improve print_gw()
PATCH 1/2 x86/pagewalk: Improve print_gw()
print_gw() has no callers, meaning that it only gets used as part of manual debugging. As such, the FILE/LINE references are of no practical use, and voluminous in the log. Additionally, the function becoming empty in a non-debug build is unhelpful. Switch from gdprintk() to gprintk().
Print the entry and mfn for a specific level on the same line. This halves the number of lines printed overall. There needs to be a small adjustment to the #ifdef'ary to maintain the proper l3e behaviour for 3-level paging, where there is no l3mfn to print.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
--- xen/include/asm-x86/guest_pt.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
xen/include/asm-x86/guest_pt.h +12 -10
@@ -310,21 +310,23 @@ guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m, unsigned long va, walk_t *gw, uint32_t pfec, mfn_t top_mfn, void *top_map);/* Pretty-print the contents of a guest-walk */ -static inline void print_gw (walk_t *gw) +static inline void print_gw (const walk_t *gw) { -gdprintk (XENLOG_INFO ,"GUEST WALK TO %#lx:\n" , gw->va); +gprintk (XENLOG_INFO ,"GUEST WALK TO %p\n" ,_p (gw->va));#if GUEST_PAGING_LEVELS >=3 /* PAE or 64... */ #if GUEST_PAGING_LEVELS >=4 /* 64-bit only... */ -gdprintk (XENLOG_INFO ," l4mfn=%" PRI_mfn"\n" ,mfn_x (gw->l4mfn)); -gdprintk (XENLOG_INFO ," l4e=%" PRI_gpte"\n" , gw->l4e.l4); -gdprintk (XENLOG_INFO ," l3mfn=%" PRI_mfn"\n" ,mfn_x (gw->l3mfn)); +gprintk (XENLOG_INFO ," l4e=%" PRI_gpte" l4mfn=%" PRI_mfn"\n" , + gw->l4e.l4,mfn_x (gw->l4mfn)); +gprintk (XENLOG_INFO ," l3e=%" PRI_gpte" l3mfn=%" PRI_mfn"\n" , + gw->l3e.l3,mfn_x (gw->l3mfn)); +#else /* PAE only... */ +gprintk (XENLOG_INFO ," l3e=%" PRI_gpte"\n" , gw->l3e.l3);#endif /* PAE or 64... */ -gdprintk (XENLOG_INFO ," l3e=%" PRI_gpte"\n" , gw->l3e.l3);#endif /* All levels... */ -gdprintk (XENLOG_INFO ," l2mfn=%" PRI_mfn"\n" ,mfn_x (gw->l2mfn)); -gdprintk (XENLOG_INFO ," l2e=%" PRI_gpte"\n" , gw->l2e.l2); -gdprintk (XENLOG_INFO ," l1mfn=%" PRI_mfn"\n" ,mfn_x (gw->l1mfn)); -gdprintk (XENLOG_INFO ," l1e=%" PRI_gpte"\n" , gw->l1e.l1); +gprintk (XENLOG_INFO ," l2e=%" PRI_gpte" l2mfn=%" PRI_mfn"\n" , + gw->l2e.l2,mfn_x (gw->l2mfn)); +gprintk (XENLOG_INFO ," l1e=%" PRI_gpte" l1mfn=%" PRI_mfn"\n" , + gw->l1e.l1,mfn_x (gw->l1mfn)); }#endif /* _XEN_ASM_GUEST_PT_H */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 x86/debugtrace: Introduce a reset debugkey
When tracing a difference between two runs, it can be useful to reset the trace count to help identify where the two traces diverge.
Move the count outside debugtrace_printk() it can be reset. Inline debugtrace_toggle() into its single caller, so its prologue and epilogue can be reused. Register a second keyhandler pointing at debugtrace_key(), and select the action based on the key used.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
--- xen/drivers/char/console.c | 64 +++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 27 deletions(-)
xen/drivers/char/console.c +37 -27
@@ -961,6 +961,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 unsigned int debugtrace_count;static DEFINE_SPINLOCK (debugtrace_lock);integer_param ("debugtrace" , debugtrace_kilobytes);
@@ -984,29 +985,6 @@ static void debugtrace_dump_worker(void)printk ("debugtrace_dump() finished\n" ); } -static void debugtrace_toggle (void ) -{ -unsigned long flags; - -watchdog_disable (); -spin_lock_irqsave (&debugtrace_lock, flags); - -/* -* Dump the buffer *before* toggling, in case the act of dumping the -* buffer itself causes more printk() invocations. -*/ -printk ("debugtrace_printk now writing to %s.\n" , - !debugtrace_send_to_console ?"console" :"buffer" ); -if ( !debugtrace_send_to_console ) -debugtrace_dump_worker (); - - debugtrace_send_to_console = !debugtrace_send_to_console; - -spin_unlock_irqrestore (&debugtrace_lock, flags); -watchdog_enable (); - -} -void debugtrace_dump (void ) {unsigned long flags;
@@ -1023,7 +1001,6 @@ void debugtrace_dump(void)void debugtrace_printk (const char *fmt, ...) {static char buf[1024 ]; -static u32 count;va_list args;char *p;
@@ -1038,7 +1015,7 @@ void debugtrace_printk(const char *fmt, ...)ASSERT (debugtrace_buf[debugtrace_bytes -1 ] ==0 ); -snprintf (buf,sizeof (buf),"%u " , ++count); +snprintf (buf,sizeof (buf),"%u " , ++debugtrace_count);va_start (args, fmt); (void )vsnprintf (buf +strlen (buf),sizeof (buf) -strlen (buf), fmt, args);
@@ -1064,7 +1041,38 @@ void debugtrace_printk(const char *fmt, ...)static void debugtrace_key (unsigned char key) { -debugtrace_toggle (); +unsigned long flags; + +watchdog_disable (); +spin_lock_irqsave (&debugtrace_lock, flags); + +if ( key =='T' )/* Toggle */ + { +/* +* Dump the buffer *before* toggling, in case the act of dumping the +* buffer itself causes more printk() invocations. +*/ +printk ("debugtrace_printk now writing to %s.\n" , + !debugtrace_send_to_console ?"console" :"buffer" ); +if ( !debugtrace_send_to_console ) +debugtrace_dump_worker (); + + debugtrace_send_to_console = !debugtrace_send_to_console; + } +else if ( key =='Y' )/* Reset */ + { +printk ("Resetting debugtrace buffer and count\n" ); + +memset (debugtrace_buf,'\0' , debugtrace_bytes); + debugtrace_prd =0 ; + debugtrace_count =0 ; + debugtrace_used =0 ; + } +else +printk ("Unrecognised debugtrace key '%c'\n" , key); + +spin_unlock_irqrestore (&debugtrace_lock, flags); +watchdog_enable (); }static int __init debugtrace_init (void )
@@ -1090,12 +1098,14 @@ static int __init debugtrace_init(void)register_keyhandler ('T' , debugtrace_key,"toggle debugtrace to console/buffer" ,0 ); +register_keyhandler ('Y' , debugtrace_key, +"reset debugtrace buffer and count" ,0 ); return 0; }__initcall (debugtrace_init); -#endif /* !NDEBUG */ +#endif /* !DEBUG_TRACE_DUMP */ /*
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86/debugtrace: Introduce a reset debugkey
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 05.12.16 at 11:02, <[email protected]> wrote:
When tracing a difference between two runs, it can be useful to reset the trace count to help identify where the two traces diverge.
Move the count outside
debugtrace_printk()it can be reset. Inlinedebugtrace_toggle()into its single caller, so its prologue and epilogue can be reused. Register a second keyhandler pointing atdebugtrace_key(), and select the action based on the key used.
I think we need to start becoming more conservative with introducing new debug keys, as there aren't that many unused ones left. Hence a first question here would be - would a sysctl do as a replacement? In which case I'd question whether instead of adding another key we could also get rid of 'T' this same way.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86/debugtrace: Introduce a reset debugkey
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 05.12.16 at 11:02, <[email protected]> wrote:
When tracing a difference between two runs, it can be useful to reset the trace count to help identify where the two traces diverge.
Move the count outside
debugtrace_printk()it can be reset. Inlinedebugtrace_toggle()into its single caller, so its prologue and epilogue can be reused. Register a second keyhandler pointing atdebugtrace_key(), and select the action based on the key used.
Quoted 5 lines
I think we need to start becoming more conservative with introducing new debug keys, as there aren't that many unused ones left. Hence a first question here would be - would a sysctl do as a replacement? In which case I'd question whether instead of adding another key we could also get rid of 'T' this same way.
These keys only exist if debugtrace is compiled in, which is controlled by uncommenting "#define DEBUG_TRACE_DUMP" in lib.h
Of all the keys to try and turn into sysctls, these would be the most awkward, IMO.
As to our keyhandler space issue, we might want to consider putting in something a little more featureful. Back when XenServer was investigating highly disaggregated systems, we came to the conclusion that it was an absolute must that we could switch between the consoles of the driver domains.
In the case that all network cards are in driver domains and network problems are happening, the debuggability of the system is about 0 without the ability to interact with the driver domain consoles.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86/debugtrace: Introduce a reset debugkey
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 05.12.16 at 12:50, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 05.12.16 at 11:02, <[email protected]> wrote:
When tracing a difference between two runs, it can be useful to reset the trace count to help identify where the two traces diverge.
Move the count outside
debugtrace_printk()it can be reset. Inlinedebugtrace_toggle()into its single caller, so its prologue and epilogue can be reused. Register a second keyhandler pointing atdebugtrace_key(), and select the action based on the key used.Quoted 5 lines
I think we need to start becoming more conservative with introducing new debug keys, as there aren't that many unused ones left. Hence a first question here would be - would a sysctl do as a replacement? In which case I'd question whether instead of adding another key we could also get rid of 'T' this same way.
Quoted 5 lines
These keys only exist if debugtrace is compiled in, which is controlled by uncommenting "#define
DEBUG_TRACE_DUMP" inlib.hOf all the keys to try and turn into sysctls, these would be the most awkward, IMO.
Not sure I follow. The ones most relevant to stay keys are the diagnostic ones, as they may be needed once the system isn't functioning well enough anymore to issue xl commands. And for the non-diagnostic ones it's unclear to me why the ones here would be any better or worse to convert to sysctl.
Quoted 9 lines
As to our keyhandler space issue, we might want to consider putting in something a little more featureful. Back when XenServer was investigating highly disaggregated systems, we came to the conclusion that it was an absolute must that we could switch between the consoles of the driver domains.
In the case that all network cards are in driver domains and network problems are happening, the debuggability of the system is about 0 without the ability to interact with the driver domain consoles.
I don't see the connection between keyhandler space and driver domain consoles.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Andrew Cooper
print_gw()has no callers, meaning that it only gets used as part of manual debugging. As such, the FILE/LINE references are of no practical use, and voluminous in the log. Additionally, the function becoming empty in a non-debug build is unhelpful. Switch fromgdprintk()togprintk().Print the entry and mfn for a specific level on the same line. This halves the number of lines printed overall. There needs to be a small adjustment to the #ifdef'ary to maintain the proper l3e behaviour for 3-level paging, where there is no l3mfn to print.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel