Re: [RFC PATCH 16/17] x86/nmi: Perform a safe NMI stack trace on all CPUs

From: long.wanglong
Date: Tue May 19 2015 - 04:57:00 EST


On 2015/5/18 22:17, Petr Mladek wrote:
> On Thu 2015-05-14 11:35:03, Wang Long wrote:
>> From: "Steven Rostedt (Red Hat)" <rostedt@xxxxxxxxxxx>
>>
>> commit a9edc88093287183ac934be44f295f183b2c62dd upstream.
>>
>> When trigger_all_cpu_backtrace() is called on x86, it will trigger an
>> NMI on each CPU and call show_regs(). But this can lead to a hard lock
>> up if the NMI comes in on another printk().
>>
>> In order to avoid this, when the NMI triggers, it switches the printk
>> routine for that CPU to call a NMI safe printk function that records the
>> printk in a per_cpu seq_buf descriptor. After all NMIs have finished
>> recording its data, the seq_bufs are printed in a safe context.
>>
>> Link: http://lkml.kernel.org/p/20140619213952.360076309@xxxxxxxxxxx
>> Link: http://lkml.kernel.org/r/20141115050605.055232587@xxxxxxxxxxx
>>
>> Tested-by: Jiri Kosina <jkosina@xxxxxxx>
>> Acked-by: Jiri Kosina <jkosina@xxxxxxx>
>> Acked-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
>> Reviewed-by: Petr Mladek <pmladek@xxxxxxx>
>> [wanglong: backport to 3.10 stable
>> - adjust context
>> ]
>> Signed-off-by: Wang Long <long.wanglong@xxxxxxxxxx>
>> Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
>> ---
>> arch/x86/kernel/apic/hw_nmi.c | 86 +++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 83 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c
>> index a698d71..1eb5f90 100644
>> --- a/arch/x86/kernel/apic/hw_nmi.c
>> +++ b/arch/x86/kernel/apic/hw_nmi.c
>> @@ -18,6 +18,7 @@
>> #include <linux/nmi.h>
>> #include <linux/module.h>
>> #include <linux/delay.h>
>> +#include <linux/seq_buf.h>
>>
>> #ifdef CONFIG_HARDLOCKUP_DETECTOR
>> u64 hw_nmi_get_sample_period(int watchdog_thresh)
>> @@ -29,12 +30,33 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh)
>> #ifdef arch_trigger_all_cpu_backtrace
>> /* For reliability, we're prepared to waste bits here. */
>> static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
>> +static cpumask_var_t printtrace_mask;
>> +
>> +#define NMI_BUF_SIZE 4096
>
> Please, replace spaces with tabs.
>
> In fact, the indentation is broken in this whole patch.
>
> The content looks fine, though.
>
> Best Regards,
> Petr
>
Hi Petr,

Thank you for your review. Sorry for the indentation broken.

I will send the patch v2.

Best Regards
Wang Long


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/