stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Gleb Natapov <gleb@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Joerg Roedel <joro@8bytes.org>,
	x86@kernel.org, stable@vger.kernel.org,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Sebastian Andrzej Siewior <sebastian@breakpoint.cc>,
	Ingo Molnar <mingo@redhat.com>,
	Zhang Yanfei <zhangyanfei@cn.fujitsu.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	yrl.pp-manager.tt@hitachi.com,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Seiji Aguchi <seiji.aguchi@hds.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Re: [PATCH] [BUGFIX] crash/ioapic: Prevent crash_kexec() from deadlocking of ioapic_lock
Date: Tue, 20 Aug 2013 09:06:50 +0900	[thread overview]
Message-ID: <5212B31A.6090504@hitachi.com> (raw)
In-Reply-To: <20130819094623.GA30389@gmail.com>

Hi Ingo,

Thank you for fixing typos!
OK, I'll fix them and rename to ioapic_zap_locks().

Thank you again!

Yoshihiro YUNOMAE

(2013/08/19 18:46), Ingo Molnar wrote:
>
> * Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com> wrote:
>
>> Prevent crash_kexec() from deadlocking of ioapic_lock.
>
> s/of/on
>
>> When crash_kexec() is executed on a cpu, the cpu will get
>> ioapic_lock in disable_IO_APIC(). So if the cpu gets NMI
>> while locking ioapic_lock, a deadlock wiil happen. In
>
> s/will
>
>> this patch, ioapic_lock is initialized before
>> disable_IO_APIC().
>>
>> To confirm this deadlocking, you'll set up as follows:
>
> s/deadlocking/deadlock
>
>> 1. Add mdelay(1000) after raw_spin_lock_irqsave() in
>>     native_ioapic_set_affinity()@arch/x86/kernel/apic/io_apic.c
>>
>>     Although the deadlocking can occur without this modification, it will
>>    increase the potential of the deadlocking problem.
>
> s/deadlocking/deadlock
>
>>
>> 2. Build and install the kernel
>>
>> 3. Set up the OS which will run panic() and kexec when NMI is injected
>>      # echo "kernel.unknown_nmi_panic=1" >> /etc/sysctl.conf
>>      # vim /etc/default/grub
>>        add "nmi_watchdog=0 crashkernel=256M" in GRUB_CMDLINE_LINUX line
>>      # grub2-mkconfig
>>
>> 4. Reboot the OS
>>
>> 5. Run following command for each vcpu on the guest
>>      # while true; do echo <CPU num> > /proc/irq/<IO-APIC-edge or IO-APIC-fasteoi>/smp_affinitity; done;
>>     By running this command, cpus will get ioapic_lock for setting affinity.
>>
>> 6. Inject NMI (push a dump button or execute 'virsh inject-nmi <domain>' if you
>>     use VM)
>>     After injecting NMI, panic() is called in an nmi-handler context.
>>     Then, kexec will normally run in panic(), but the operation will be stopped
>>     by deadlock of ioapic_lock in crash_kexec()->machine_crash_shutdown()->
>
> s/of/on
>
>>     native_machine_crash_shutdown()->disable_IO_APIC()->clear_IO_APIC()->
>>     clear_IO_APIC_pin()->ioapic_read_entry().
>
> I suppose we could do this patch if it's a common
> occurance.
>
> A few minor details need fixing:
>
>>
>> Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> Cc: x86@kernel.org
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Andi Kleen <ak@linux.intel.com>
>> Cc: Seiji Aguchi <seiji.aguchi@hds.com>
>> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
>> Cc: Joerg Roedel <joro@8bytes.org>
>> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
>> Cc: Gleb Natapov <gleb@redhat.com>
>> Cc: Marcelo Tosatti <mtosatti@redhat.com>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: stable@vger.kernel.org
>> ---
>>   arch/x86/include/asm/apic.h    |    2 ++
>>   arch/x86/kernel/apic/io_apic.c |    5 +++++
>>   arch/x86/kernel/crash.c        |    4 ++++
>>   3 files changed, 11 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
>> index f8119b5..ddb06af 100644
>> --- a/arch/x86/include/asm/apic.h
>> +++ b/arch/x86/include/asm/apic.h
>> @@ -715,4 +715,6 @@ static inline void exiting_ack_irq(void)
>>   	ack_APIC_irq();
>>   }
>>
>> +extern void ioapic_lock_init(void);
>> +
>>   #endif /* _ASM_X86_APIC_H */
>> diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
>> index 9ed796c..2816c07 100644
>> --- a/arch/x86/kernel/apic/io_apic.c
>> +++ b/arch/x86/kernel/apic/io_apic.c
>> @@ -1534,6 +1534,11 @@ void intel_ir_io_apic_print_entries(unsigned int apic,
>>   	}
>>   }
>>
>> +void ioapic_lock_init(void)
>> +{
>> +	raw_spin_lock_init(&ioapic_lock);
>> +}
>
> Please name this ioapic_zap_locks() to make clear that this
> is crash handling related.
>
>> +
>>   __apicdebuginit(void) print_IO_APIC(int ioapic_idx)
>>   {
>>   	union IO_APIC_reg_00 reg_00;
>> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
>> index 74467fe..ea039d5 100644
>> --- a/arch/x86/kernel/crash.c
>> +++ b/arch/x86/kernel/crash.c
>> @@ -129,6 +129,10 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
>>
>>   	lapic_shutdown();
>>   #if defined(CONFIG_X86_IO_APIC)
>
> Please enhance this #ifdef while at it.
>
>> +	/*
>> +	 * Prevent crash_kexec() from deadlocking of ioapic_lock.
>> +	 */
>
> s/of/on.
>
> Also, single-line comment can go /* here */.
>
>> +	ioapic_lock_init();
>>   	disable_IO_APIC();
>>   #endif
>>   #ifdef CONFIG_HPET_TIMER
>>
>
> Thanks,
>
> 	Ingo
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



  reply	other threads:[~2013-08-20  0:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19  8:12 [PATCH] [BUGFIX] crash/ioapic: Prevent crash_kexec() from deadlocking of ioapic_lock Yoshihiro YUNOMAE
2013-08-19  9:46 ` Ingo Molnar
2013-08-20  0:06   ` Yoshihiro YUNOMAE [this message]
2013-08-20 10:12     ` Eric W. Biederman
2013-08-20 14:27       ` Don Zickus
2013-08-22  8:38         ` Yoshihiro YUNOMAE
2013-08-22 13:11           ` Don Zickus
2013-08-27  3:41             ` Yoshihiro YUNOMAE
2013-08-27 13:33               ` Don Zickus
2013-08-31  0:58                 ` Eric W. Biederman
2013-09-02  3:09                   ` Yoshihiro YUNOMAE
2013-09-03  0:12                     ` Eric W. Biederman
2013-09-03 11:02                       ` Yoshihiro YUNOMAE
2013-09-03 12:44                         ` Eric W. Biederman
2013-09-04  9:40                           ` Yoshihiro YUNOMAE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5212B31A.6090504@hitachi.com \
    --to=yoshihiro.yunomae.ez@hitachi.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=gleb@redhat.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=sebastian@breakpoint.cc \
    --cc=seiji.aguchi@hds.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yrl.pp-manager.tt@hitachi.com \
    --cc=zhangyanfei@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).