From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B64BC28B28 for ; Wed, 12 Mar 2025 06:39:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65302280004; Wed, 12 Mar 2025 02:39:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB36280001; Wed, 12 Mar 2025 02:39:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A185280004; Wed, 12 Mar 2025 02:39:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2C662280001 for ; Wed, 12 Mar 2025 02:39:20 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 24955120B76 for ; Wed, 12 Mar 2025 06:39:21 +0000 (UTC) X-FDA: 83211947322.27.E5CACAC Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id EB9CB40005 for ; Wed, 12 Mar 2025 06:39:17 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741761559; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4nzl/JoAcKfk+17JGCdXapA9X4zA8l2xq/KJTnlNSZA=; b=FTPUFaGJmZbaMhFO5fwsXaM4vrIHweAHZC/B9c4JQQ7yU459DYLCIokRR/i/Rk0iwwT4hM JR6aBaeB+E3b/NjEh4NgpnqshTvh8ISZ6Dv5G5c7dVukZIU4ikaZMXPKMn2AR9OFqjCOfJ YuvQ25sSj8GyZ07Aee2IKeaczxXAW2A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741761559; a=rsa-sha256; cv=none; b=LDnBvSJGNsLnavXcqyeJ64lCIsdf6KKRPjiIPUI8xTp/xVcOcsErxgoW9F0ahVK2rBrG4i b7UtjI1SgqiRP+VbAnuaBXxe57ce2GdRYOGybdplY/9C3mJN8xGBAI3v3BANJ5qLXK6UT3 D1xqkrYpSbh94L2yQWyfedlRRt9icmg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4ZCLVN3j4HzCs97; Wed, 12 Mar 2025 14:35:40 +0800 (CST) Received: from kwepemd200019.china.huawei.com (unknown [7.221.188.193]) by mail.maildlp.com (Postfix) with ESMTPS id 42B661800CD; Wed, 12 Mar 2025 14:39:13 +0800 (CST) Received: from [10.173.127.72] (10.173.127.72) by kwepemd200019.china.huawei.com (7.221.188.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 12 Mar 2025 14:39:11 +0800 Subject: Re: [PATCH v4 2/3] mm/hwpoison: Do not send SIGBUS to processes with recovered clean pages To: Shuai Xue CC: , , , , , , , , , , , , , , , , , References: <20250307054404.73877-1-xueshuai@linux.alibaba.com> <20250307054404.73877-3-xueshuai@linux.alibaba.com> From: Miaohe Lin Message-ID: <662a16ee-66d3-3fc8-6488-8788bcfbe84e@huawei.com> Date: Wed, 12 Mar 2025 14:39:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20250307054404.73877-3-xueshuai@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd200019.china.huawei.com (7.221.188.193) X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: EB9CB40005 X-Stat-Signature: bg5n4on8tb3qopjccw1ddsd9f8ctjpyk X-HE-Tag: 1741761557-686556 X-HE-Meta: U2FsdGVkX1+r6ygvJgqrd4xg1xAg+J+e447Nwa6/vHWL1q1MTWNy3z3d3e9o3lMpRrCmR0mbhdotQHwmUIRzmmnxPuqdRWdzp1Grg7YhyDUwv69MqD9s/YXSCDrQsowMli5T7mTEyd260J4y6HiTkWFphmuTN3H4C1PbrBASwuTG2l+KCQhnpDclhI2cdH5RKq29sfWFeZafsigTG2SZ1xCzQXUbVi16utHgl8Pt9DJ/QTqILGGa1sJl165qDhYaAq58akx4uQAs7zqcBYl+ct2huN6HZuBeSndvWWOSeoR+fcgXgBu/ae5/NBDlwnF3qUxOn1o7Ditcdk6H2d1X9RZjQpwMNJm01BteMRBNhi9I/URBmX0M95nSt2Tjw5f5fPMna5xnuyXxGEOz8K00qsD4DbMJLdp4MveWp6rDWTdJGMMbzMEbV+9RQ+9r2GQg5O8Ao24fb4akWPJJNJb6ho7GY5EtfVuRplZqhYCWoetQQDMJLn1gG/OH6Ri83xypZWdb0JturRQR9Hyqh4JcHFJoyWZl+CRSCN669wiEKI7g2Az1qqv7jmKGs3oWfT1TdRGH2CzMGjr2PAZeHBdm59Txz0nmxy/2KjLjQc8cBt4qHAUy8ECawfDv9hrmtEGO2fNbL4BRbgw5knPjKfeliOuwZ0dtAH5Wq7MSUENJ+KDXwC9cDpkPCKJnoXY1dV+xDgcTUy5E3J9Ya9HgYB8RfEd5pc/CHmMLgNSRW4ek1jYXnX8L4TJ/IVGMdUHHrcJeWZ3XqcANqlME2QVAcVB5tvaHWu6/qhPjDY3OoOjIzzhtEyYE6sqECYckX+DyBc3/psiFN28o96OK+uAY8PYPAyOpkCxvYPa+Bbb17RT7Qg7oRH7Gyb/ca+g5y+7qapr8ktexQF3vScZDutkh0Va37ydTtgk+SsPPSBgBGYz9UuTJC1DoiR60eoMmg80MFsDI2apLgeYGuOkhf85ANVt fRh4uzSZ yaSiLeBhcrEG94epEhNfHeh4vORNoi3YFxcVipW7xSw8tCGjIRxSSU+/xZFPStrdwAsMftZfxltzfWdyaKS50MlsTQD0JYvITpWa6wGB1oz77aiNutg43oBgvc9qzW4WeVwCxvZnOTDpJ75s5Sbr7WXn3vOLPkw1UedcOMCaIv71UZCL8q3ZzYIDY4MgzB1jFGXoEX+/QySgkn422SlUgI6c3q6H6bwUPdmvfGSElAsaHnV6awBVkfHEtxkgD6UKOvFA2tmMXBfWxupkys4hpEDtfMA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001042, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025/3/7 13:44, Shuai Xue wrote: > When an uncorrected memory error is consumed there is a race between the > CMCI from the memory controller reporting an uncorrected error with a UCNA > signature, and the core reporting and SRAR signature machine check when the > data is about to be consumed. > > - Background: why *UN*corrected errors tied to *C*MCI in Intel platform [1] > > Prior to Icelake memory controllers reported patrol scrub events that > detected a previously unseen uncorrected error in memory by signaling a > broadcast machine check with an SRAO (Software Recoverable Action Optional) > signature in the machine check bank. This was overkill because it's not an > urgent problem that no core is on the verge of consuming that bad data. > It's also found that multi SRAO UCE may cause nested MCE interrupts and > finally become an IERR. > > Hence, Intel downgrades the machine check bank signature of patrol > scrub from SRAO to UCNA (Uncorrected, No Action required), and signal > changed to #CMCI. Just to add to the confusion, Linux does take an action > (in uc_decode_notifier()) to try to offline the page despite the UC*NA* > signature name. > > - Background: why #CMCI and #MCE race when poison is consuming in Intel platform [1] > > Having decided that CMCI/UCNA is the best action for patrol scrub errors, > the memory controller uses it for reads too. But the memory controller is > executing asynchronously from the core, and can't tell the difference > between a "real" read and a speculative read. So it will do CMCI/UCNA if an > error is found in any read. > > Thus: > > 1) Core is clever and thinks address A is needed soon, issues a speculative read. > 2) Core finds it is going to use address A soon after sending the read request > 3) The CMCI from the memory controller is in a race with MCE from the core > that will soon try to retire the load from address A. > > Quite often (because speculation has got better) the CMCI from the memory > controller is delivered before the core is committed to the instruction > reading address A, so the interrupt is taken, and Linux offlines the page > (marking it as poison). > > - Why user process is killed for instr case > > Commit 046545a661af ("mm/hwpoison: fix error page recovered but reported > "not recovered"") tries to fix noise message "Memory error not recovered" > and skips duplicate SIGBUSs due to the race. But it also introduced a bug > that kill_accessing_process() return -EHWPOISON for instr case, as result, > kill_me_maybe() send a SIGBUS to user process. > > If the CMCI wins that race, the page is marked poisoned when > uc_decode_notifier() calls memory_failure(). For dirty pages, > memory_failure() invokes try_to_unmap() with the TTU_HWPOISON flag, > converting the PTE to a hwpoison entry. As a result, > kill_accessing_process(): > > - call walk_page_range() and return 1 regardless of whether > try_to_unmap() succeeds or fails, > - call kill_proc() to make sure a SIGBUS is sent > - return -EHWPOISON to indicate that SIGBUS is already sent to the > process and kill_me_maybe() doesn't have to send it again. > > However, for clean pages, the TTU_HWPOISON flag is cleared, leaving the > PTE unchanged and not converted to a hwpoison entry. Conversely, for > clean pages where PTE entries are not marked as hwpoison, > kill_accessing_process() returns -EFAULT, causing kill_me_maybe() to > send a SIGBUS. > > Console log looks like this: > > Memory failure: 0x827ca68: corrupted page was clean: dropped without side effects > Memory failure: 0x827ca68: recovery action for clean LRU page: Recovered > Memory failure: 0x827ca68: already hardware poisoned > mce: Memory error not recovered > > To fix it, return 0 for "corrupted page was clean", preventing an > unnecessary SIGBUS to user process. > > [1] https://lore.kernel.org/lkml/20250217063335.22257-1-xueshuai@linux.alibaba.com/T/#mba94f1305b3009dd340ce4114d3221fe810d1871 > Fixes: 046545a661af ("mm/hwpoison: fix error page recovered but reported "not recovered"") > Signed-off-by: Shuai Xue > Cc: stable@vger.kernel.org Thanks for your detailed commit log. This patch looks good to me. Acked-by: Miaohe Lin Thanks. .