Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932423AbbFHNmU (ORCPT ); Mon, 8 Jun 2015 09:42:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:50085 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932098AbbFHNlc (ORCPT ); Mon, 8 Jun 2015 09:41:32 -0400 Date: Mon, 8 Jun 2015 15:41:27 +0200 From: Borislav Petkov To: Tony Luck Cc: "Chen, Gong" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4 Rebase] x86, MCE: Avoid potential deadlock in MCE context Message-ID: <20150608134127.GE5877@pd.tnic> References: <1432150538-3120-1-git-send-email-gong.chen@linux.intel.com> <1432150538-3120-5-git-send-email-gong.chen@linux.intel.com> <20150520092800.GB3645@pd.tnic> <20150522211247.GB4930@gchen.bj.intel.com> <20150522090941.GD3606@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150522090941.GD3606@pd.tnic> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3423 Lines: 103 On Fri, May 22, 2015 at 11:09:41AM +0200, Borislav Petkov wrote: > On Fri, May 22, 2015 at 05:12:47PM -0400, Chen, Gong wrote: > > Since AMD doesn't queue any MCE, > > Of course it does - amd_threshold_interrupt() and the newly added > amd_deferred_error_interrupt() both call __log_error() which does > mce_log(). So AFAINM, we want to do MCE work only after we've logged something to the genpool. So we can do the much simplified thing below and kick the workqueue from within mce_log() as everything that logs, calls that function. Tony, any concerns? I haven't tested it yet but will do so once we've sorted out the MCE injection stuff on AMD. Thanks. --- From: "Chen, Gong" Date: Wed, 20 May 2015 15:35:38 -0400 Subject: [PATCH] x86/mce: Avoid potential deadlock due to printk() in MCE context Printing in MCE context is a no-no, currently, as printk is not NMI-safe. If some of the notifiers on the MCE chain call do so, we may deadlock. In order to avoid that, delay printk() to process context where it is safe to do so. Reported-by: Xie XiuQi Signed-off-by: Chen, Gong Cc: Tony Luck Link: http://lkml.kernel.org/r/1432150538-3120-5-git-send-email-gong.chen@linux.intel.com [ Boris: kick irq_work in mce_log() directly. ] Signed-off-by: --- arch/x86/kernel/cpu/mcheck/mce-apei.c | 1 - arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c b/arch/x86/kernel/cpu/mcheck/mce-apei.c index a1aef9533154..34c89a3e8260 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-apei.c +++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c @@ -57,7 +57,6 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) m.addr = mem_err->physical_addr; mce_log(&m); - mce_notify_irq(); } EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 321c7f6e17a0..6aef4970206f 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -156,7 +156,8 @@ void mce_log(struct mce *mce) /* Emit the trace record: */ trace_mce_record(mce); - atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); + mce_genpool_add(mce); + irq_work_queue(&mce_irq_work); mce->finished = 0; wmb(); @@ -1115,7 +1116,6 @@ void do_machine_check(struct pt_regs *regs, long error_code) /* assuming valid severity level != 0 */ m.severity = severity; m.usable_addr = mce_usable_address(&m); - mce_genpool_add(&m); mce_log(&m); diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c index 844f56c5616d..70f567f774ed 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_intel.c +++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c @@ -246,7 +246,6 @@ static void intel_threshold_interrupt(void) return; machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(&mce_banks_owned)); - mce_notify_irq(); } /* -- 2.3.5 -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. -- -- 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/