From patchwork Fri Nov 27 16:18:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11936615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15EAEC3E8C5 for ; Fri, 27 Nov 2020 16:18:28 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87A5C2223D for ; Fri, 27 Nov 2020 16:18:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="kHlkIPIM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87A5C2223D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+208+5278000+9232812@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id LBiMYY5279335xhtQIMTY1Ce; Fri, 27 Nov 2020 08:18:27 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web08.20964.1606493906000708956 for ; Fri, 27 Nov 2020 08:18:27 -0800 IronPort-SDR: NGEBxS9ItOoRY2WHlNR1eTtjtYSSpEJ9qc7Zk5eAYjX7ctm/+lRRAIQR75AFPHLHsnhdqJqOXH ZdPPeiYjItrg== X-IronPort-AV: E=McAfee;i="6000,8403,9818"; a="236543449" X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="236543449" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:26 -0800 IronPort-SDR: FSYa2JxjTM/bJugn698bg9ey7Rjg+V1wbeMYGMF/zoqOfJi4Ph1GHuSbd+6GG+Fj/V0u55NX0J 2MLx55m1QarA== X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="548095109" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:23 -0800 From: "Paoloni, Gabriele" To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [linux-safety] [PATCH v2 1/5] x86/mce: do not overwrite no_way_out if mce_end() fails Date: Fri, 27 Nov 2020 16:18:15 +0000 Message-Id: <20201127161819.3106432-2-gabriele.paoloni@intel.com> In-Reply-To: <20201127161819.3106432-1-gabriele.paoloni@intel.com> References: <20201127161819.3106432-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech List-Post: X-Gm-Message-State: c2RLz8UVRXkWObxaj6VxRRtZx5278000AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1606493907; bh=kyw7dagKDcwHJE6A1vIRReUqzDk1j+dylFKFAtm/CzA=; h=Cc:Content-Type:Date:From:Subject:To; b=kHlkIPIMOPRvgz3E68YPcnGPXX578Swwo6jjOfYlfpY86fh9MjMXZUi6mnTR6PUB+pR 8vKxnftz0tSZ0KPebFoLrukWCR5Jgz1Skl3syEPlz20ywSV/WbHxxwiMKLK8FPvJc5yZO 0+2wvqxSmd8Pil+6YSkjqk5D7Zwh/Ta4e8o= Currently if mce_end() fails 'no_way_out' is set equal to 'worst'. 'worst' is the worst severity that was found across the MCA banks associated with the current CPU; however at this point 'no_way_out' could have been already set by mca_start() by looking at all severities of all CPUs that entered the MCE handler. If mce_end() fails, check first if no_way_out is already set and, if so, stick to it, otherwise use the local worst value. Cc: Signed-off-by: Gabriele Paoloni Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 4102b866e7c0..32b7099e3511 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1384,8 +1384,10 @@ noinstr void do_machine_check(struct pt_regs *regs) * When there's any problem use only local no_way_out state. */ if (!lmce) { - if (mce_end(order) < 0) - no_way_out = worst >= MCE_PANIC_SEVERITY; + if (mce_end(order) < 0) { + if (!no_way_out) + no_way_out = worst >= MCE_PANIC_SEVERITY; + } } else { /* * If there was a fatal machine check we should have From patchwork Fri Nov 27 16:18:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11936617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0C23C63798 for ; Fri, 27 Nov 2020 16:18:29 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 410FD21534 for ; Fri, 27 Nov 2020 16:18:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="siFXL7VG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 410FD21534 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+209+5278000+9232812@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id znAEYY5279335xF2NBJZoehb; Fri, 27 Nov 2020 08:18:29 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web08.20964.1606493906000708956 for ; Fri, 27 Nov 2020 08:18:28 -0800 IronPort-SDR: oZYS0IYhDArGy3HcoT3wxKfGKebS1/6Mob6KqTnRbZoGf0iLLY+MmbobFlpn94BJRCdKz1oPys jRP/GO3xx1RA== X-IronPort-AV: E=McAfee;i="6000,8403,9818"; a="236543452" X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="236543452" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:28 -0800 IronPort-SDR: U5sPqM2Z6LrYhlajZNXbSVjbGR6s385DfcOE4fru4a1Jz1+7ifAz+XNrMKnSl8vkFqRF7V+cWH 9jk3F3fbNxiw== X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="548095130" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:26 -0800 From: "Paoloni, Gabriele" To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [linux-safety] [PATCH v2 2/5] x86/mce: move the mce_panic() call and 'kill_it' assignments to the right places Date: Fri, 27 Nov 2020 16:18:16 +0000 Message-Id: <20201127161819.3106432-3-gabriele.paoloni@intel.com> In-Reply-To: <20201127161819.3106432-1-gabriele.paoloni@intel.com> References: <20201127161819.3106432-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech List-Post: X-Gm-Message-State: f7zpZgDBWqGf9oObQMZQyUYrx5278000AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1606493909; bh=UMKXH7I2v4pUZC280FYbGNNQsftdYAnQsbFzi5XCXqM=; h=Cc:Content-Type:Date:From:Subject:To; b=siFXL7VGE93bIthwhWWMl1w09CzDF3ganHUJDc3C05NIp/BzzaKRHJR7YXmSc+us0KS d2pVnvlUdI0QLRW+67QdLswzfj+/qQzqDnqne6yf8OjK6cSUVB9yik+Uq7FLBr55OrZXS Ekj1xxIil443b+dp+yWsOvAsV+DIBRlpIIk= Right now for local MCEs we panic(),if needed, right after lmce is set. For global MCEs mce_reign() takes care of calling mce_panic(). Hence: - improve readibility by moving the conditional evaluation of tolerant up to when kill_it is set first; - move the mce_panic() call up into the statement where mce_end() fails. Signed-off-by: Gabriele Paoloni Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 32b7099e3511..50e9b0893a92 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1350,8 +1350,7 @@ noinstr void do_machine_check(struct pt_regs *regs) * severity is MCE_AR_SEVERITY we have other options. */ if (!(m.mcgstatus & MCG_STATUS_RIPV)) - kill_it = 1; - + kill_it = (cfg->tolerant == 3) ? 0 : 1; /* * Check if this MCE is signaled to only this logical processor, * on Intel, Zhaoxin only. @@ -1387,6 +1386,12 @@ noinstr void do_machine_check(struct pt_regs *regs) if (mce_end(order) < 0) { if (!no_way_out) no_way_out = worst >= MCE_PANIC_SEVERITY; + /* + * mce_reign() has probably failed hence evaluate if we need + * to panic + */ + if (no_way_out && mca_cfg.tolerant < 3) + mce_panic("Fatal machine check on current CPU", &m, msg); } } else { /* @@ -1403,15 +1408,6 @@ noinstr void do_machine_check(struct pt_regs *regs) } } - /* - * If tolerant is at an insane level we drop requests to kill - * processes and continue even when there is no way out. - */ - if (cfg->tolerant == 3) - kill_it = 0; - else if (no_way_out) - mce_panic("Fatal machine check on current CPU", &m, msg); - if (worst > 0) irq_work_queue(&mce_irq_work); From patchwork Fri Nov 27 16:18:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11936619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B871C3E8C5 for ; Fri, 27 Nov 2020 16:18:32 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0597B21534 for ; Fri, 27 Nov 2020 16:18:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="swy9modn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0597B21534 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+210+5278000+9232812@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id r215YY5279335xfDIxviay8s; Fri, 27 Nov 2020 08:18:31 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web08.20964.1606493906000708956 for ; Fri, 27 Nov 2020 08:18:31 -0800 IronPort-SDR: cz+RVS5936PBWRwAppQ8NjTbiyjGG2+lIfbHs9sz1KP5E5CruVbrTeqVuB5e49yCGdKghm+eYN FXJKjW+/l0fA== X-IronPort-AV: E=McAfee;i="6000,8403,9818"; a="236543456" X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="236543456" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:31 -0800 IronPort-SDR: R3L7FpdmHwaVEKeBO7+K7LfahIOeVMyvER/9hR1i17fDLFYSBJ3MZQja+1XSI8fItQ9uqBoh3U pRRkS8SQAgkQ== X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="548095144" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:28 -0800 From: "Paoloni, Gabriele" To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [linux-safety] [PATCH v2 3/5] x86/mce: for LMCE panic only if mca_cfg.tolerant < 3 Date: Fri, 27 Nov 2020 16:18:17 +0000 Message-Id: <20201127161819.3106432-4-gabriele.paoloni@intel.com> In-Reply-To: <20201127161819.3106432-1-gabriele.paoloni@intel.com> References: <20201127161819.3106432-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech List-Post: X-Gm-Message-State: 6ufAk3aXMQVJuLKSyLllWERqx5278000AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1606493911; bh=Dn0imm+oGjgAHX7Ard8Hpl+eCwv2bNecyAf2R2XG2QU=; h=Cc:Content-Type:Date:From:Subject:To; b=swy9modn+M2wqSREPp+EUZo+S5ZE/0RpNJfmQ49OfhITxrVOcD8Url6zYrpKI6dmbqh fOQC8SBZDMt9WRYkv0iNMFEEaADfG0DkhbFeAwlbJZjQsjKaO42p65MJJSSaMI0Y7cMoT Py3CxTzpnmB5xKTB++kSZtjJzgvF7an5qz0= Right now for LMCE if no_way_out is set mce_panic() is called regardless of mca_cfg.tolerant. This is not correct as, if mca_cfg.tolerant = 3, the code should never panic. Signed-off-by: Gabriele Paoloni Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 50e9b0893a92..d766a3f6a343 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1367,7 +1367,7 @@ noinstr void do_machine_check(struct pt_regs *regs) * to see it will clear it. */ if (lmce) { - if (no_way_out) + if (no_way_out && mca_cfg.tolerant < 3) mce_panic("Fatal local machine check", &m, msg); } else { order = mce_start(&no_way_out); From patchwork Fri Nov 27 16:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11936621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 648DFC63798 for ; Fri, 27 Nov 2020 16:18:34 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DFCB21534 for ; Fri, 27 Nov 2020 16:18:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="mr4yNVBw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DFCB21534 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+211+5278000+9232812@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id T6ooYY5279335xC4DSR2l9Q2; Fri, 27 Nov 2020 08:18:33 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web08.20964.1606493906000708956 for ; Fri, 27 Nov 2020 08:18:33 -0800 IronPort-SDR: nOKXzg8iDU6BFd2rfqGPI0bw7kv4r1QopC+bpZHbO01Had0mKTiHRUz7Sf7jgkm7MC+fYshiWW LpYIHa8YVc2A== X-IronPort-AV: E=McAfee;i="6000,8403,9818"; a="236543460" X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="236543460" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:33 -0800 IronPort-SDR: LNRD34yjDKhKsejH9usrAuRXFZh1h9gtsXH3CebUPDjWub2FJGJHN03b1fseTFWRiEy4qQ0YV2 PlGvHyJk9HFA== X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="548095161" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:31 -0800 From: "Paoloni, Gabriele" To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [linux-safety] [PATCH v2 4/5] x86/mce: remove redundant call to irq_work_queue() Date: Fri, 27 Nov 2020 16:18:18 +0000 Message-Id: <20201127161819.3106432-5-gabriele.paoloni@intel.com> In-Reply-To: <20201127161819.3106432-1-gabriele.paoloni@intel.com> References: <20201127161819.3106432-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech List-Post: X-Gm-Message-State: mlPf5btCB5lo3MvHLxrxYAp7x5278000AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1606493913; bh=2crtWspoj4OrC4YPp5UD6nLFCfij4H+LfwTxZPWssrU=; h=Cc:Content-Type:Date:From:Subject:To; b=mr4yNVBwoGPmxq5yObohDc6+1wo55Wvte51/A3NjDMVx7MEEovqlZ9eFyvQUUB848+V c41tGSKkz9uo10+K+32Ag9kB2i/MiFPFkeok5s3fDe3WPD4NNwlF7IOeE740LJr9VDD/9 C+CNUbmYz9U/M2z+3/lGPSwDvIxhYZLU854= Right now in do_machine_check() __mc_scan_banks() triggers the following call tree: __mc_scan_banks()->mce_log()->irq_work_queue(&mce_irq_work). Hence the call of irq_work_queue() below after __mc_scan_banks() seems redundant. Just remove it. Signed-off-by: Gabriele Paoloni Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index d766a3f6a343..802302c54762 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1408,9 +1408,6 @@ noinstr void do_machine_check(struct pt_regs *regs) } } - if (worst > 0) - irq_work_queue(&mce_irq_work); - if (worst != MCE_AR_SEVERITY && !kill_it) goto out; From patchwork Fri Nov 27 16:18:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paoloni, Gabriele" X-Patchwork-Id: 11936623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3DE6C3E8C5 for ; Fri, 27 Nov 2020 16:18:36 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CDD82223F for ; Fri, 27 Nov 2020 16:18:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="jMl32CIF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CDD82223F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+212+5278000+9232812@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id Q5HWYY5279335xm0WND5SXs2; Fri, 27 Nov 2020 08:18:36 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web08.20964.1606493906000708956 for ; Fri, 27 Nov 2020 08:18:36 -0800 IronPort-SDR: V5Kv/x9f42NBP+l4wSNHUtwGW81RKTLUFSnANAYUlIiRyoZxUEc0eVz9qRFfkcxaK7jHzVIYr7 8sU8A6XcDw0A== X-IronPort-AV: E=McAfee;i="6000,8403,9818"; a="236543465" X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="236543465" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:35 -0800 IronPort-SDR: 4VpXVwaAo5p2D9bQaGy9uojCA1TWHWQumUv8bqM7lWNzcxc56DDhQq8JqftyXhyoiCbpvYoDml ilFJOE0+OD2Q== X-IronPort-AV: E=Sophos;i="5.78,375,1599548400"; d="scan'208";a="548095177" X-Received: from paolonig001.ir.intel.com ([163.33.183.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 08:18:33 -0800 From: "Paoloni, Gabriele" To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [linux-safety] [PATCH v2 5/5] x86/mce: rename kill_it as kill_current_task Date: Fri, 27 Nov 2020 16:18:19 +0000 Message-Id: <20201127161819.3106432-6-gabriele.paoloni@intel.com> In-Reply-To: <20201127161819.3106432-1-gabriele.paoloni@intel.com> References: <20201127161819.3106432-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech List-Post: X-Gm-Message-State: 5ZaF4Bc8JgcSesiiMxfoZzvBx5278000AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1606493916; bh=NSlUO70SfvQyEFRtDS9Y0ge/lBX/vaOgifyrY9Rx69E=; h=Cc:Content-Type:Date:From:Subject:To; b=jMl32CIF34m3IlwjZ606TC7HeZBwSEu8a01DsHv0c1POJNL+Aatik2gxyQMV49nGLEc wZIq/1xbVZ7nVovJjZ0uPvJG4ajMZOtz9pb+CUNIDSGTEIAMZGnJrXUoi3aZDpKo1A+/q q+leuTobKXtQuqjC6YW+1R2Yx1APBCJMPb8= Currently if an MCE happens in user-mode or while the kernel is copying data from user space, 'kill_it' is used to check if we can recover the execution of the interrupted task or not; the flag name however is not much meaningful, hence rename it to match its goal. Signed-off-by: Gabriele Paoloni --- arch/x86/kernel/cpu/mce/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 802302c54762..740a4fcc1e90 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1320,10 +1320,10 @@ noinstr void do_machine_check(struct pt_regs *regs) int no_way_out = 0; /* - * If kill_it gets set, there might be a way to recover from this + * If kill_current_task is not set, there might be a way to recover from this * error. */ - int kill_it = 0; + int kill_current_task = 0; /* * MCEs are always local on AMD. Same is determined by MCG_STATUS_LMCES @@ -1350,7 +1350,7 @@ noinstr void do_machine_check(struct pt_regs *regs) * severity is MCE_AR_SEVERITY we have other options. */ if (!(m.mcgstatus & MCG_STATUS_RIPV)) - kill_it = (cfg->tolerant == 3) ? 0 : 1; + kill_current_task = (cfg->tolerant == 3) ? 0 : 1; /* * Check if this MCE is signaled to only this logical processor, * on Intel, Zhaoxin only. @@ -1408,7 +1408,7 @@ noinstr void do_machine_check(struct pt_regs *regs) } } - if (worst != MCE_AR_SEVERITY && !kill_it) + if (worst != MCE_AR_SEVERITY && !kill_current_task) goto out; /* Fault was in user mode and we need to take some action */ @@ -1416,7 +1416,7 @@ noinstr void do_machine_check(struct pt_regs *regs) /* If this triggers there is no way to recover. Die hard. */ BUG_ON(!on_thread_stack() || !user_mode(regs)); - queue_task_work(&m, kill_it); + queue_task_work(&m, kill_current_task); } else { /* @@ -1434,7 +1434,7 @@ noinstr void do_machine_check(struct pt_regs *regs) } if (m.kflags & MCE_IN_KERNEL_COPYIN) - queue_task_work(&m, kill_it); + queue_task_work(&m, kill_current_task); } out: mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);