On 02/21/2017 03:35 AM, Pan Xinhui wrote: > > > 在 2017/2/21 09:58, Guilherme G. Piccoli 写道: >> Currently the xmon debugger is set only via kernel boot command-line. >> It's disabled by default, and can be enabled with "xmon=on" on the >> command-line. Also, xmon may be accessed via sysrq mechanism. >> But we cannot enable/disable xmon in runtime, it needs kernel reload. >> >> This patch introduces a debugfs entry for xmon, allowing user to query >> its current state and change it if desired. Basically, the "xmon" file >> to read from/write to is under the debugfs mount point, on powerpc >> directory. It's a simple attribute, value 0 meaning xmon is disabled >> and value 1 the opposite. Writing these states to the file will take >> immediate effect in the debugger. >> >> Signed-off-by: Guilherme G. Piccoli <gpicc...@linux.vnet.ibm.com> >> --- >> v3: logic improved based in the changes made on patch 1. >> >> v2: dropped the custom parser by using simple attributes [mpe suggestion]. >> >> >> arch/powerpc/xmon/xmon.c | 31 +++++++++++++++++++++++++++++++ >> 1 file changed, 31 insertions(+) >> >> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c >> index f1fcfa8..764ea62 100644 >> --- a/arch/powerpc/xmon/xmon.c >> +++ b/arch/powerpc/xmon/xmon.c >> @@ -29,6 +29,10 @@ >> #include <linux/nmi.h> >> #include <linux/ctype.h> >> >> +#ifdef CONFIG_DEBUG_FS >> +#include <linux/debugfs.h> >> +#endif >> + >> #include <asm/ptrace.h> >> #include <asm/string.h> >> #include <asm/prom.h> >> @@ -3275,6 +3279,33 @@ static int __init setup_xmon_sysrq(void) >> device_initcall(setup_xmon_sysrq); >> #endif /* CONFIG_MAGIC_SYSRQ */ >> >> +#ifdef CONFIG_DEBUG_FS >> +static int xmon_dbgfs_set(void *data, u64 val) >> +{ >> + xmon_off = !val; > xmon_off is really 'off' :) > There is xmon_on >
OK, this is *really* odd. I sent the wrong version of the patch ={ I'm _sorry_, thanks for noticing Xinhui! @Michael, my complete fault. I tested the real "v3" of this patch, but for some reason (aka my disorganization) I sent the old v2. In the v3, I used "xmon_on = !!val". How about if I resend the whole series tomorrow, correcting this and changing patch 2 in order to keep the automatic show of backtrace always? Or do you prefer to fix it yourself? Thanks, and again, I apologize for the mess. Guilherme >> + xmon_init(!xmon_off); >> + >> + return 0; >> +} >> + >> +static int xmon_dbgfs_get(void *data, u64 *val) >> +{ >> + *val = !xmon_off; >> + return 0; >> +} >> + >> +DEFINE_SIMPLE_ATTRIBUTE(xmon_dbgfs_ops, xmon_dbgfs_get, >> + xmon_dbgfs_set, "%llu\n"); >> + >> +static int __init setup_xmon_dbgfs(void) >> +{ >> + debugfs_create_file("xmon", 0600, powerpc_debugfs_root, NULL, >> + &xmon_dbgfs_ops); >> + return 0; >> +} >> +device_initcall(setup_xmon_dbgfs); >> +#endif /* CONFIG_DEBUG_FS */ >> + >> static int xmon_early __initdata; >> >> static int __init early_parse_xmon(char *p) >>