GDB serial port debugging: Respect opt_watchdog flag when resuming a debug session
PATCH 1/1 GDB serial port debugging: Respect opt_watchdog flag when resuming a debug session
Hello,
When trap_to_gdb in common/gdbstub.c returns, it calls watchdog_enable(). However, the watchdog functionality is an option controlled in arch/x86/setup.c using the opt_watchdog boot parameter, and currently defaults to 'off'. When the user resumes from a gdb session over the serial port, the watchdog will be enabled regardless of the 'opt_watchdog' flag. This patch addresses this issue by propagating the optional parameter to arch/x86/nmi.c and conditionally enabling/disabling the watchdog based on the value of the now global 'opt_watchdog' flag.
% diffstat opt_watchdog_patch
nmi.c | 11 ++++++++++- setup.c | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-)
Dan.
xen/arch/x86/nmi.c +10 -1
@@ -39,6 +39,8 @@ static DEFINE_PER_CPU(struct timer, nmi_timer); static DEFINE_PER_CPU(unsigned int, nmi_timer_ticks); +extern int opt_watchdog; +/* * lapic_nmi_owner tracks the ownership of the lapic NMI hardware: * - it may be reserved by some other driver, or not
@@ -169,6 +171,9 @@static void enable_lapic_nmi_watchdog (void ) { +if ( !opt_watchdog ) +return ; +if (nmi_active <0 ) { nmi_watchdog =NMI_LOCAL_APIC ;setup_apic_nmi_watchdog ();
@@ -351,7 +356,8 @@void watchdog_disable (void ) { -atomic_inc (&watchdog_disable_count); +if ( opt_watchdog ) +atomic_inc (&watchdog_disable_count); }void watchdog_enable (void )
@@ -359,6 +365,9 @@static unsigned long heartbeat_initialised;unsigned int cpu; +if ( !opt_watchdog ) +return ; +if ( !atomic_dec_and_test (&watchdog_disable_count) ||test_and_set_bit (0 , &heartbeat_initialised) )return ;
xen/arch/x86/setup.c +2 -3
@@ -72,7 +72,7 @@integer_param ("maxcpus" , max_cpus);/* opt_watchdog: If true, run a watchdog NMI on each processor. */ -static int opt_watchdog =0 ; +int opt_watchdog =0 ;boolean_param ("watchdog" , opt_watchdog);/* **** Linux config option: propagated to domain0. */
@@ -950,8 +950,7 @@do_initcalls (); -if ( opt_watchdog ) -watchdog_enable (); +watchdog_enable ();/* Create initial domain 0. */ dom0 =domain_create (0 ,0 ,DOM0_SSIDREF );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
This shouldn¹t be true. If !opt_watchdog then setup.c will not call watchdog_enable() and watchdog_disable_count should be forever non-zero (because it is initialised to 1, and noone else should ever watchdog_enable() if they haven¹t previously done watchdog_disable()).
Did you make this change because you saw problems, or just because the code appeared broken?
By the way, I already applied the serial fix, and I¹ll hold off on the main patch pending a new one that makes more of the code arch-generic as suggested by Isaku Yamahata.
Thanks,
Keir
Quoted 24 lines · Dan Doucette
Hello,
When
trap_to_gdbincommon/gdbstub.creturns, it callswatchdog_enable(). However, the watchdog functionality is an option controlled inarch/x86/setup.cusing theopt_watchdogboot parameter, and currently defaults to 'off'. When the user resumes from a gdb session over the serial port, the watchdog will be enabled regardless of the 'opt_watchdog' flag. This patch addresses this issue by propagating the optional parameter toarch/x86/nmi.cand conditionally enabling/disabling the watchdog based on the value of the now global 'opt_watchdog' flag.% diffstat
opt_watchdog_patchnmi.c | 11 ++++++++++- setup.c | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-)Signed-off-by Dan Doucette <[email protected]>Dan.
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
I made this change when a number of things were not working, because it appeared broken as you said.
I never backed out the change and re-tested.
I agree, if watchdog_enable/disable are always called in even numbers, and enable is not called initially, it should be fine.
Dan.
Quoted 41 lines · Keir Fraser
This shouldn't be true. If !opt_watchdog then
setup.cwill not callwatchdog_enable()andwatchdog_disable_countshould be forever non-zero (because it is initialised to 1, and noone else should everwatchdog_enable()if they haven't previously donewatchdog_disable()).Did you make this change because you saw problems, or just because the code appeared broken?
By the way, I already applied the serial fix, and I'll hold off on the main patch pending a new one that makes more of the code arch-generic as suggested by Isaku Yamahata.
Thanks,
KeirOn 19/12/07 22:45, "Dan Doucette" <[email protected]> wrote:
Hello,
When
trap_to_gdbincommon/gdbstub.creturns, it callswatchdog_enable().
However, the watchdog functionality is an option controlled inarch/x86/setup.cusing theopt_watchdogboot parameter, and currently defaults to 'off'. When the user resumes from a gdb session over the serial port, the watchdog will be enabled regardless of the 'opt_watchdog' flag.
This patch addresses this issue by propagating the optional parameter toarch/x86/nmi.cand conditionally enabling/disabling the watchdog based on the value of the now global 'opt_watchdog' flag.% diffstat
opt_watchdog_patchnmi.c | 11 ++++++++++- setup.c | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-)Signed-off-by Dan Doucette <[email protected]>Dan.
Quoted 8 lines
------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel