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 E7959C28B2E for ; Wed, 12 Mar 2025 08:03:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ED80280002; Wed, 12 Mar 2025 04:03:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A194280001; Wed, 12 Mar 2025 04:03:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06A25280002; Wed, 12 Mar 2025 04:03:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DEAAA280001 for ; Wed, 12 Mar 2025 04:03:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9AB24C0CB2 for ; Wed, 12 Mar 2025 08:03:34 +0000 (UTC) X-FDA: 83212159548.30.DC45331 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf30.hostedemail.com (Postfix) with ESMTP id 3B12480010 for ; Wed, 12 Mar 2025 08:03:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=OPfIehn4; spf=pass (imf30.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741766612; 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:dkim-signature; bh=4eQWP95hD+rHKyU8INAu0G1d6sAjuAMp9XDqbuG9YPA=; b=XYxFC+lRb4gb+3jiXsTodZMLX50ZdXDSpElrzocr7ORu3AnK+SxXVzzOXh4PaFycX+emyU gJGUDfFz7/nL8wv4PRERQLckgPW881IKsKwfKZDd6cSawqyLFy0rPyRWr6J7LcQjWPst4g 0jQyb/b/LpCxLZiHavqPTkSJfd2IwF4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741766612; a=rsa-sha256; cv=none; b=DaUNpobOVGvOhwCf3MJktV9KS7HwSnBHyfEm39wls2ifInxUNhmiTFgMliy4txcjdk3diQ pRn/hR3TRgj3V19s84cNaGubD1DVl8VJNma+LsSQDwz26KBiDtDhfVSuqSnN0ap6i2GpoJ 3kd4PR7i++Kyam9KVmGutw0w+/7FF1Q= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=OPfIehn4; spf=pass (imf30.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1741766606; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=4eQWP95hD+rHKyU8INAu0G1d6sAjuAMp9XDqbuG9YPA=; b=OPfIehn4lAwlVIgB4gyAWjyk5LPK4GGXCgFzb7SOjZt8NEwrNZdm89r7wjNlZm4ea6Lwl1IaZuUZYlQujUrgA5kYdB0XG2YkqnzFFhmeJ5y7PdrdylVTS+Ko5x5N7VDmvd+oEtd6qwJW2Y/hm7JGiRaFfItglCCdoJ78rUVh3AM= Received: from 30.221.65.55(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0WRBqTIH_1741766603 cluster:ay36) by smtp.aliyun-inc.com; Wed, 12 Mar 2025 16:03:24 +0800 Message-ID: <62e01956-0796-42d5-b4fc-f66b478bf9bc@linux.alibaba.com> Date: Wed, 12 Mar 2025 16:03:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/3] mm/hwpoison: Do not send SIGBUS to processes with recovered clean pages To: Miaohe Lin , tony.luck@intel.com, Borislav Petkov Cc: tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, jpoimboe@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, tianruidong@linux.alibaba.com, bp@alien8.de, peterz@infradead.org, catalin.marinas@arm.com, yazen.ghannam@amd.com, akpm@linux-foundation.org, nao.horiguchi@gmail.com References: <20250307054404.73877-1-xueshuai@linux.alibaba.com> <20250307054404.73877-3-xueshuai@linux.alibaba.com> <662a16ee-66d3-3fc8-6488-8788bcfbe84e@huawei.com> From: Shuai Xue In-Reply-To: <662a16ee-66d3-3fc8-6488-8788bcfbe84e@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 3B12480010 X-Stat-Signature: gygocfqugdbnsnd6gobomej9854etzgh X-HE-Tag: 1741766609-360387 X-HE-Meta: U2FsdGVkX1/6MtQi5jaY67QjXKM5HrWZvXCigvoehmMv3H3P0ZYt1d46jTnGay9W7YGWz/JI9tfWS+iVWFtFDEtwALH2xMaqigo8ZWDnIS/ZW5y/EYmWTwQttm0RNFz0HoMlWkAHlD1FGblxxskwJwXn34B7drBIyPJjqx89DpakMXZwfxfZ7jExNj82eRw1dHmGswGJQujzZ4cwJAQg9LF/A2gAad7c/+tWx1wOErLT0VOVdaE3uMIlks2j9198WRCPXFCdgv0b9f4wjl2Hv3iPjcuHpVVpg2riu+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6XGPy2uWJuqcgWNxrm9F6swVt X-Bogosity: Ham, tests=bogofilter, spamicity=0.015920, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 2025/3/12 14:39, Miaohe Lin 写道: > 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. > . Thanks. Most part is borrowed from disscusion with Tony and Borislav. Thanks to them :) Best Regards, Shuai